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 obj = {}; | |
function reduce(accum, doc) { | |
for (var key in doc) { | |
if (doc.hasOwnProperty(key) && typeof doc[key] !== 'function') { | |
const type = typeof doc[key] | |
if (type === 'object') { | |
const aKey = (accum[key] && typeof accum[key] === 'string') ? key + '_obj' : key | |
accum[aKey] = accum[aKey] ? accum[aKey] : {} | |
reduce(accum[aKey], doc[key]) |
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
(* | |
the 'args' dictionary contains following variables: | |
URL => my-http://myhost.domain.com:8080/mysite/a.html?search=blah#myanchor | |
URL_SCHEME => my-http | |
URL_HOST => myhost.domain.com | |
URL_PORT => 8080 | |
URL_PATH => /mysite/a.html | |
URL_QUERY => ?search=blah | |
URL_FRAGMENT => #myanchor | |
URL_VALUE => everything that comes after the 'scheme:' |
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
execve("./node", ["./node"], [/* 32 vars */]) = 0 | |
brk(0) = 0x288c000 | |
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) | |
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd8ca824000 | |
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) | |
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 | |
fstat(3, {st_mode=S_IFREG|0644, st_size=26694, ...}) = 0 | |
mmap(NULL, 26694, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fd8ca81d000 | |
close(3) = 0 | |
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) |
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
execve("./node56", ["./node56"], [/* 17 vars */]) = 0 | |
brk(0) = 0x340d000 | |
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) | |
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f64b6c1b000 | |
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) | |
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 | |
fstat(3, {st_mode=S_IFREG|0644, st_size=30969, ...}) = 0 | |
mmap(NULL, 30969, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f64b6c13000 | |
close(3) = 0 | |
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) |
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
# /etc/nsswitch.conf is set to 600 | |
strace ./node | |
execve("./node", ["./node"], [/* 32 vars */]) = 0 | |
brk(0) = 0x2f42000 | |
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) | |
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f01cb5de000 | |
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) | |
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 | |
fstat(3, {st_mode=S_IFREG|0644, st_size=26694, ...}) = 0 |
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 _ = require('lodash'); | |
var randomString = function (length) { | |
return _(length).range().map(_.partial(_.random, 33, 126, false)).map(_.ary(String.fromCharCode)).join(''); | |
}; |
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
function readableNumber(num) { | |
var s = ['', 'K', 'M', 'B']; | |
var e = Math.floor(Math.log(num) / Math.log(1000)); | |
return (num / Math.pow(1000, e)).toPrecision(3) + s[e]; | |
} |
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
<?php | |
class RobustPDO extends PDO | |
{ | |
/** Call setAttribute to set the session wait_timeout value */ | |
const ATTR_MYSQL_TIMEOUT = 100; | |
/** @var array */ | |
protected $config = []; | |
/** @var bool For lazy connection tracking */ |
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
<?php | |
/** | |
* Compare two arrays and return a list of items only in array1 (deletions) and only in array2 (insertions) | |
* | |
* @param array $array1 The 'original' array, for comparison. Items that exist here only are considered to be deleted (deletions). | |
* @param array $array2 The 'new' array. Items that exist here only are considered to be new items (insertions). | |
* @param array $keysToCompare A list of array key names that should be used for comparison of arrays (ignore all other keys) | |
* @return array[] array with keys 'insertions' and 'deletions' | |
*/ | |
public static function arrayDifference(array $array1, array $array2, array $keysToCompare = null) { |
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 | |
USER="user" | |
PASSWORD="password" | |
HOST="localhost" | |
MYSQL_OPTS="--compact --single-transaction --skip-opt --quick --no-create-info --skip-triggers" | |
if [ "$1" == "" ]; then | |
echo "Usage: $0 database-name [output-dir]" | |
exit 1 | |
fi |
NewerOlder