Skip to content

Instantly share code, notes, and snippets.

// 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];
}
@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
@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: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 / 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',
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 / gist:6075388
Last active December 20, 2015 04:59
timestamp handling example for PHP and javascript
<?php
$now = time();
?>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script type="text/javascript">
// we will add our javascript code here
wfeng@mbp  ~  which hg
/usr/local/share/python/hg
Mercurial.configure do |conf|
conf.hg_binary_path = "/usr/local/share/python/hg"
end
repo = Mercurial::Repository.open("/Users/wfeng/work_local/www/betslip")
repo.branches.active.collect { |b| { :name => b.name, :hash_id => b.hash_id, :selected => ["HEAD", "default"].include?(b.name) } }
<?php
function change_value_1(array $o) {
$o['b'] = 5;
}
function change_value_2(array $o) {
$o = array();
$o['b'] = 5;
}
<?php
// debug log full
function _dbg_logf() {
$args = func_get_args();
_dbg_log_core(true, $args);
}
// debug log standard
function _dbg_log() {