Skip to content

Instantly share code, notes, and snippets.

View yuanfeiz's full-sized avatar

YuanfΞi Zhu yuanfeiz

  • The Homestead Arcology
View GitHub Profile
@yuanfeiz
yuanfeiz / checkin.rb
Created October 12, 2012 13:17
虾米自动签到
require 'mechanize'
require "logger"
require 'json'
def login_url
"http://www.xiami.com/member/login"
end
def checkin_url
"http://www.xiami.com/task/signin"
@yuanfeiz
yuanfeiz / gist:3759298
Created September 21, 2012 01:32
还原为iOS优化过的PNG
find ./ -name "*.png" -depth 1 | sed 's:\([^/]*\.png\):\1 \1\.new:g' | xargs -n 2 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush -revert-iphone-optimizations
@yuanfeiz
yuanfeiz / Gemfile
Created June 20, 2012 04:40
qiniu demo in ruby
source :rubygems
gem 'rest-client'
gem 'multi_json'
@yuanfeiz
yuanfeiz / NSObject+AssociatedObjects.h
Created June 15, 2012 08:11 — forked from xslim/NSObject+AssociatedObjects.h
Blocks support for RestKit RKClient
#import <Foundation/Foundation.h>
@interface NSObject (AMAssociatedObjects)
- (void)associateValue:(id)value withKey:(void *)key; // Retains value.
- (id)associatedValueForKey:(void *)key;
@end
@yuanfeiz
yuanfeiz / happyphone.bashrc
Created May 30, 2012 15:10
dot bashrc for HappyPhone shell
alias respring="killall SpringBoard"
alias grep="grep --color=tty"
#!/usr/bin/awk -f
BEGIN {
g_max = -1;
g_min = 999999999;
}
{
match($0, /[0-9]*\ \"-\"/);
timeInterval = substr($0, RSTART, RLENGTH - 4) / 1e6;
g_count += timeInterval;
g_max = (g_max > timeInterval ? g_max : timeInterval);
<%= content_for :title do %>
关于我们 - VIDA(唯达) - 你我的生活轨迹
<% end -%>
<%= content_for :meta_description do %>
Vida 在西班牙语和葡萄牙语中是Life的意思,我们以此寓意为我们的产品命名。
<% end-%>
<div id="contact">
<a id="follow-us" href="http://weibo.com/vidafm" onClick="javascript: pageTracker._trackPageview('clicktrack-frontpage-followus');">关注我们的新浪微博 @vida_唯达</a>
@yuanfeiz
yuanfeiz / iProxy.rake
Created April 9, 2012 13:27
upload a pac which have self as a proxy server
require 'rest_client'
class KVStore
def self.shared_instance
@@_shared_instance ||= RestClient::Resource.new("http://api.openkeyval.org")
end
def self.store(key, value = nil)
shared_instance[key].post({:data => value})
end
%form{:action=>"/upload",:method=>"post",:enctype=>"multipart/form-data"}
%input{:type=>"file",:name=>"file"}
%input{:type=>"submit",:value=>"Upload"}
@yuanfeiz
yuanfeiz / upload.rb
Created April 5, 2012 09:11
sinatra upload file
require 'sinatra'
post '/upload' do
unless params[:file] &&
(tmpfile = params[:file][:tempfile]) &&
(name = params[:file][:filename])
@error = "No file selected"
return haml(:upload)
end
STDERR.puts "Uploading file, original name #{name.inspect}"