Adapted to Markdown format from rom Aman Gupta's gist at: http://gist.github.com/79224
Using:
require 'rubygems'
require 'eventmachine'
| 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 |
Adapted to Markdown format from rom Aman Gupta's gist at: http://gist.github.com/79224
Using:
require 'rubygems'
require 'eventmachine'
| ## | |
| # 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) |