Skip to content

Instantly share code, notes, and snippets.

View shanlalit's full-sized avatar

Lalit Shandilya shanlalit

View GitHub Profile
require "net/http"
http = Net::HTTP.new("example.com")
http.open_timeout = 2
http.read_timeout = 3 # Must be greater than open_timeout
begin
http.start
begin
http.request_get("/whatever?") do |res|
res.read_body
end
// An Unobtrusive Javascript (UJS) driver based on explicit behavior definitions. Just
// put a "data-behaviors" attribute on your view elements, and then assign callbacks
// for those named behaviors via Behaviors.add.
var Behaviors = {
add: function(trigger, behavior, handler) {
document.observe(trigger, function(event) {
var element = event.findElement("*[data-behaviors~=" + behavior + "]");
if (element) handler(element, event);
});
@UnderpantsGnome
UnderpantsGnome / gist:289486
Created January 29, 2010 05:46
rvm global gems per ruby
########################################
### Start with a "clean" environment ###
########################################
mmoen@shiny:~/tmp$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.5
- RUBY VERSION: 1.8.6 (2009-08-04 patchlevel 383) [i686-darwin10.2.0]
- INSTALLATION DIRECTORY: /Users/mmoen/.rvm/gems/ruby/1.8.6
- RUBY EXECUTABLE: /Users/mmoen/.rvm/ruby-1.8.6-p383/bin/ruby
#!/bin/sh
#
# PROVIDE: cccms
# REQUIRE: nginx cleanvar
. /etc/rc.subr
name=cccms
rcvar=`set_rcvar`
@nathanhammond
nathanhammond / jquery.ancestry.js
Created August 13, 2008 15:18
Functionality to add a filter for descendants and ancestors of a jQuery set.
/*
Ancestry - jquery.ancestry.js
As discussed in the jQuery Development Google Group.
Released under the MIT license.
Involved: Michael Geary, Diego Perini, John-David Dalton, John Resig, and Nathan Hammond
Compiled: Nathan Hammond
*/
jQuery.comparePosition = function ( element, context) {