Skip to content

Instantly share code, notes, and snippets.

View quickshiftin's full-sized avatar

Nathan Nobbe quickshiftin

View GitHub Profile
@msmfsd
msmfsd / es7-async-await.js
Last active February 4, 2024 17:38
Javascript fetch JSON with ES7 Async Await
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch
// async function
async function fetchAsync () {
// await response of fetch call
let response = await fetch('https://api.github.com');
// only proceed once promise is resolved
let data = await response.json();
// only proceed once second promise is resolved
@ygotthilf
ygotthilf / jwtRS256.sh
Last active May 23, 2024 07:42
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@joecliff
joecliff / cryptojs_base64_encrypt_decrypt.js
Last active March 11, 2024 08:00
An example of base64 usage in cryptojs
var CryptoJS = require("crypto-js");//replace thie with script tag in browser env
//encrypt
var rawStr = "hello world!";
var wordArray = CryptoJS.enc.Utf8.parse(rawStr);
var base64 = CryptoJS.enc.Base64.stringify(wordArray);
console.log('encrypted:', base64);
//decrypt
var parsedWordArray = CryptoJS.enc.Base64.parse(base64);
@quickshiftin
quickshiftin / phplint.sh
Last active August 29, 2015 13:56
The lint utility you wish `php -l` was out of the box. Lint check multiple PHP files with a single command.
function php_lint
{
for arg in $(seq $#)
do
# Use find to iterate over directories recursively
if [ -d "${!arg}" ]; then
find "${!arg}" -name '*.php' -exec php -l "{}" ";"
# Just run normal files and symlinks through php -l individually
elif [ -f "${!arg}" -o -h "${!arg}" ]; then
php -l "${!arg}"
@quickshiftin
quickshiftin / mysqldbs.sh
Last active August 29, 2015 13:56
mysqldbs - Show all mysql databases for a given host (defaults to localhost) a given user can view with a simple Bash alias.
alias mysqldbs='_() { local h=""; if [ ! -z "$2" ]; then h="-h$2"; fi; echo "show databases;" | mysql -u "$1" "$h" -p; }; _'
@quickshiftin
quickshiftin / git-find-replace.sh
Last active August 29, 2015 13:56
Simple git find-&-replace utility (for use w/ GNU sed)
#--------------------------------------------------------
# Simple search and replace utility for git repositories.
# @note Use w/ GNU sed.
# (c) Nathan Nobbe 2014
# quickshiftin@gmail.com
# http://quickshiftin.com
# $1 - Search
# $2 - Replace
# $3 - Subdirectory (optional, defaults to cwd)
#--------------------------------------------------------
@quickshiftin
quickshiftin / lastd.sh
Created February 10, 2014 19:35
BASH alias to get the last downloaded file on OSX
alias lastd='echo ~/Downloads/$(ls -t ~/Downloads/ | head -n 1)'
@quickshiftin
quickshiftin / git-transmit
Last active January 1, 2020 16:00 — forked from subtleGradient/git-transmit
Checkout this approach for knowing what to transfer. This revision uses a local tag to track each time you use the command. The first time you use it, it pushes all files in the project. At the end of each run it updates the tag to point to HEAD. Next time you run it, it will only push files that have changed since the last push.
#!/usr/bin/env bash
# author: Thomas Aylott SubtleGradient.com
# author: Nathan Nobbe quickshiftin.com
# Find out where HEAD is pointing
head_ref=$(git show-ref --head -s | head -n 1)
# Check to see if transmit tag exists, and get transmit tag hash
_transmit_ref=$(git show-ref --verify -s refs/tags/transmit)
# If there's not transmit tag, create it for the first time.
@kitek
kitek / gist:1579117
Created January 8, 2012 17:50
NodeJS create md5 hash from string
var data = "do shash'owania";
var crypto = require('crypto');
crypto.createHash('md5').update(data).digest("hex");