This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://www.justskins.com/forums/format-number-with-comma-37369.html | |
n.to_s.reverse.gsub(/...(?=.)/,'\&,').reverse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new(ENV['MONGOID_HOST'], ENV['MONGOID_PORT'], :logger => Rails.logger).db(ENV['MONGOID_DATABASE']) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
第一次在ruby客户端中途取消,第二次就华丽丽的down掉了 | |
248300/1548508 16% | |
Tue Nov 8 17:59:10 Invalid access at address: 0x2aabdf7dbe24 | |
Tue Nov 8 17:59:10 Got signal: 7 (Bus error). | |
Tue Nov 8 17:59:11 Backtrace: | |
0x8ad399 0x8ad970 0x3dc6a0eb10 0x7345f8 0x77b264 0x682625 0x6876e9 0x688b7f 0x689101 0x689370 0x688fed 0x689370 0x688fed 0x689370 0x688fed 0x689370 0x688fed 0x689370 0x688fed 0x689370 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Started GET "/assets/application.css" for 127.0.0.1 at Tue Jan 17 15:26:06 +0800 2012 | |
Served asset /application.css - 200 OK (42ms) | |
[2012-01-17 15:26:06] ERROR NoMethodError: undefined method `each' for nil:NilClass | |
/usr/local/rvm/gems/ree-1.8.7-2011.03/gems/rack-1.3.6/lib/rack/handler/webrick.rb:71:in `service' | |
/usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' | |
/usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' | |
/usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' | |
/usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/webrick/server.rb:162:in `start' | |
/usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' | |
/usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/webrick/server.rb:95:in `start' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
错误信息:Database command 'mapreduce' failed: (assertion: 'unknown out specifier [db]'; assertionCode: '13522'; errmsg: 'db assertion failure'; ok: '0.0'). | |
解决方案:设置out现象里的db参数应该是一个字符串键,比如{"db" => "mapreduce_db", :replace => "tmp_mapreduce"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DateTime.strptime("08/Mar/2012:11:53:53 +0800", "%d/%b/%Y:%H:%M:%S %z") | |
# => Thu, 08 Mar 2012 11:53:53 +0800 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mon Mar 26 06:23:21 [FileAllocator] allocating new datafile /dbs/mongodb/local.72, filling with zeroes... | |
Mon Mar 26 06:23:45 [FileAllocator] done allocating datafile /dbs/mongodb/local.72, size: 2047MB, took 23.744 secs | |
Mon Mar 26 06:23:45 [FileAllocator] allocating new datafile /dbs/mongodb/local.73, filling with zeroes... | |
Mon Mar 26 06:24:05 [FileAllocator] done allocating datafile /dbs/mongodb/local.73, size: 2047MB, took 20.625 secs | |
Mon Mar 26 06:24:05 [FileAllocator] allocating new datafile /dbs/mongodb/local.74, filling with zeroes... | |
Mon Mar 26 06:24:32 [FileAllocator] done allocating datafile /dbs/mongodb/local.74, size: 2047MB, took 26.592 secs | |
Mon Mar 26 06:24:32 [FileAllocator] allocating new datafile /dbs/mongodb/local.75, filling with zeroes... | |
Mon Mar 26 06:25:02 [FileAllocator] done allocating datafile /dbs/mongodb/local.75, size: 2047MB, took 29.55 secs | |
Mon Mar 26 06:25:02 [FileAllocator] allocating new datafile /dbs/mongodb/local.76, filling with zeroes... | |
Mon Mar 26 06:25:21 [FileAlloca |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%w[open-uri nokogiri].map &method(:require) | |
@regexp = Regexp.new ENV['租房'] | |
(0..19).to_a.map do |n| | |
html = Nokogiri open("http://www.douban.com/group/beijingzufang/discussion?start=#{n*25}") | |
html.css(".article table.olt tr td a").map {|i| {:title => i.attributes['title'].to_s, :href => i.attributes['href'].to_s}}.map do |h| | |
if h[:title].match @regexp | |
puts h.inspect | |
h[:href] | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'inline' | |
class ParseLogInC | |
inline do |builder| | |
builder.c <<-CODE | |
#include 'ruby.h' | |
#include 'stdio.h' | |
static VALUE nginx(VALUE line) { | |
VALUE ary = rb_ary_new(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rack' | |
class Object | |
def webapp | |
class << self | |
define_method :call do |env| | |
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, send(func, *attrs)] | |
end |