Skip to content

Instantly share code, notes, and snippets.

Avatar

Nicolas Gryman ngryman

View GitHub Profile
@ngryman
ngryman / dshell
Created Aug 20, 2020 — forked from bcooksey/dshell
dshell: A little wrapper around the docker-compose run command that intelligently gets you a shell inside a container
View dshell
#!/bin/bash
if [ ! -z $1 ]; then
MATCHER=$1
else
# Try to guess the project based on directory name
MATCHER=`pwd | sed 's/\/.*\///'`
fi
echo "Looking for web container named '$MATCHER'..."
@ngryman
ngryman / localhost-certificate.sh
Created Jul 17, 2020
Certificate generation for localhost
View localhost-certificate.sh
openssl req -x509 -out localhost.crt -keyout localhost.key \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=localhost' -extensions EXT -config <( \
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
View gist:2a38d6ed7b6677aa5f49d9a744823ac8
          🚀    
        ★○•     
     ¸. ¸☆ ☆      
    ° ○ ° ★       
   ☾ ★☆ ☾°      
 ° ☆ ○  ° . •     
  ○ ° ★☾ ☆
View morrocon-lentils.md

Ingredients

  • 250g lentils
  • 1 oinion
  • 3 garlic cloves
  • 1 fat tomatoe
  • 3 tbsp. olive oil
  • 1 tsp. of tomatoe paste
  • 1.5 tsp. of poudered cumin
  • 1 tsp. of poudered curcuma (or turmeric)
@ngryman
ngryman / keybase.md
Created Oct 26, 2019
Keybase verification
View keybase.md

Keybase proof

I hereby claim:

  • I am ngryman on github.
  • I am ngryman (https://keybase.io/ngryman) on keybase.
  • I have a public key ASBd_NtgNSEMC6YmT6USKEd6kbAU4pf1_lxkPNrY2NVChQo

To claim this, I am signing this object:

@ngryman
ngryman / precommit.sh
Created Oct 15, 2019
Pre-commit hook to detect dependencies changes in a monorepo
View precommit.sh
has_package_changed=$(git diff --cached --quiet */package.json packages/*/package.json; echo $?)
if [ $has_package_changed = 1 ]; then
# do stuff
fi
@ngryman
ngryman / example.ts
Created Jun 29, 2019
Updating cached data from multiple parameterized queries after a mutation (hacky solution)
View example.ts
addTask({
variables: { input },
optimisticResponse: {
addTask: {
__typename: 'Task',
id,
...input
}
},
update: (proxy: any, { data: { addTask } }: any) => {
@ngryman
ngryman / create-gif.js
Created Jun 24, 2018
Keep the aspect ratio of your images using GIFs
View create-gif.js
function createGif(width, height) {
const b64wh = btoa(
String.fromCharCode(width & 0xFF) +
String.fromCharCode(width >> 8 & 0xFF) +
String.fromCharCode(height & 0xFF) +
String.fromCharCode(height >> 8 & 0xFF) +
String.fromCharCode(0) +
String.fromCharCode(0)
)
return `R0lGODlh${b64wh}ACwAAAAAAQABAAAC`
@ngryman
ngryman / create-gif.js
Created Jun 24, 2018
Keep the aspect ratio of your images using GIFs
View create-gif.js
function createGif(width, height) {
const buffer = new ArrayBuffer(24)
const byteView = new Uint8Array(buffer)
// signature
byteView.set([ 71, 73, 70, 56, 57, 97 ], 0)
// size
byteView.set([width, width >> 8], 6)
byteView.set([height, height >> 8], 8)
@ngryman
ngryman / dropdown-menu.js
Last active Jan 31, 2018
Gradual usages
View dropdown-menu.js
class DropdownMenu {
state = {
isMenuOpened: this.props.isMenuOpened
}
static defaultProps = {
togglerLabel: 'Show menu'
}
componentDidMount() {