Skip to content

Instantly share code, notes, and snippets.

View endeepak's full-sized avatar

Deepak Narayana Rao endeepak

View GitHub Profile
@endeepak
endeepak / ruby_subclasses.rb
Created September 27, 2010 19:15
ruby_subclasses.rb
class Class
def subclasses
result = []
ObjectSpace.each_object(Class) { |klass| result << klass if klass < self }
result
end
end
@endeepak
endeepak / .irbc
Created October 4, 2010 07:14
.irbrc
require 'rubygems'
require 'wirble'
Wirble.init
Wirble.colorize
require 'hirb'
Hirb.enable
# Log to STDOUT if in Rails
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER')
@endeepak
endeepak / example.feature
Created December 21, 2010 17:15 — forked from matschaffer/example.feature
cucumber javascript alert confirm
@javascript
Scenario: confiming when saving inactive
Given I expect to click "OK" on a confirmation box saying "Are you sure?"
When I press "Save"
Then the confirmation box should have been displayed
And I should see "TV" in the "Campaign Keywords" section
@endeepak
endeepak / ruby-1.9-tips.rb
Created February 5, 2011 19:43 — forked from igrigorik/ruby-1.9-tips.rb
Ruby 1.9 Tips, Tricks & Features
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
@endeepak
endeepak / spec_examples.rb
Created February 12, 2011 09:01 — forked from hosh/spec_examples.rb
rspec-best-practices-and-tips
#http://eggsonbread.com/2010/03/28/my-rspec-best-practices-and-tips/
describe User do
subject { user }
let(:user) { User.new }
context "when name empty" do
it { should_not be_valid }
specify { user.save.should be_false }
end
@endeepak
endeepak / sass_and_less_compared.markdown
Created February 23, 2011 18:11 — forked from chriseppstein/sass_and_less_compared.markdown
sass_and_less_compared markdown

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For less, I'm using the ruby version because this is what they suggest on the website. The javascript version may be different.

Variables

@endeepak
endeepak / autobench command line and conf.txt
Created September 10, 2011 08:18
autobench command line and conf options
>>autobench --single_host --host1=localhost --port1=3000 --uri1=/ --low_rate=10 --rate_step=5 --high_rate=30 --num_call=1 --num_conn=100
#--file=results.tsv --timeout=18000
#~/.autobench.conf
# httperf_method = POST
#
# httperf_add-header = "Content-type:application/json;\n"
@endeepak
endeepak / iphone firebug
Created April 11, 2012 10:24
iphone firebug
javascript:(function(F,i,r,e,b,u,g,L,I,T,E){if(F.getElementById(b))return;E=F[i+'NS']&&F.documentElement.namespaceURI;E=E?F[i+'NS'](E,'script'):F[i]('script');E[r]('id',b);E[r]('src',I+g+T);E[r](b,u);(F[e]('head')[0]||F[e]('body')[0]).appendChild(E);E=new%20Image;E[r]('src',I+L);})(document,'createElement','setAttribute','getElementsByTagName','FirebugLite','4','firebug-lite.js','releases/lite/latest/skin/xp/sprite.png','https://getfirebug.com/','#startOpened');
@endeepak
endeepak / README.markdown
Created April 11, 2012 21:06 — forked from beccasaurus/README.markdown
Without this, returning a 400 gives you just "Bad Request" ... with this, you can return a custom response

If you don't have the XML snippet below in your Web.config and your .NET app tries to return a 400 with custom data, you get this:

HTTP/1.1 400 Bad Request
Cache-Control: private
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 3.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET

Date: Tue, 19 Apr 2011 17:47:46 GMT

@endeepak
endeepak / selenium_android_sendkeys_bug.rb
Created April 23, 2012 21:00
AndroidDriver Bug : sendKeys() doesn't release shift key on typing uppercase characters followed by number
# Tested With
# android-server-2.21.0.apk
# selenium-dotnet-2.21.0
# selenium-webdriver (2.21.2) Gem
require "rubygems"
require "selenium-webdriver"
driver = Selenium::WebDriver.for(:remote, :url => "http://localhost:8080/wd/hub", :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.android)
driver.navigate.to "http://www.google.com"