This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
require 'rubygems' | |
require 'mechanize' | |
agent = WWW::Mechanize.new() | |
page = agent.get(:url => "https://www.gmail.com") | |
#use OpenSSL between mechanize requests. | |
public_key = OpenSSL::PKey::RSA.new(File.read(File.dirname(__FILE__) + "/mykeypublic.pem")) | |
private_key = OpenSSL::PKey::RSA.new(File.read(File.dirname(__FILE__) + "/mykey.pem")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#vlad code, why on earth would you do this...??? | |
def export receiver, *methods | |
methods.each do |method| | |
eval "def #{method} *args, █ #{receiver}.#{method}(*args, &block);end" | |
end | |
end | |
export "Thread.current[:task]", :get, :put, :rsync, :run, :sudo, :target_host |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CommentsController < ApplicationController | |
layout false | |
def show | |
headers['Cache-Control'] = 'must-revalidate' | |
item = Item.find(params[:item_id]) | |
if stale?(:etag => item.comments.count, :public => true) | |
@comments = item.comments.all(:include => :user) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExamplesController < ApplicationController | |
def show | |
data = {:name => "Apple Pie", :price => "3.75"} | |
render :json => data, :callback => params[:callback] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FoosController < ApplicationController | |
def http | |
http = EM::HttpRequest.new(params[:url]).get | |
http.callback { | |
render :text => http.response | |
} | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AccountsController < ApplicationController | |
before_filter :require_user | |
def destroy | |
@account = current_user.accounts.find(params[:id]) | |
@account.destroy | |
respond_to do |format| | |
format.html { redirect_to(accounts_url) } | |
format.xml { head :ok } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ForwardingSupport | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
async_cb = env['async.callback'] | |
env['async.callback'] = Proc.new do |status, headers, body| | |
async_cb.call(post_process(env, status, headers, body)) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Craigslist google maps mashup</title> | |
<script type="text/javascript" src="javascripts/jquery-1.4.4.min.js"></script> | |
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
var latlng = new google.maps.LatLng(-34.397, 150.644); | |
var reverse_geocoder = new google.maps.Geocoder(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'eventmachine' | |
require 'em-http-request' | |
require 'fiber' | |
EventMachine.run do | |
http = EM::HttpRequest.new('http://www.google.com').get | |
begin | |
puts "Before" | |
http.callback { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Eventually some non deterministic difference of signals received | |
missed signal @cont_count: 428 @usr2_count: 439 |
OlderNewer