I hereby claim:
- I am tmarshall on github.
- I am timmars (https://keybase.io/timmars) on keybase.
- I have a public key ASDg3nQOy7XnHPnJ5Xa2-Ve8olubAzz22vE5rNeUT1Nz_Ao
To claim this, I am signing this object:
/* | |
returns the 'type' of a single value | |
getType({}) // 'object' | |
getType([]) // 'array' | |
getType('') // 'string' | |
getType(12) // 'number' | |
getType(5n) // 'bigint' | |
getType(new Date()) // 'date' | |
getType(new Error()) // 'error' | |
gotchyas: |
const templatized = (template, vars = {}) => { | |
const handler = new Function('vars', [ | |
'const tagged = ( ' + Object.keys(vars).join(', ') + ' ) =>', | |
'`' + template + '`', | |
'return tagged(...Object.values(vars))' | |
].join('\n')) | |
return handler(vars) | |
} |
const upperLettersMatch = /[A-Z]+/g | |
function camelToSnakeCase(str) { | |
return str | |
.replace(upperLettersMatch, (match, indx, baseString) => { | |
const replacement = match.length === 1 ? match : | |
match.length + indx === baseString.length ? match : | |
match.substr(0, match.length - 1) + '_' + match.substr(-1) | |
return ( | |
(indx === 0 ? '' : '_') + |
xxyyzz() { | |
PGPASSWORD='1!2' | |
echo "$PGPASSWORD" | |
} |
#!/usr/bin/env osascript -l JavaScript | |
/* | |
osascript -l JavaScript <this-file.js> | |
see https://github.com/JXA-Cookbook/JXA-Cookbook/wiki/ | |
*/ | |
const System = Application('System Events') | |
const Terminal = Application('Terminal') |
'use strict'; | |
const slice = Array.prototype.slice; | |
/* | |
There is a common pattern where values need to be pushed into an array, skipping any duplicates. | |
When doing this with objects (like API results) you will often check against one key. | |
For example, you may have something like: |
I hereby claim:
To claim this, I am signing this object:
(function() { | |
var | |
window = this, | |
Denizen = window.Denizen = function(name, options) { | |
options = options || {}; | |
var object = options.init || options.extend || new Function; | |
object.constructor = Denizen; | |
object.$type = name.toLowerCase(); |
var AWS = require('aws-sdk'); | |
AWS.config.update({ | |
accessKeyId: '{AWS_KEY}', | |
secretAccessKey: '{AWS_SECRET}', | |
region: '{SNS_REGION}' | |
}); | |
var sns = new AWS.SNS(); |
/* | |
Clones an argument, intelligently. | |
@param {Object} obj The object being cloned | |
@returns {Object} The cloned object | |
*/ | |
function objectClone(arg /*, originalObjs, newObjs */) { | |
var | |
originalObjs = arguments.length > 1 ? arguments[1] : [ ], // collection of original object values (used to detect where two attributes should equal the same thing) | |
newObjs = arguments.length > 2 ? arguments[2] : [ ], // collection of new objects (to match up to the originals) |