Combine default parameters and destructuring for a compact version of the defaults / overrides pattern.
function foo ({
bar = 'no',
baz = 'works!'
} = {}) {
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env | |
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced | |
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start | |
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running. | |
# Add the following to your shell init to set up gpg-agent automatically for every shell | |
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then | |
source ~/.gnupg/.gpg-agent-info | |
export GPG_AGENT_INFO | |
else |
var LRU = require('lru-cache'); | |
var i = 0; | |
var sets = 0; | |
var start = Date.now(); | |
var last = Date.now(); | |
var max = 8193; // 8192 is the magic number upper perf limit of plain objects | |
var maxAge = 1000 * 60 * 60 * 24; |
#!/bin/bash | |
#------------------------------------------------------------------------------- | |
# download/unpack componentry for N|Solid into ~/nsolid | |
#------------------------------------------------------------------------------- | |
# updates: | |
# 2016-05-04 print note about officially supported "Download All" tarball | |
# 2016-02-10 change to get N|Solid versions dynamically from index.tab | |
# 2016-02-10 upgrade to N|Solid 1.2.1 | |
# 2016-01-12 upgrade to N|Solid 1.2.0 |
Benchmarking: create-10 | |
bn.js#create-10 x 1,967,120 ops/sec ±1.65% (9 runs sampled) | |
bignum#create-10 x 642,220 ops/sec ±0.80% (8 runs sampled) | |
------------------------ | |
Fastest is bn.js#create-10 | |
======================== | |
Benchmarking: create-hex | |
bn.js#create-hex x 2,610,191 ops/sec ±0.85% (9 runs sampled) | |
bignum#create-hex x 614,238 ops/sec ±2.36% (9 runs sampled) | |
------------------------ |
/** | |
* get - XHR Request | |
*/ | |
let get = function (url) { | |
return function (callback) { | |
let xhr = new XMLHttpRequest(); | |
xhr.open('GET', url); | |
xhr.onreadystatechange = function() { | |
let response = xhr.responseText; |
launchctl unload /Library/LaunchAgents/org.macosforge.xquartz.startx.plist | |
sudo launchctl unload /Library/LaunchDaemons/org.macosforge.xquartz.privileged_startx.plist | |
sudo rm -rf /opt/X11* /Library/Launch*/org.macosforge.xquartz.* /Applications/Utilities/XQuartz.app /etc/*paths.d/*XQuartz | |
sudo pkgutil --forget org.macosforge.xquartz.pkg | |
# Log out and log in |
# | |
# sorted_json.rb | |
# Puppet module for outputting json in a sorted consistent way. I use it for creating config files with puppet | |
require 'json' | |
def sorted_json(json) | |
if (json.kind_of? String) | |
return json.to_json | |
elsif (json.kind_of? Array) |