Skip to content

Instantly share code, notes, and snippets.

View abhishek77in's full-sized avatar

Abhishek Srivastava abhishek77in

View GitHub Profile
@reqshark
reqshark / simple-mongodb-connection.rb
Created July 3, 2012 12:36
connecting to mongo from ruby
#!/usr/bin/env ruby
# ruby_simple_example.rb
#
# A sample ruby script covering connection to a MongoDB database given a
# fully-qualified URI. There are a few additional means, but we prefer the URI
# connection model because developers can use the same code to handle various
# database configuration possibilities (single, master/slave, replica sets).
#
# Author:: Mongolab
@brentertz
brentertz / rvm2rbenv.txt
Created November 21, 2011 23:00
Switch from RVM to RBENV
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@metaskills
metaskills / wait_until.rb
Last active May 2, 2024 01:51
Never sleep() using Capybara!
# WAIT! Do consider that `wait` may not be needed. This article describes
# that reasoning. Please read it and make informed decisions.
# https://www.varvet.com/blog/why-wait_until-was-removed-from-capybara/
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations?
describe 'Modal' do
should 'display login errors' do
visit root_path
@viola
viola / gist:1070410
Created July 7, 2011 20:00
Example of fetching Hash (key,value) to the simple_form collection.
-- model
some sort of constant hash:
HASH_NAME = {
0 => "Choose:",
1 => "On-Campus Recruiting - CSO",·
2 => "CSO Staff Referral",
3 => "Faculty Contact",·
4 => "Career Day",·
5 => "CSO Summer Job Listing",·
6 => "Alumni Contact",·
@mhenrixon
mhenrixon / _form.html.haml
Created May 18, 2011 11:02
A complete sample of how to perform nested polymorphic uploads in rails using carrierwave
=semantic_form_for [:admin, @dog], validate: true, html: {multipart: true} do |f|
=f.inputs do
=f.input :name
=f.input :kennel_name
=f.input :birthdate
=f.input :gender, as: :radio, collection: {'Tik' => 'F', 'Hane' => 'M'}
=f.input :father_id, as: :select, collection: @dogs
=f.input :mother_id, as: :select, collection: @bitches
=f.semantic_fields_for :pictures do |pic|
@samsworldofno
samsworldofno / gist:535038
Created August 18, 2010 15:04
cap db:pull
namespace :db do
desc "Download the a full dump of the production database into the development database"
task :pull do
config = YAML::load(File.open(File.join('config', 'database.yml')))
dump_database_remotely(config['production'], remote_file)
compress_backup_remotely(remote_file)
download_backup(remote_file(:compressed), local_file(:compressed))
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
$KCODE = 'UTF8'
require 'rubygems'
require 'google-search'
query = ARGV[0] || "paris hilton"
HTML = File.dirname(__FILE__) + '/face.html'
open(HTML, 'w') do |file|