This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *)documentPathForFile:(NSString *)fileName | |
{ | |
NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); | |
NSString *documentPath = [pathArray objectAtIndex:0]; | |
NSString *filePath = [documentPath stringByAppendingPathComponent:fileName]; | |
return filePath; | |
// return [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:fileName]; | |
} | |
- (NSMutableArray *)loadLocalBooksFromDocument:(NSString *)fileName |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# useful nginx configuration for reverse proxy with Apache | |
# edit lines 8, 11, and 30 | |
# taken from: http://syslog.tv/2010/01/11/debian-apache-2-nginx-wordpress-mu/ | |
# edits by jakebellacera (http://github.com/jakebellacera && http://jakebellacera.com) | |
server { | |
listen 80; | |
server_name domain.com *.domain.com; # edit this to your domain |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put this in your lib folder as logger_format.rb and | |
# require it in your environment or an initializer | |
class Logger | |
def format_message(level, time, progname, msg) | |
"#{time.to_s(:long)} -- #{msg}\n" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Polygon | |
@@sides = 10 | |
def self.sides | |
@@sides | |
end | |
end | |
puts Polygon.sides # => 10 | |
class Triangle < Polygon |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://www.npmjs.org/install.sh | sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# remove all existed ruby | |
rm -rf /usr/lib/ruby | |
wget http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.tar.gz | |
tar xzvf ruby-enterprise-1.8.7-2010.02.tar.gz | |
./ruby-enterprise-1.8.7-2010.02/installer | |
# custom the location of ruby installation: /usr/lib/ruby | |
# ruby, passenger, rake, ri, rdoc, rubygem, rack, rails ... will be installed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person | |
def self.person | |
"Person" | |
end | |
end | |
class Person | |
class << self | |
def hello | |
"Hello" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# using rvm with ruby-1.8.7-p249 | |
# latest version 2.7.7 2010-06-17 | |
brew install libxml2 | |
brew link libxml2 | |
# latest version 1.13.1 | |
brew install libiconv | |
brew link libiconv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSURL *url = [NSURL URLWithString:@"http://api.woyiwang.com:4001/test_post_login"]; | |
NSString *body = [NSString stringWithFormat: @"param1=%@¶m2=%@",value1,value2]; | |
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; | |
[theRequest setHTTPMethod:@"POST"]; | |
[theRequest setHTTPBody: [body dataUsingEncoding: NSUTF8StringEncoding]]; | |
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/init.d/nginx | |
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 |