Skip to content

Instantly share code, notes, and snippets.

View anildigital's full-sized avatar
:octocat:

Anil Wadghule anildigital

:octocat:
View GitHub Profile
@jferris
jferris / new.rb
Created November 5, 2010 18:23
New FactoryGirl definition syntax
FactoryGirl.define do
sequence :email do |n|
"user#{n}@example.com"
end
factory :user do
email
password "test"
aliased_as :author
end
send_file '/path/to/404.html', :type => 'text/html; charset=utf-8', :status => 404
render :file => "public/404.html", :status => 404, :layout => false
@nahi
nahi / RubyProcess.java.diff
Created December 27, 2010 05:10
httpclient is the fastest. benchmark.rb of JRuby can only measure elapsed time (at present)... Please see 'real' part.
diff --git a/src/org/jruby/RubyProcess.java b/src/org/jruby/RubyProcess.java
index 4d16468..ac6a105 100644
--- a/src/org/jruby/RubyProcess.java
+++ b/src/org/jruby/RubyProcess.java
@@ -29,6 +29,10 @@
***** END LICENSE BLOCK *****/
package org.jruby;
+import java.lang.management.ManagementFactory;
+import java.lang.management.ThreadMXBean;
@anildigital
anildigital / nuke.rb
Created February 6, 2011 17:06 — forked from radar/nuke.rb
require 'rubygems'
require 'mechanize'
require 'httparty'
# Ugly code, for an ugly hack.
# Hey, if Lighthouse didn't suck then none of this would happen.
# It's been lotsa fun coding it though, so I suppose I should be thankful for the "opportunity"
@sstephenson
sstephenson / config.ru
Created April 8, 2011 04:46
Rackup file for Rails 2.3 apps
require File.dirname(__FILE__) + '/config/environment'
run ActionController::Dispatcher.new
@sreeix
sreeix / app.js
Created April 20, 2011 18:58
Node JS. chat client.
var http = require('http'),
express = require("express"),
sys = require("sys"),
io = require('socket.io');
var app = express.createServer();
app.set('view engine', 'jade');
app.get("/", function(req, res){
@anildigital
anildigital / config.ru.rb
Created April 21, 2011 06:21 — forked from brianmario/config.ru.rb
minimal rails3 app
require 'action_controller'
Router = ActionDispatch::Routing::RouteSet.new
Router.draw do
root :to => 'site#index'
end
class SiteController < ActionController::Metal
def index
self.response_body = "waddup son"
@kaiwren
kaiwren / gist:957742
Created May 5, 2011 19:41
Quote from the Buddha

From http://everything2.com/title/nontheist

The Buddha is the first historically known nontheist. Most Buddhists are nontheist.

The Buddha was often asked whether God existed. Usually, he replied with a complete silence. Once, however, he told the story of the man shot by a poisoned arrow.

When the doctor came and wanted to pull the arrow out of the wound, the man grabbed the doctor's hand and asked:

"Before you start treating me, Doctor, tell me, who was it that shot me? Was he of warrior class or some other class? Was he tall or was he short? Was he young or was he old? Was he dark skinned or light skinned?"

@tarcieri
tarcieri / pmap_fetch_benchmark.rb
Created May 11, 2011 06:28
Concurrent HTTP fetching benchmark with Enumerable#pmap
require 'celluloid'
require 'open-uri'
require 'cgi'
require 'benchmark'
module Enumerable
def pmap(&block)
futures = map { |elem| Celluloid::Future(elem, &block) }
futures.map { |future| future.value }
end
require 'logger'
class String
LOGGER = Logger.new($stderr)
def -@; LOGGER.info self; end
end
# Extracted earlier, hardcoded for speed
ENTITIES = %w(I-ORG O I-MISC I-PER I-LOC B-LOC B-MISC MO B-ORG)