Skip to content

Instantly share code, notes, and snippets.

require "open-uri"
def download
if $*[0] == nil or $*[1] == nil or $*[2] == nil
abort "用法示例:ruby #$0 开始数 结束数 存放的目录 EX:如ruby #$0 200 300 d:\\ "
end
time = Time.now
threads = []
for i in $*[0]..$*[1]
exports = "http://blog.ntjy.net/my_blogs/" + i.to_s
@windix
windix / olympic.rb
Created July 31, 2012 04:21
Olympic Game scraper
require "mechanize"
require "sinatra"
require "stringio"
class MedalScraper
def initialize
@sports = {
'archery' => 'Archery',
'athletics' => 'Athletics',
'badminton' => 'Badminton',
@windix
windix / gist:2970224
Created June 22, 2012 04:26
Download codetv videos from codeschool.com (account required)
require 'bundler/setup'
require 'mechanize'
require 'open-uri'
agent = Mechanize.new
# agent.set_proxy 'localhost', 3128
# login
agent.get('https://www.codeschool.com/users/sign_in') do |page|
result = page.form_with(:action => '/users/sign_in') do |form|
@windix
windix / REMDME.md
Created May 27, 2012 10:33
nginx + php-fpm + passenger

NGINX

Installed: 1.3.4 manually

wfeng@ca2:~$ /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.3.4
built by gcc 4.4.5 (Debian 4.4.5-8) 
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-http_gzip_static_module --with-cc-opt=-Wno-error --add-module=/usr/local/src/passenger-3.0.14/ext/nginx
@windix
windix / gist:2375962
Created April 13, 2012 11:13
Mac OS X tips

Mac OS X tips

my version

Mac OS X 10.6.8 (Leopard) 32 bit

ruby -e 'puts RUBY_PLATFORM'
i386-darwin10.8.0
// Get property by name: "performSelector:"
- (void)encodeWithCoder:(NSCoder *)encoder {
for(int i=0; i<kFieldCount; i++) {
NSString *fieldName = [[NSString alloc]initWithFormat:@"field%d", i+1];
//NSString *field = [self performSelector:sel_getUid([fieldName UTF8String])];
NSString *field = [self valueForKey:fieldName];
[encoder encodeObject:field forKey:fieldName];
[fieldName release];
}