Skip to content

Instantly share code, notes, and snippets.

View haifeng's full-sized avatar
🎯
Focusing

Haifeng Cao haifeng

🎯
Focusing
View GitHub Profile
@haifeng
haifeng / oshi.rb
Created July 10, 2010 13:44 — forked from anonymous/oshi.rb
require 'rubygems'
require 'eventmachine'
require 'em-websocket'
require 'json'
class Connection
attr_accessor :socket, :user_id
def initialize(socket, user_id)
@socket = socket
# Everything you need to do to get started with Rails 2.3.8
#
# As of June 14th, 2010 @ 2:30 p.m. MST
#
# This gist now features instructions to get Rails 3 up and running with:
# - Ruby 1.8.7-p174
# - Bundler 0.9.26
# - Cucumber 0.8.0
# - Rspec 1.3.0 + Rspec-Rails 1.3.2
# - RVM
user app;
worker_processes 2;
error_log /home/app/logs/nginx.error.log info;
events {
worker_connections 1024;
}
@haifeng
haifeng / sunspot_resque.rb
Created October 13, 2011 16:45 — forked from nz/sunspot_resque.rb
Sunspot with Resque
# app/models/post.rb
class Post
searchable :auto_index => false, :auto_remove => false do
text :title
text :body
end
after_commit :resque_solr_update
module Sunspot
class ResqueSessionProxy < Sunspot::SessionProxy::AbstractSessionProxy
attr_reader :original_session
delegate :config, :delete_dirty?, :dirty?,
:new_search, :search,
:new_more_like_this, :more_like_this,
:remove, :remove!,
@haifeng
haifeng / meta.rb
Created August 20, 2012 17:46
i18n positions
$LOAD_PATH << './lib'
require 'i18n.rb'
class Backend < I18n::Backend::Simple
include I18n::Backend::Metadata
end
# if string.respond_to?(:translation_metadata)
require 'http-request'
require 'http'
require 'benchmark'
urls = [
"http://www.lovelygirliebits.com/feeds/posts/default",
"http://www.51arch.com/feed/",
"http://mutelife.com/feed/",
"http://jacksonphillipsinc.com/Tools_of_Trade/Tools_of_the_Trade.xml",
"http://hrishimittal.com/rss",
@haifeng
haifeng / bench.rb
Created April 2, 2013 14:27
http gem benchmark
require 'http-request'
require 'http'
require 'benchmark'
# "http://jacksonphillipsinc.com/Tools_of_Trade/Tools_of_the_Trade.xml",
# "http://hrishimittal.com/rss",
# "http://octave.dk/feed/",
# "http://montreal.kijiji.ca/f-SearchAdRss",
# "http://blog.alezaa.com/rss",
# "http://www.bizbash.com/rss/news.xml",
@haifeng
haifeng / gist:5301538
Created April 3, 2013 14:10
current benchmark for http
require 'jruby'
require 'http-request'
# require 'http'
require 'benchmark'
require 'http_client'
# require './async-http-client-1.7.12.jar'
# require './slf4j-log4j12-1.7.5.jar'
# require './async-http-client-1.6.1.jar'
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5HxyZAXbtya8XD6Capt+0BqIDyGwGoXyBadoYDQsgVlboY/J9YtQS8916qUVQ/3MIyBOsaw3aqiUeA0YiSlkinR7x9PCn3Btcmag1PWs5KiFxtzDZiKpltsu8xPqg7oo+XEfDklraF4UVMs4ic+/4d45WuZhkPk9j2wD+ipBqgS/piNHQGUM/fcj13f9M3l6DMp5af/aJhpH9LXqj98zbl2bB25RLpYSlH0He1qkUsQRULo+0X3wMwhVsbY+hz9jmzcuXwzq+jhDk9OFo5kiOBcQyDsExo4FwXs5MFvhlNv4FhJ0q0jm+kOE1oONG/sjDaK/lPzsTZgT680PPG2qX haifeng.cao@nulayer.com