Skip to content

Instantly share code, notes, and snippets.

View vincent178's full-sized avatar
💭
Hacking

Vincent Huang vincent178

💭
Hacking
View GitHub Profile
@vincent178
vincent178 / NSTask-Output.m
Created September 24, 2013 07:57
Get NSTask Standard Output
NSTask * list = [[NSTask alloc] init];
[list setLaunchPath:@"/bin/ls"];
[list setCurrentDirectoryPath:@"/"];
NSPipe * out = [NSPipe pipe];
[list setStandardOutput:out];
[list launch];
[list waitUntilExit];
[list release];
@vincent178
vincent178 / rails_layout.rb
Created October 4, 2013 23:50
Rails layout auto render based on xhr request
layout proc { |controller| controller.request.xhr? ? nil : 'application' }
@vincent178
vincent178 / loc.sh
Last active December 28, 2015 17:59
How many lines of codes in your project
XCode project codes without CocoaPods
find . \( -iname \*.m -o -iname \*.mm -o -iname \*.c -o -iname \*.cc -o -iname \*.h \) \-not -path "./Pods/*" -exec wc -l '{}' \+
Sinatra project codes
find . \( -iname \*.rb -o -iname \*.rake \) -exec wc -l '{}' \+
@vincent178
vincent178 / ArrayDataSource.m
Created December 10, 2013 13:33
Separate Out Data Source
@implementation ArrayDataSource
- (id)itemAtIndexPath:(NSIndexPath*)indexPath {
return items[(NSUInteger)indexPath.row];
}
- (NSInteger)tableView:(UITableView*)tableView
numberOfRowsInSection:(NSInteger)section {
return items.count;
}
@vincent178
vincent178 / centos_setup.md
Last active November 5, 2018 19:17
CentOS install Ruby Rails Nginx and Passenger (tested on CentOS 6.3)

Install Sudo

Update yum

$ yum update

Install Sudo

$ yum install sudo
@vincent178
vincent178 / ubuntu_setup.md
Last active August 29, 2015 13:57
Ubuntu Server Setup with Ruby Rails Nginx and Passenger

Create Account

Create Account for Application

$ useradd -m -s /bin/bash deploy

Add write permission to sudoers

$ adduser deploy sudo

Install Package

$ sudo yum install postgresql-devel

Setting PostgresSQL

Initilize Database

$ sudo /etc/init.d/postgresql initdb
@vincent178
vincent178 / curl.md
Last active August 29, 2015 13:58
#linux #curl

Get method

$ 

Post method

$ curl -H 'Content-Type: application/json' \
       -H 'Accept: application/json' \
 -X POST http://localhost:3000/users/sign_in \

KEYS * type

FLUSHDB and FLUSHALL FLUSHDB deletes all keys in the current databases FLUSHALL deletes all keys in all databases clear redis database

redis-cli KEYS soulmate-* | xargs redis-cli DEL

@vincent178
vincent178 / segue-between-different-storyboard.m
Last active August 29, 2015 13:58
segue between different storyboard
// Get the storyboard named secondStoryBoard from the main bundle:
UIStoryboard *secondStoryBoard = [UIStoryboard storyboardWithName:@"secondStoryBoard" bundle:nil];
// Load the initial view controller from the storyboard.
// Set this by selecting 'Is Initial View Controller' on the appropriate view controller in the storyboard.
UIViewController *theInitialViewController = [secondStoryBoard instantiateInitialViewController];
//
// **OR**
//
// Load the view controller with the identifier string myTabBar