Skip to content

Instantly share code, notes, and snippets.

View maxgfr's full-sized avatar
🎯
Focusing

Maxime Golfier maxgfr

🎯
Focusing
View GitHub Profile
@maxgfr
maxgfr / sitcky.html
Created February 17, 2022 20:16
Sticky footer using flexbox
<body>
<div class="content">
content
</div>
<footer class="footer"></footer>
</body>
@maxgfr
maxgfr / context.tsx
Last active February 17, 2022 11:35
Generic context react
import { ContextType, Result } from "./types";
import React, { Context, createContext } from "react";
export const Context =
createContext<ContextType<Result> | null>(null);
return (
<Context.Provider
value={{
result: {} as Result
@maxgfr
maxgfr / explicit.ts
Last active February 17, 2022 10:27
Type guard and type conversion in typescript
// https://www.typescriptlang.org/play?#code/C4TwDgpgBAglC8UDeBYAUFTUwCcD2YAjAFxQDOwOAlgHYDm6W2+YATKRdfY1rgQMwdKtBmgC+6dKEhQAQgigB5ALZVgAHhgAaKAHI+bXQD5JaadADCClWs079LfsdPmoADXUAVKBAAewCBoAEzJYKAAfOQioCyMFbz8A4NC4AH4w0gT-QJCo9PlSCwBuUwBjPBoKKCoyC1IPWIUkKB5MAxIoACIQPE6tVuYCdi6AdwgyAAs+9Ak0dHLK4GqyWXr1WTjEZoH20m7e-oxeRz2yAEMAGwBXYGnxMoqqmpg1mE3kFqO2lg79u6YDMNOmNJv9jgJTpcbncxEA
type A = {
prop1: string
prop2: string
prop3: string
}
type B = Omit<A, 'prop2'>
@maxgfr
maxgfr / connect.md
Last active December 2, 2022 22:53
How to create a port forwarding through ssh

Create a port forwarding through ssh

# ssh -L [my_machine_port]:[remote_machine_port] [remote_user]@[remote_ip]

ssh -L 5000:localhost:3200 [email protected] # Here I forward the remote 3200 port on my localhost:5000
@maxgfr
maxgfr / publish_github.yml
Last active March 7, 2022 17:35
Actions to publish Node.js package to github and npmpackages
name: Publish package on github
on:
workflow_dispatch:
jobs:
publish:
name: Publish on github packages
runs-on: ubuntu-latest
permissions:
name: Node.js CI/CD
on: [push] # tells github to run this on any push to the repository
jobs:
test: # names the job
runs-on: ubuntu-latest # sets the version of linux we want to use, should be what you have on your server
strategy:
fail-fast: false # tells github to not run further steps if this one fails
@maxgfr
maxgfr / fetch_twitch.js
Last active January 2, 2022 19:02
Fetch graphql twitch by game
const fetch = require('node-fetch')
const QUERY = (name) => `
query {
game(name: "${name}") {
id
name
streams(first: 50) {
edges {
node {

How to iterate svgo on a folder ?

find MY_FOLDER -type f -name '*.svg' -print0 | xargs -0 -n 1 -P 6 svgo

All Mongoose Schema Types

var schema = new Schema({
  name:    String,
  binary:  Buffer,
  living:  Boolean,
  updated: { type: Date, default: Date.now },
  age:     { type: Number, min: 18, max: 65 },
  mixed:   Schema.Types.Mixed,
@maxgfr
maxgfr / generate_secret_key_jwt.md
Last active January 2, 2022 22:06
NodeJS cryptography key generator

Generate Secret Key for JWT

Source : dwyl/hapi-auth-jwt2#48 (comment)

node -e "console.log(require('crypto').randomBytes(256).toString('base64'));" # option 1
openssl rand 256 | base64 # option 2