Skip to content

Instantly share code, notes, and snippets.

View nicolas-zozol's full-sized avatar
🙂

Nicolas Zozol nicolas-zozol

🙂
View GitHub Profile
// Define the shape of your safe action result.
export interface ActionResult<T> {
// When execution is successful, data contains the result.
data?: T;
// Optional error information when input validation fails.
validationErrors?: Record<string, any>;
// Optional error information when bound arguments validation fails.
bindArgsValidationErrors?: Record<string, any>;
// Optional error information when the server code throws.
serverError?: any;
/*
I want a discriminate for post (or product) so that we don't look into a database:
Also '/learn' is the equivalent of '/blog'. It's a parameter named homeUrl
We have 3 discriminant for routes:
- locale. If empty, 'en'. Can be 'fr'.
- categories : ['blockchain'] or ['blockchain','security'] : can be undefined for blogroll
- page/number : Blog roll current page
- /s/slug : last part of the url, if present ; /s/ precises there will be a slug (s for slug)
@nicolas-zozol
nicolas-zozol / .tsx
Created May 17, 2023 07:13
useSize: get responsives sizes inside TSX code with React
/**
* This custom hook is used to get the size of the screen and creates
* a context to share the size with all the components.
*/
import React, { FC, useEffect, useState } from 'react'
export const tabletSize = '634px'
export const desktopSize = '1206px'
@nicolas-zozol
nicolas-zozol / gist:8bcb215a629488549166059db7d99f35
Created January 14, 2021 09:15
nodejs systemd file config
[Unit]
Description=My app
After=syslog.target
[Service]
User=www-data
Type=simple
ExecStart=/home/myuser/mywebsite/node_modules/next/dist/bin/next start -p $PORT
SuccessExitStatus=130
RestartSec=3
Restart=on-failure
@nicolas-zozol
nicolas-zozol / sonoff.js
Created January 6, 2021 13:20
Sonoff basic javascript code
require('dotenv').config()
const ewelink = require('ewelink-api')
const credentials = {
username: process.env.EMAIL,
password: process.env.PASSWORD
}
const devices = {
lili: process.env.LILI // device Id
@nicolas-zozol
nicolas-zozol / docker-compose.yml
Created January 29, 2020 08:05
Adminer + Postgres docker-compose
---
version: "3.3"
services:
# POSTGRES: https://github.com/docker-library/postgres
db:
image: postgres
container_name: db
#restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER}
@nicolas-zozol
nicolas-zozol / option.ts
Created September 12, 2019 14:30
Optional in typecript
export class Optional<T> {
constructor(public value:T) {
}
isPresent():boolean {
return this.value !== null && this.value !== undefined;
}
map(bindCall):Optional<T> {
"rules": {
"no-consecutive-blank-lines": true,
"interface-over-type-literal": false,
"trailing-comma":false,
"object-literal-sort-keys":false,
"member-access":false,
"interface-name":false,
"arrow-parens":false
},
@nicolas-zozol
nicolas-zozol / responds-to-more.scss
Last active March 5, 2021 09:14
Sass-responds-to
// Using media-query to generate some common hide/show css classes.
// Work in Progress, works with my projects.
// !important is sometimes needed with bootstrap, you should try to remove it first.
// Most of the time, I just pick one between laptop or desktop
// Extra small screen / phone ;
$mobileMax: 480px;
// Small screen / tablet
$tabletMax: 850px;
// laptops :
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="funkopop" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/funkopop" />
<property name="javax.persistence.jdbc.user" value="admin" />