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 / index.js
Created September 3, 2014 21:05
Scrape web page for coffee shop address
var request = require('request'),
jsdom = require('jsdom');
request({
uri: 'http://cupsapp.com/'
}, function(error, response, body) {
if(error && response.statusCode !== 200) {
console.log('Error when contacting CUPS Page');
}
@ryanhanwu
ryanhanwu / lookup.js
Created September 3, 2014 21:11
Lookup csv address and convert to latitude and longitude
var geocoder = require('geocoder'),
seqqueue = require('seq-queue'),
csv = require("fast-csv"),
fs = require('fs'),
stream = fs.createReadStream("pharmacy.csv");//CSV File with pharmacy data from database
var LookupAndPrint = function() {
this.queue = seqqueue.createQueue(1000);
};
LookupAndPrint.prototype.cl = function(addr, data) {
@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;
}
@ryanhanwu
ryanhanwu / distance.m
Created September 10, 2014 15:08
Calculate distance between two location
#import <CoreLocation/CoreLocation.h>
CLLocation *locA = [[CLLocation alloc] initWithLatitude:lat1 longitude:long1];
CLLocation *locB = [[CLLocation alloc] initWithLatitude:lat2 longitude:long2];
CLLocationDistance distance = [locA distanceFromLocation:locB];
//Distance in Meters
//1 meter == 100 centimeter
@ryanhanwu
ryanhanwu / gist:80fbba02347d9d1853ec
Created September 10, 2014 15:09
campass heading
There is no native compass UIView. In order to use the magnetometer, you'll have to use CoreLocation and the following delegate method:
- (void) locationManager:(CLLocationManager *)manager
didUpdateHeading:(CLHeading *)newHeading
to rotate a UIView to point North (bearingView is a UIImageView):
float heading = newHeading.magneticHeading; //in degrees
float headingDegrees = (heading*M_PI/180); //assuming needle points to top of iphone. convert to radians
self.bearingView.transform = CGAffineTransformMakeRotation(headingDegrees);
@ryanhanwu
ryanhanwu / installed_package.json
Created October 8, 2014 03:23
Sublime text 3 installed plugins
{
"installed_packages":
[
"Alignment",
"All Autocomplete",
"AutoFileName",
"Autoprefixer",
"BracketHighlighter",
"DocBlockr",
@ryanhanwu
ryanhanwu / GeoConverter.js
Created October 22, 2014 09:34
GeoConverter. Meter, KiloMeter, Radian
(function() {
var GeoConverter;
GeoConverter = (function() {
var EARTH_MILES = 24902,
EARTH_KM = 40076,
DEGREE_KM = EARTH_KM / 360,
DEGREE_MI = EARTH_MILES / 360,
DEGREE_M = DEGREE_KM * 1000,
MILE_METER = 1609.34,
RADIAN_DEGREE = 57.2957795;