Skip to content

Instantly share code, notes, and snippets.

pete higgins phiggins

Block or report user

Report or block phiggins

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View script output
phiggins@gravytrain ~/test $ ruby test_sequel_threaded.rb
I, [2010-06-02T11:24:07.591001 #7130] INFO -- : (0.000126s) PRAGMA foreign_keys = 1
I, [2010-06-02T11:24:07.609124 #7130] INFO -- : (0.017792s) CREATE TABLE `things` (`id` integer PRIMARY KEY AUTOINCREMENT, `n` integer)
I, [2010-06-02T11:24:07.610116 #7130] INFO -- : (0.000098s) PRAGMA table_info('things')
I, [2010-06-02T11:24:07.611848 #7130] INFO -- : (0.000107s) SELECT sqlite_version() LIMIT 1
I, [2010-06-02T11:24:07.614920 #7130] INFO -- : (0.000074s) BEGIN
I, [2010-06-02T11:24:07.615516 #7130] INFO -- : (0.000286s) INSERT INTO `things` (`n`) VALUES (0)
I, [2010-06-02T11:24:07.620080 #7130] INFO -- : (0.000095s) SELECT * FROM `things` WHERE (`id` = 1) LIMIT 1
I, [2010-06-02T11:24:07.648590 #7130] INFO -- : (0.028211s) COMMIT
I, [2010-06-02T11:24:07.649250 #7130] INFO -- : (0.000077s) BEGIN
View simple_udp_p2p_example.rb
require 'eventmachine'
class MyP2PConnection < EM::Connection
def initialize(system)
@system = system
end
def receive_data(packet)
object = parse(packet)
port, ip = Socket.unpack_sockaddr_in(get_peername)
View ruby_1.9.1-p378_1.9.1-p429.diff
0a1,327
> Fri Jul 2 19:07:09 2010 Yuki Sonoda (Yugui) <yugui@yugui.jp>
>
> * io.c (argf_inplace_mode_set): prohibits an assignment
> of a tainted value. Patch by unak.
>
> * util.c, file.c: prevents a buffer over-run on windows.
> Patch by unak.
>
> Wed May 26 13:27:18 2010 Yuki Sonoda (Yugui) <yugui@yugui.jp>
View rmu_markdown.rb

Jul 07, 14:01:23  seacreature: I will be starting in 2 minutes, but please say hi now and mention your city :)

Jul 07, 14:01:24  locks: or we'd have the sessions up and running

Jul 07, 14:01:29  chrisdinn: JOINED

Jul 07, 14:01:56  locks: hello, I'm ricardo from Porto, Portugal

Jul 07, 14:02:03  chastell: hi, this is Piotr from Warsaw, Poland

View w 1.9.2-rc1 windows compile error
C:\Documents and Settings\Administrator>gem install eventmachine
Building native extensions. This could take a while...
ERROR: Error installing eventmachine:
ERROR: Failed to build gem native extension.
C:/ruby/192-rc1/bin/ruby.exe extconf.rb
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... yes
checking for inotify_init() in sys/inotify.h... no
checking for __NR_inotify_init in sys/syscall.h... no
View gem install nokogiri -V
$ gem install nokogiri -V
GET http://gems.rubyforge.org/latest_specs.4.8.gz
301 Moved Permanently
GET http://rubygems.org/latest_specs.4.8.gz
302 Found
GET http://production.s3.rubygems.org/latest_specs.4.8.gz
200 OK
GET http://gems.github.com/latest_specs.4.8.gz
200 OK
Installing gem nokogiri-1.4.3.1
View em_300_gets.rb
require 'eventmachine'
require 'em-http'
c = 4
urls = DATA.readlines.map {|s| s.strip }
pending = urls.size
before = Time.now
puts "urls: #{pending}"
puts "concurrency: #{c}"
View gist:510289
(04:12:04 AM) fd0: is there an example on how to write to a logfile with eventmachine?
(04:12:21 AM) fd0: or should i use default ruby (eventually blocking) io?
(04:12:44 AM) raggi: asynchronous writes to disk are kinda complicated due to platform issues
(04:12:52 AM) raggi: so at the moment, we don't really support it
(04:12:56 AM) raggi: you can use a few tricks though
(04:12:59 AM) fd0: namely?
(04:13:12 AM) raggi: e.g. EM.popen(cat - >> logfile)
View gist:512596
class Inspect
def self.profile
require 'ruby-prof'
RubyProf.start
result = yield
prof_result = RubyProf.stop
printer = RubyProf::FlatPrinter.new(prof_result)
View em_put_test.rb
require 'em-http'
N = 10
files = (0...N).map do |n|
file = "test_file_#{n}"
File.open( file, "w" ) do |f|
100_000.times { f << "0123456789" }
end
file
You can’t perform that action at this time.