Skip to content

Instantly share code, notes, and snippets.

View igrigorik's full-sized avatar
:octocat:

Ilya Grigorik igrigorik

:octocat:
View GitHub Profile
class Canine
VERSION = '1.3'
def initialize(&block)
@commands = Hash.new
@default = @latest = :commands
@empty = nil
@auto = {
:commands => hash_command("commands","Show a list of commands",Proc.new {
@commands.each { |cmd| c = cmd[1]
name = c[:name].to_s
##
# sync api: return values and exceptions
begin
images = []
results = RestClient.get('http://google.com/search?q=ruby')
Hpricot(results).find('a').each{ |link|
page = RestClient.get(link)
begin
# async_sinatra_example.ru
require 'sinatra'
# Normally Sinatra::Base expects that the completion of a request is
# determined by the block exiting, and returning a value for the body.
#
# In an async environment, we want to tell the webserver that we're not going
# to provide a response now, but some time in the future.
#
# The a* methods provide a method for doing this, by informing the server of

EventMachine Notes

Adapted to Markdown format from rom Aman Gupta's gist at: http://gist.github.com/79224

Using:

require 'rubygems'
require 'eventmachine'

EM::run Takes over the Process

@igrigorik
igrigorik / gist:60421
Created February 8, 2009 16:42 — forked from tmm1/gist:58437
##
# sync api: return values and exceptions
begin
images = []
results = RestClient.get('http://google.com/search?q=ruby')
Hpricot(results).find('a').each{ |link|
page = RestClient.get(link)
begin
#!/usr/bin/env ruby
require 'rubygems'
require 'mini_magick'
BLANK = 'blank.png' # 1x1px white png
$text = 'hello, world' # text to write
img = MiniMagick::Image.from_file(BLANK)