Skip to content

Instantly share code, notes, and snippets.

View ryanhanwu's full-sized avatar
🎯
Focusing

Ryan Wu ryanhanwu

🎯
Focusing
View GitHub Profile
@ryanhanwu
ryanhanwu / npm-upgrade-bleeding.sh
Last active August 29, 2015 01:15 — forked from othiym23/npm-upgrade-bleeding.sh
a safe way to upgrade all of your globally-installed npm packages
#!/bin/sh
set -e
set -x
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f3)
do
npm -g install "$package"
done
#!/bin/bash
# https://gist.github.com/949831
# http://blog.carbonfive.com/2011/05/04/automated-ad-hoc-builds-using-xcode-4/
# command line OTA distribution references and examples
# http://nachbaur.com/blog/how-to-automate-your-iphone-app-builds-with-hudson
# http://nachbaur.com/blog/building-ios-apps-for-over-the-air-adhoc-distribution
# http://blog.octo.com/en/automating-over-the-air-deployment-for-iphone/
# http://www.neat.io/posts/2010/10/27/automated-ota-ios-app-distribution.html
@ryanhanwu
ryanhanwu / 0_reuse_code.js
Created May 2, 2014 17:26
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ryanhanwu
ryanhanwu / Singleton.m
Last active August 29, 2015 14:06 — forked from advantis/Singleton.m
// Simple implementation (not thread-safe)
+ (Singleton *) sharedSingleton
{
static Singleton *instance;
if (nil == instance)
{
instance = [self new];
}
return instance;
}
{ countries : [
{name: 'Afghanistan', code: 'AF'},
{name: 'Åland Islands', code: 'AX'},
{name: 'Albania', code: 'AL'},
{name: 'Algeria', code: 'DZ'},
{name: 'American Samoa', code: 'AS'},
{name: 'AndorrA', code: 'AD'},
{name: 'Angola', code: 'AO'},
{name: 'Anguilla', code: 'AI'},
{name: 'Antarctica', code: 'AQ'},
@ryanhanwu
ryanhanwu / agg.coffee
Last active August 29, 2015 14:26 — forked from lawrencejones/agg.coffee
Projection generator for mongodb
_ = require 'underscore'
# Given an array of elements ELEM and a matching KEY value,
# will build the apprpriate projection to generate sortable
# weights for a mongo aggregator.
#
# ELEM: An array of values upon which to match against KEY
# KEY: The document field key to match against
# I: Default 0, index into array at which to begin
#
@ryanhanwu
ryanhanwu / __stack.js
Created April 20, 2012 06:40 — forked from bmeck/__stack.js
stack trace api fun for the masses.
var stack_holder = new Error
function stackPrepare(e,stacks) {
var stack = stacks
for(var p in stack[0]) {
stack[p] = stack[0][p]
}
stack.find = function(fn) {
console.log(stack)
for(var i=0;i<stack.length;i++) {
if(stack[i].getFunction() === fn) {
@ryanhanwu
ryanhanwu / wget.js
Created August 6, 2012 02:28 — forked from xonecas/wget
simple wget for node.js
require('http');
function wget(host, path, https, callback) {
var port = (https) ? 443 : 80,
client = http.createClient(port, host, https),
request = client.request('get', path, {
'host': host
}),
response_body = '';
@ryanhanwu
ryanhanwu / snippet.js
Created September 12, 2012 11:48 — forked from christopherdebeer/snippet.js
Node.js Express - Mobile detection
app.get('/', function(req, res){
var ua = req.header('user-agent');
if(/mobile/i.test(ua)) {
res.render('mobile.html');
} else {
res.render('desktop.html');
}
});
@ryanhanwu
ryanhanwu / .gitignore
Created October 2, 2012 07:24
sina weibo OAuth with node-oauth for node.js+express
node_modules
config.js