Skip to content

Instantly share code, notes, and snippets.

View samuelkarani's full-sized avatar

Samuel Karani Mbaabu samuelkarani

  • University of California, Berkeley
  • Paris, France
View GitHub Profile
@ziluvatar
ziluvatar / token-generator.js
Last active April 11, 2024 07:10
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');
@jbritton
jbritton / graphql-cheat-sheet.md
Last active January 4, 2024 21:46
GraphQL Cheat Sheet

GraphQL Cheat Sheet

Overview

  • An alternative approach to RESTful APIs
  • Clients issue queries/mutations to read and update data
  • Clients can fetch only the entity fields that are required
  • GraphQL query syntax can express complex entity relations => nested objects
  • Mitigates the explosion of RESTful endpoints in scenarios where many different representations of an entity are needed
  • Graphiql is a query execution UI, also provides good documentation
@buonzz
buonzz / docker-compose-cheatsheet.sh
Last active April 16, 2020 14:05
docker-compose cheatsheet
$ docker-compose up -d # start containers in background
$ docker-compose kill # stop containers
$ docker-compose up -d --build # force rebuild of Dockerfiles
$ docker-compose rm # remove stopped containers
$ docker ps # see list of running containers
$ docker exec -ti [NAME] bash # ssh to the container
# list all images
docker images
@tpae
tpae / Trie.js
Created November 20, 2016 23:49
Trie.js - super simple JavaScript implementation
// Trie.js - super simple JS implementation
// https://en.wikipedia.org/wiki/Trie
// -----------------------------------------
// we start with the TrieNode
function TrieNode(key) {
// the "key" value will be the character in sequence
this.key = key;
@hakimelek
hakimelek / us_institutions.json
Created September 28, 2016 09:36
A List of American Colleges and Universities in JSON format
[
{
"institution": "Alabama A & M University"
},
{
"institution": "University of Alabama at Birmingham"
},
{
"institution": "Amridge University"
},
@ahmu83
ahmu83 / US_States_and_Cities.json
Created July 20, 2016 16:50
List of US States and Cities in JSON format.
{
"New York": [
"New York",
"Buffalo",
"Rochester",
"Yonkers",
"Syracuse",
"Albany",
"New Rochelle",
"Mount Vernon",
@aresnick
aresnick / index.html
Last active October 22, 2021 12:58
Google Drive Export Client Side Export Example
<html>
<head>
<script type="text/javascript">
// Your Client ID can be retrieved from your project in the Google
// Developer Console, https://console.developers.google.com
var CLIENT_ID = '436763072331-rod105o2ppkpjrcdpsmrvmn2st3qg9el.apps.googleusercontent.com';
var SCOPES = ['https://www.googleapis.com/auth/drive.readonly'];
@subfuzion
subfuzion / curl.md
Last active April 27, 2024 14:16
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@squarism
squarism / iterm2.md
Last active April 26, 2024 19:19
An iTerm2 Cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],