Skip to content

Instantly share code, notes, and snippets.

View ngryman's full-sized avatar

Nicolas Gryman ngryman

View GitHub Profile
@ngryman
ngryman / usleep.c
Created September 8, 2013 07:07
usleep for Windows.
void usleep(DWORD waitTime){
LARGE_INTEGER perfCnt, start, now;
QueryPerformanceFrequency(&perfCnt);
QueryPerformanceCounter(&start);
do {
QueryPerformanceCounter((LARGE_INTEGER*) &now);
} while ((now.QuadPart - start.QuadPart) / float(perfCnt.QuadPart) * 1000 * 1000 < waitTime);
}
@ngryman
ngryman / README.md
Last active January 16, 2023 14:07
intellij javascript live templates

intellij javascript live templates

Just a dump of handy live templates I use with IntelliJ. They should also work with WebStorm.

How to

  • Go to settings.
  • Search for live templates.
  • Under the javascript section you should be able to manage your templates.
@ngryman
ngryman / city_code.csv
Created March 11, 2022 08:31
German City Codes
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
"city_code"
"A"
"AA"
"AB"
"ABG"
"ABI"
"AC"
"AE"
"AH"
"AIB"
@ngryman
ngryman / example.ts
Created June 29, 2019 17:24
Updating cached data from multiple parameterized queries after a mutation (hacky solution)
addTask({
variables: { input },
optimisticResponse: {
addTask: {
__typename: 'Task',
id,
...input
}
},
update: (proxy: any, { data: { addTask } }: any) => {
@ngryman
ngryman / dshell
Created August 20, 2020 15:35 — forked from bcooksey/dshell
dshell: A little wrapper around the docker-compose run command that intelligently gets you a shell inside a container
#!/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 July 17, 2020 17:53
Certificate generation for localhost
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")
          🚀    
        ★○•     
     ¸. ¸☆ ☆      
    ° ○ ° ★       
   ☾ ★☆ ☾°      
 ° ☆ ○  ° . •     
  ○ ° ★☾ ☆
@ngryman
ngryman / service.conf.sh
Created October 2, 2012 21:10
Post: Using upstart with forever to manage your node.js application
#!upstart
description "your fancy description that no one will see ;)"
author "Your Name <youremail@fqdn>"
# start on every run level, 2 is the one on Ubuntu
start on runlevel [2345]
# stop on halt, maintenance or reboot
stop on runlevel [016]

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 / em.scss
Created March 3, 2013 19:03
sass px to em mixin
// http://viljamis.com/blog/2013/prototyping-responsive-typography/?utm_source=Responsive+Design+Weekly&utm_campaign=76e7785581-Responsive_Design_Weekly_046&utm_medium=email
$browser-context: 16; // Default
@function em($pixels, $context: $browser-context) {
@return #{$pixels/$context}em
}