Skip to content

Instantly share code, notes, and snippets.

View psahni's full-sized avatar

Prashant Sahni psahni

View GitHub Profile
# Example of how you can to use Capybara with plain Rails' integration tests and FactoryGirl (or plain MyModel.create…)
require 'test_helper'
require 'capybara'
require 'capybara/dsl'
require 'database_cleaner'
Capybara.app = Pardy::Application
Capybara.default_driver = :rack_test
DatabaseCleaner.strategy = :truncation
@psahni
psahni / omniauth.rb
Created April 22, 2011 07:54 — forked from dira/omniauth.rb
OmniAuth strategy for a custom provider
module OmniAuth
module Strategies
# tell OmniAuth to load our strategy
autoload :Pixelation, 'lib/pixelation_authorization'
end
end
Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, "app_name", "secret"
provider :facebook, "app_name", "secret", :scope => ''
@psahni
psahni / .gitignore
Created May 15, 2011 17:40 — forked from karmi/.gitignore
Import your Gmail messages into ElasticSearch and search them with a simple web application.
.DS_Store
*.log
Gemfile.lock
class Article
attr_reader :filename
def initialize(filename)
@filename = filename
end
def <=> other
self.filename <=> other.filename
end
@psahni
psahni / mysql_connection_cleaner.rb
Created June 15, 2011 13:02 — forked from jagira/mysql_connection_cleaner.rb
MySQL Connection Cleaner
require 'mysql2'
client = Mysql::Client.new(:host => "localhost", :username => "root")
# Fetch running threads
processes = client.query("SHOW FULL PROCESSLIST")
processes.each do |process|
# Kill thread
@psahni
psahni / application.html.erb
Created August 3, 2011 06:48 — forked from chrisbloom7/application.html.erb
Static named redirect routes in Rails 3
<ul class="social-links">
<li class="facebook"><%= link_to "Like us on Facebook", facebook_path %></li>
<li class="twitter"><%= link_to "Follow us on Twitter", twitter_path %></li>
</ul>
/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function ($) {
$.event.special.textchange = {
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
Animals.each do |letter, results|
10.times do
doc = Nokogiri::HTML(open("http://www.ocar.org/page.php?tut=realtor-affiliate-search-results&tid=802&pid=8&first_or_last_name=#{letter}&city=&office=&btc=&op=find_a_realtor&ftut=find-a-realtor&start=#{results_per_page}"))
realtors = {}
('a'..'z').each do |n|
realtors[n] = Realtor.create
end
doc.css('div.search_results_item').each do |number|
phone_number = /\(\d{3}\)\s\d{3}-\d{4}/.match("#{number.content}")
('a'..'z').each do |n|
require 'spec_helper'
feature "Editing tickets" do
let!(:project) { Factory(:project) }
let!(:ticket) { Factory(:ticket, :project => project) }
before do
visit '/'
click_link project.name
click_link ticket.title