Skip to content

Instantly share code, notes, and snippets.

View soldair's full-sized avatar

Ryan Day soldair

  • Google
  • San Jose CA
View GitHub Profile
@soldair
soldair / gist:1321164
Created October 27, 2011 23:07
js is object
//is not array object
var isObject = function(o){
return new Object(o) === o && !(o instanceof Array)
}
@soldair
soldair / install_node.sh
Created October 27, 2011 23:29
install nodejs shell script
if [ "node-v0.5.10" !-d ]; then
curl http://nodejs.org/dist/v0.5.10/node-v0.5.10.tar.gz
tar -xvf node-v0.5.10.tar.gz
fi
cd node-v0.5.10
./configure
if [ $? != 0 ]; then
echo "configure failed =("
exit 1;
@soldair
soldair / gist:2495387
Created April 26, 2012 03:02
us format strtotime benchmark with mktime
<?php
function _strtotime_us2($str,$now=null) {
if ($now === null) {
$now = time();
}
$strp = explode('-',$str);
@soldair
soldair / _require.php
Created June 30, 2012 14:47
nodejs style require for php
/*
* nodejs style require for php
* */
function _require($file){
static $requireCache = array();
if(isset($requireCache[$file])) return $requireCache[$file];
//todo support namespaces? evil eval? copy the file... all sad solutions
$module = array();
$module['exports'] = array();
@soldair
soldair / nodejs_passwd_reverse.sh
Created August 22, 2012 22:12
nodejs oneliner to reverse text on all lines of /etc/passwd from stdin to stdout
cat /etc/passwd | node -e "var buf ='',rev=function(lines){lines.forEach(function(l,k){process.stdout.write(l.split('').reverse().join('')+'\n')})};process.stdin.on('data',function(b){buf+=b.toString();b = buf.split('\n');buf = b.shift();rev(b)}); process.stdin.resume();"
@soldair
soldair / pauseresume_walkdir.js
Created September 8, 2012 21:37
pause node walkdir, read a file into a write stream, then resume
// walkdir ~0.0.5
var fs = require('fs')
, walkdir = require('../walkdir')
// write all logs to the logs.cat file
, ws = fs.createWriteStream('logs.cat')
;
var em = walkdir('./');
em.on('file',function(path,stat){
@soldair
soldair / gist:4950965
Created February 14, 2013 06:27
my ssh public key
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6L/Y30hj/CJ/WehbUuSrTb9qTFkX/uHya8copfyg4T0+VexzGhZV7dp5VZISVnk8B0N4ZOlBp5y15pRKR9OIK1q2JjMq5uyGRIkiF62kkvo8PQ/OpMBk/glV0WJ73AZdgYV9HRS8Zr/cnPsw2Lp4hjrMwvj9Tv+Q5l+dl3HQ7O3xfIAdxSe2y62Sn/tg3vp+d6tEtEz8HFc0+YoCbRnhAuXA9R8sEW3nuyLXnITGSZ6SEHcPBkqtEqdshXHRbg8cTu5TenA9jfbyIsF2+hc/kYnek8YUzscUXGYjjg5ItRsoVtBTKf51KPx23ZJGX7VGTmVPsFfC8byj/De2S2GjUw== soldair@host
@soldair
soldair / gist:4988801
Created February 19, 2013 19:01
email rfc compliant regex php
/*
* Method: email_rfc
* Validate email, RFC compliant version
*
* Originally by Cal Henderson, modified to fit Kohana syntax standards:
* - http://www.iamcal.com/publish/articles/php/parsing_email/
* - http://www.w3.org/Protocols/rfc822/
*
* Parameters:
* email - email address
@soldair
soldair / pr
Created February 20, 2013 19:25
function pr () {
local repo=`git remote -v | grep -m 1 "(push)" | sed -e "s/.*github.com[:/]\(.*\)\.git.*/\1/"`
local branch=`git name-rev --name-only HEAD`
if [ "$1" != "" ]; then
local branch=$1
fi
echo "... creating pull request for branch \"$branch\" in \"$repo\""
xdg-open https://github.com/$repo/pull/new/$branch
}
@soldair
soldair / epeerinvalid.log
Created March 14, 2013 06:26
epeerinvalid due to peer dependency added to flatiron-cli-config
make: Leaving directory `/usr/local/lib/node_modules/qrcode/node_modules/canvas/build'
/usr/local/bin/qrcode -> /usr/local/lib/node_modules/qrcode/bin/qrcode
npm WARN package.json eventemitter2@0.4.1 'contributers' should probably be 'contributors'
npm ERR! peerinvalid The package flatiron does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer flatiron-cli-config@0.1.3 wants flatiron@~0.1.9
npm ERR! peerinvalid Peer flatiron-cli-users@0.1.1 wants flatiron@~0.1.9
npm ERR! System Linux 3.2.0-23-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "qrcode"
npm ERR! cwd /usr/local/lib/node_modules