Skip to content

Instantly share code, notes, and snippets.

@IskenHuang
IskenHuang / app.js
Created September 26, 2012 03:10
Nodejs file upload
app.post('/upload', function(req, res){
data = req.body;
// get the temporary location of the file
console.log('file => '+req.files);
var tmp_path = req.files.file.path;
// set where the file should actually exists - in this case it is in the "images" directory
var target_path = './public/images/'+ req.files.file.name;
// move the file from the temporary location to the intended location
console.log('tmp_path = '+tmp_path+' || target_path = '+target_path);
@IskenHuang
IskenHuang / CheckNetWork.h
Created October 3, 2012 01:28
iOS-CheckNetWork
//
// CheckNetWork.h
//
//
// Created by Isken Huang on 11/13/10.
// Copyright 2010 Isken Huang. All rights reserved.
//
#import <netinet/in.h>
#import <SystemConfiguration/SCNetworkReachability.h>
@IskenHuang
IskenHuang / gist:4255734
Created December 11, 2012 03:39
multiple target in the same project
#ifdef LITE
//lite version
//your code here
#else
//not lite version(i.e. pro)
//your code here
#endif
//-------------------------------------------------------------
@IskenHuang
IskenHuang / AddressBook.m
Created December 17, 2012 09:33
Grant iOS AddressBook permission
-(void) grantAddressBook{
// Request authorization to Address Book
ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error) {
// First time access has been granted, add the contact
[self getContentList:addressBookRef];
});
}
//yahoo weather
NSLog(@"%@", [YahooAPI yahooAPIWeatherWithWOEID:@"12703518"]);
NSLog(@"%@", [YahooAPI yahooAPIWeatherWithWOEID:@"12703518" unit:YAHOO_WEATHER_UNIT_CELSIUS]);
NSLog(@"%@", [YahooAPI yahooAPIWeatherWithWOEID:@"12703518" unit:YAHOO_WEATHER_UNIT_FAHRENHEIT]);
//yahoo woeid
NSLog(@"%@", [YahooAPI yahooAPIWOEIDWithLatitude:25.049826 Longitude:121.572586]);
NSLog(@"%@", [YahooAPI yahooAPIWOEIDWithAddress:@"台北市大安區敦化南路二段267號"]);
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="YOUR_PAYPAL_ACCOUNT">
<!-- code -->
<input type="hidden" name="charset" value="utf-8">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
@IskenHuang
IskenHuang / google login from curl
Created January 8, 2013 15:20
Google oauth login from curl
/*
* Step 1. get access token using curl
* https://developers.google.com/gdata/articles/using_cURL
*
* service name list
* https://developers.google.com/gdata/faq#clientlogin
*
*/
curl https://www.google.com/accounts/ClientLogin \
@IskenHuang
IskenHuang / app.js
Last active December 15, 2015 15:38
Quick launch an web server base on expressjsupdate add support CORS
/**
* Tutorial
*
* Step1. install nodejs & npm (download: http://nodejs.org/download/)
*
* Step2. install express (http://expressjs.com/)
* $ sudo npm install express -g
*
* Step3. $ node app
@IskenHuang
IskenHuang / sublime.md
Created June 17, 2013 15:22
launch sublime from terminal
var keycode = {
'backspace' : '8',
'tab' : '9',
'enter' : '13',
'shift' : '16',
'ctrl' : '17',
'alt' : '18',
'pause_break' : '19',
'caps_lock' : '20',
'escape' : '27',