Skip to content

Instantly share code, notes, and snippets.

View xumingyong's full-sized avatar

Xu mingyong xumingyong

  • EHDC
  • Sichuan province, China
View GitHub Profile
@xumingyong
xumingyong / gist:4103423
Created November 18, 2012 03:56
How to install gems via GFW
It's simple, add https gem sources:
# gem sources -a https://rubygems.org/
@xumingyong
xumingyong / gist:1891239
Created February 23, 2012 07:09
tips on EventMachine::start_server
# Following comments on eventmachine.rb - V1.0.0-beta4.1
# at line:502
def self.start_server server, port=nil, handler=nil, *args, &block
begin
port = Integer(port)
rescue ArgumentError, TypeError
# there was no port, so server must be a unix domain socket
# the port argument is actually the handler, and the handler is one of the args
args.unshift handler if handler
@xumingyong
xumingyong / gist:1812724
Created February 13, 2012 01:57
Ruby: meta-programming
#definition
class Object < BasicObject
include Kernel
...
end
#examples
module M; end
class C; include M; end
C.ancestors # => [M, Object, Kernel, BasicObject]
@xumingyong
xumingyong / gist:1770838
Created February 8, 2012 16:26
Install EventMachine

Notes:

In windows platform, you must use 
#gem install eventmachine --pre
Then `eventmachine (1.0.0.beta.4.1 x86-mingw32)` installed

Following does not work
#gem install eventmachine

Who knows why?

@xumingyong
xumingyong / gist:1766559
Created February 8, 2012 07:41
Build LibOpenssl with MinGW
@xumingyong
xumingyong / gist:1765862
Created February 8, 2012 05:45
Cool.io & EventMachine

Platform support

Cool.io gem is the new release of Rev gem which is a ruby impelmentation of Libev, but not support Windows.

Performance

Cool.io performance is slow than EventMachine, cause of more functionality are implemented by ruby than in C.

I guess EventMachine is the best event-loop implementation in RUBY enviroment.

@xumingyong
xumingyong / gist:1765052
Created February 8, 2012 03:26
gem install error, when DevKit missed

Error

When I install iobuffer, rev rubygems, following error prompted:

<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- 
script/../config/boot (LoadError)
   from <internal:lib/rubygems/custom_require>:29:in `require'
   from script/server:2:in `<main>'
@xumingyong
xumingyong / gist:1756987
Created February 7, 2012 03:34
Build Libev with MinGW

Steps

  1. Download libev source in http://dist.schmorp.de/libev/
  2. run >sh ./configure
  3. run >make
  4. libev.a static lib file generated in ./lib

Notes:

I remembered that I cannot compile it successfully before. But after I compiled the LibUV, and added the header file & libs, I can build libev successfully.

@xumingyong
xumingyong / gist:1756864
Created February 7, 2012 03:00
Build Libuv with MinGw
------------
1. IPV6 patch
------------
Add following definition code in win/winsock.h
//
// Options to use with [gs]etsockopt at the IPPROTO_IPV6 level.
// These are specified in RFCs 3493 and 3542.
// The values should be consistent with the IPv6 equivalents.