Skip to content

Instantly share code, notes, and snippets.

View franckverrot's full-sized avatar
📚
🥋

Franck Verrot franckverrot

📚
🥋
View GitHub Profile
require "rubygems"
require "hpricot"
require "open-uri"
class TvRage
def self.full_schedule(country='US')
doc = self.fetch_xml('http://services.tvrage.com/feeds/fullschedule.php', 'country' => country, '24_format' => '1')
p "full_schedule - #{doc.class}"
doc.search('//show').each {|show| process_show(show) }
end
import java.util.ArrayList
import java.util.List
class Voulez
def initialize(more:List)
@words = ArrayList.new [:want]
more.each {|s| @words.add s}
end
def self.vous(verb:String)
self.new [:you, verb]

Instrument Anything in Rails 3

With Rails 3.0 released a few weeks ago I've migrated a few apps and I'm constantly finding useful new improvements. One such improvement is the ability to log anything in the same way that Rails internally logs ActiveRecord and ActionView. By default Rails 3 logs look slightly spiffier than those produced by Rails 2.3: (notice the second line has been cleaned up)

Started GET "/" for 127.0.0.1 at Mon Sep 06 01:07:11 -0400 2010
  Processing by HomeController#index as HTML
  User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1

Rendered layouts/_nav.html.erb (363.4ms)

@franckverrot
franckverrot / RUNME-demo_of_async_fibers.log
Created April 27, 2011 20:40 — forked from mrflip/RUNME-demo_of_async_fibers.log
A fully-commented demo showing execution flow in the fibers+eventmachine => linear asynchronous code pattern
>> load './RUNME-demo_of_async_fibers.rb'
/Users/flip/ics/backend/son_of_a_batch/RUNME-demo_of_async_fibers.rb:4: warning: already initialized constant FIBER_IDXS
814e5e90 0 f_0 beg main top level
814e5e90 1 f_0 beg em setup this block sets up the eventmachine execution, but no execution-order shenanigans yet
814e5e90 2 f_0 beg fiber stp the end-the-reactor block won't be called for 1.5s, so we get here immediately.
814e5e90 3 f_0 end fiber stp nothing from inside the Fiber.new{} block has run yet.
814e5e90 4 f_0 end fiber stp kick off the fiber...
80d829a0 5 f_1 beg fiber when my_fiber.resume is called, this runs. Now in a new fiber
80d829a0 6 f_1 beg get_result get_result is called from within fiber_1
80d829a0 7 f_1 setup callback set up some code to run 1.5s from now
Gem::Specification.new do |s|
# totally generic
version_file = Dir['lib/*/{*/,}version.rb'].first
s.name = version_file.split('/')[1..-2].join('-')
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.authors = `git shortlog -sn`.scan(/[^\d\s].*/)
s.email = `git shortlog -sne`.scan(/[^<]+@[^>]+/)
s.require_paths = ["lib"]
@franckverrot
franckverrot / database.yml.erb
Created July 1, 2011 21:35 — forked from thbar/database.yml.erb
Heroku database.yml
<%
require 'cgi'
require 'uri'
begin
uri = URI.parse(ENV["DATABASE_URL"])
rescue URI::InvalidURIError
raise "Invalid DATABASE_URL"
end
@franckverrot
franckverrot / database.yml.erb
Created July 1, 2011 21:35 — forked from thbar/database.yml.erb
Heroku database.yml
<%
require 'cgi'
require 'uri'
begin
uri = URI.parse(ENV["DATABASE_URL"])
rescue URI::InvalidURIError
raise "Invalid DATABASE_URL"
end
@franckverrot
franckverrot / Questions
Created August 13, 2011 12:53
Frozen Rails Give-away
Day job: Lead Dev at @Leadformance
Your Rails contributions (if any): 26 commits, [#84](http://contributors.rubyonrails.org/contributors/franck-verrot/commits)
What's your Ruby/Rail experience?: ± 4-5 years
How do you use GitHub?: Professionnal and Personal projects, both paid accounts. Lots of contributions too.
Originally:
https://gist.github.com/7565976a89d5da1511ce
Hi Donald (and Martin),
Thanks for pinging me; it's nice to know Typesafe is keeping tabs on this, and I
appreciate the tone. This is a Yegge-long response, but given that you and
Martin are the two people best-situated to do anything about this, I'd rather
err on the side of giving you too much to think about. I realize I'm being very
critical of something in which you've invested a great deal (both financially
@franckverrot
franckverrot / dtrace_rubymotion_repl
Created May 18, 2012 15:41 — forked from fpotter/dtrace_rubymotion_repl
DTrace script to observe UNIX socket traffic to/from a RubyMotion app
#!/usr/bin/env dtrace -s
/*
* DTrace script to observe UNIX socket reads/writes for RubyMotion apps running
* in the iOS Simulator.
*
* Usage: sudo dtrace_rubymotion_repl <pid of running RubyMotion iOS app>
*
*/
syscall::sendto:entry