Skip to content

Instantly share code, notes, and snippets.

View haifeng's full-sized avatar
🎯
Focusing

Haifeng Cao haifeng

🎯
Focusing
View GitHub Profile
fg.assets.limit(5)
=> #<Mongoid::Criteria
selector: {"_id"=>{"$in"=>[BSON::ObjectId('52963d53646f6d46c54d0000'), BSON::ObjectId('52963d53646f6d46c54a0000'), BSON::ObjectId('52963d53646f6d46c5470000'), BSON::ObjectId('ffe739e40000ecfac56ab627'), BSON::ObjectId('52963d53646f6d46c5440000'), BSON::ObjectId('52963d53646f6d46c5410000'), BSON::ObjectId('52963d53646f6d46c53e0000'), BSON::ObjectId('52963d53646f6d46c53b0000'), BSON::ObjectId('52963d52646f6d46c5380000'), BSON::ObjectId('52963d52646f6d46c5350000'), BSON::ObjectId('52963d52646f6d46c5320000'), BSON::ObjectId('52963d52646f6d46c52f0000'), BSON::ObjectId('52963d52646f6d46c52c0000'), BSON::ObjectId('52963d52646f6d46c5290000'), BSON::ObjectId('52963d52646f6d46c5260000'), BSON::ObjectId('52963d52646f6d46c5230000'), BSON::ObjectId('5297605169702d35e38d0800'), BSON::ObjectId('ffe61e660000e7f21e191a9c'), BSON::ObjectId('5297605169702d35e3890800'), BSON::ObjectId('ffe61e660000e7f21e191aa2'), BSON::ObjectId('ffe61e660000e7f21e191aa6'), BSON::ObjectId('ffe61e660000
@haifeng
haifeng / vcl
Created November 7, 2013 20:51
vcl
backend F_default {
.host = "origin-imgry.pressly.com";
.port = "80";
}
backend F_s3_host {
.host = "imgrydb.pressly.com.s3.amazonaws.com";
.port = "80";
}
@haifeng
haifeng / pcmag
Created June 28, 2013 19:25
for maciek
(14..28).each do |day|
(0..23).each do |hour|
key = "201306#{day}:#{hour}:510ac2293d3d9dda100001eb:app-hourly-events"
hash = R.hgetall(key)
nav_count = 0
ui_count = 0
hash.each do |k, v|
nav_count += v.to_i if k.index("page:navigate:")
ui_count += v.to_i if k.index("ui:article-open:")
end
6/14/2013 0:00:00, 0, 0
6/14/2013 1:00:00, 0, 0
6/14/2013 2:00:00, 446, 163
6/14/2013 3:00:00, 9165, 1851
6/14/2013 4:00:00, 8965, 1623
6/14/2013 5:00:00, 7926, 1477
6/14/2013 6:00:00, 6135, 1257
6/14/2013 7:00:00, 4489, 937
6/14/2013 8:00:00, 3960, 844
6/14/2013 9:00:00, 3640, 730
{"requests":["?action_name=ttclick&url=http://pressly.com/api/1&idsite=2&rand=351459&h=18&m=13&s=3&rec=1&apiv=1&cookie=&urlref=http://www.pressly.com&id=af344a398df83874&idvc=19&res=320×480"],"token_auth":"4071b7978b9286acb4a72876b350cb8f"}
brokerListener = zmq.socket('pull')
brokerListener.identity = 'Broker Listener:' + process.pid
brokerListener.connect(nconf.get('busUri'))
console.log("#{brokerListener.identity} created.")
brokerListener.on('message', (type, data) ->
console.log("Broker Listener " + brokerListener.identity + ': received type' + type + ', data [' + data.toString() + ']')
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5HxyZAXbtya8XD6Capt+0BqIDyGwGoXyBadoYDQsgVlboY/J9YtQS8916qUVQ/3MIyBOsaw3aqiUeA0YiSlkinR7x9PCn3Btcmag1PWs5KiFxtzDZiKpltsu8xPqg7oo+XEfDklraF4UVMs4ic+/4d45WuZhkPk9j2wD+ipBqgS/piNHQGUM/fcj13f9M3l6DMp5af/aJhpH9LXqj98zbl2bB25RLpYSlH0He1qkUsQRULo+0X3wMwhVsbY+hz9jmzcuXwzq+jhDk9OFo5kiOBcQyDsExo4FwXs5MFvhlNv4FhJ0q0jm+kOE1oONG/sjDaK/lPzsTZgT680PPG2qX haifeng.cao@nulayer.com
@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'
@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",
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",