This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http') | |
// Expectation: When I curl localhost:3000, I want to be able to | |
var server = http.createServer(function (req, res) | |
res.statusCode = 200; | |
res.write(e.stack); // throws exception | |
res.end() | |
}) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use this when you can curl an https server, but node request() will return 'econnreset: socket hang up' | |
var options = { | |
url: 'https://some/site', | |
method: 'POST', | |
// these 3 lines matter | |
strictSSL: false, | |
secureProtocol: 'TLSv1_method', | |
rejectUnhauthorized: false | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh #adding this to force silly gist highlighting. REMOVE THIS | |
# ZSH standalone npm install autocompletion. Add this to ~/.zshrc file. | |
_npm_install_completion() { | |
local si=$IFS | |
# if 'install' or 'i ' is one of the subcommands, then... | |
if [[ ${words} =~ 'install' ]] || [[ ${words} =~ 'i ' ]]; then | |
# add the result of `ls ~/.npm` (npm cache) as completion options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash #adding this to force silly gist highlighting. REMOVE THIS | |
# This is a modified version of the script generated by https://docs.npmjs.com/cli/completion to include `npm install` autocompletion. | |
# Basically we added `if` blocks to check for `install` subcommand. | |
###-begin-npm-completion-### | |
# | |
# npm command completion script | |
# | |
# Installation: npm completion >> ~/.bashrc (or ~/.zshrc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash #adding this to force silly gist highlighting | |
# If you are already using npm autocompletion via (https://docs.npmjs.com/cli/completion), I assume that you have some code in | |
# your .bashrc/.zshrc file. Follow the instruction below to avoid clobbering the npm autocomplete script. | |
##################### | |
#### FOR BASH change THIS (in your .bashrc file) | |
##################### | |
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$cword" \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash #adding this to force silly gist highlighting. REMOVE THIS | |
# BASH standalone npm install autocomplete. Add this to ~/.bashrc file. | |
_npm_install_completion () { | |
local words cword | |
if type _get_comp_words_by_ref &>/dev/null; then | |
_get_comp_words_by_ref -n = -n @ -w words -i cword | |
else | |
cword="$COMP_CWORD" | |
words=("${COMP_WORDS[@]}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// method shorthand. ES6 version. | |
{ | |
initialize() {}, | |
doSomething() {} | |
} | |
// replaces (ES5) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a 'curried' function. If it receives less params than it expects, it returns a function which expects the rest of the params. | |
function add(a, b) { | |
// if 2nd param wasn't passed, return a function that holds the 1st param via closure, but expects another param. | |
if (typeof b === "undefined") { | |
return function(c) { | |
a + c; | |
} | |
} | |
// if 2 params are passed return the result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# $ ./gitmove [destGitRepo] [src_file] | |
DEST_FOLDER=$1 | |
# this will take all parameters AFTER the first. So you can give a list, or a glob (which is expanded into separate params) | |
SOURCE_FILES="${@:2}" | |
# SOURCE_FILE=$2 | |
STARTING_FOLDER=$(pwd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# $ ./gitmove [destGitRepo] [src_file] | |
DEST_FOLDER=$1 | |
SOURCE_FILE=$2 | |
# get the earliest hash of a source file to copy | |
HASH=$(git log --format=%H $SOURCE_FILE | tail -1) | |
# echo $HASH |