Skip to content

Instantly share code, notes, and snippets.

View ashchan's full-sized avatar
🏠
Working from Mars

Jianming Chen ashchan

🏠
Working from Mars
View GitHub Profile
@ashchan
ashchan / 0_reuse_code.js
Last active August 29, 2015 14:07
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
jQuery(function() {
$.cookie('tz', (new Date()).getTimezoneOffset());
});
@ashchan
ashchan / Capfile
Created November 15, 2010 14:35 — forked from nstielau/Capfile
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
##################################
# Edit these
set :application, "example_node_app"
set :node_file, "hello_world.js"
set :host, "ec2-174-129-114-66.compute-1.amazonaws.com"
ssh_options[:keys] = [File.join(ENV["HOME"], ".ec2", "default.pem")]
set :repository, "git://gist.github.com/479007.git"
set :branch, "master"
@ashchan
ashchan / gist:589094
Created September 21, 2010 02:34
NSDate class method to get an NSDate from an internet date time string (RFC822 or RFC3339)
// Return date for internet date string (RFC822 or RFC3339)
// - RFC822 http://www.ietf.org/rfc/rfc822.txt
// - RFC3339 http://www.ietf.org/rfc/rfc3339.txt
// - Good QA on internet dates: http://developer.apple.com/iphone/library/qa/qa2010/qa1480.html
// - Cocoa date formatting: http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns
+ (NSDate *)dateFromInternetDateTimeString:(NSString *)dateString {
// Setup Date & Formatter
NSDate *date = nil;
static NSDateFormatter *formatter = nil;
@ashchan
ashchan / gist:71520
Created February 27, 2009 15:25 — forked from jsierles/gist:31100
#!/usr/bin/env ruby
#
# fetch hosts from amazon EC2 meta-data
#
# Based on http://dysinger.net/2008/10/13/using-amazon-ec2-metadata-as-a-simple-dns
#
%w(logger optparse rubygems right_aws resolv pp).each { |l| require l }
LOGGER = Logger.new("/var/log/fetch_hosts.log")