Skip to content

Instantly share code, notes, and snippets.

View shamil614's full-sized avatar

scott hamilton shamil614

View GitHub Profile
@gaffneyc
gaffneyc / rpc_consumer.rb
Created June 3, 2009 15:07
Basic RPC using RabbitMQ and Bunny
require 'rubygems'
gem 'gaffneyc-bunny'
require 'bunny'
# Example of simple RPC using server named queues
Bunny.open do |amqp|
# Exchange definition
amqp.exchange('reply', :type => :direct)
amqp.exchange('out', :type => :direct)
anonymous
anonymous / factories.rb
Created February 24, 2010 05:05
Factory.define :item do |f|
include ActionDispatch::TestProcess
f.name "Macbook Pro 15"
f.price_in_dollars 1500
f.photo fixture_file_upload('/files/avatar.jpg', 'image/jpg')
end
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@waseem
waseem / easy_tunnel.rake
Created July 11, 2010 05:12
A Rake interface to creating a tunnel using ssh.
##
# A Rake interface to creating a tunnel using ssh.
# This file originally comes with the facebooker gem for Ruby on Rails: http://github.com/mmangino/facebooker
#
# How to use:
# 1. Simply put it at a proper place. e.g. lib/tasks/ in your Rails application
# 2. Create a config file 'easy_tunnel.yml' like following:
#
# development:
# public_host_username: host_user_name
@remvee
remvee / ignore_unknown_http_method.rb
Created September 28, 2010 07:39
silence ActionController::UnknownHttpMethod exceptions
# Avoid annoying ActionController::UnknownHttpMethod exceptions like:
#
# ActionController::UnknownHttpMethod) "CONNECT, accepted HTTP methods are get, head, put, post, delete, and options"
#
# Install this file in app/metal and these requests will receive a 405
# "Method Not Allowed" status and will be logged under `info'.
class IgnoreUnknownHttpMethod
def self.call(env)
[
if ActionController::Request::HTTP_METHODS.include?(env["REQUEST_METHOD"].downcase)
@rodreegez
rodreegez / fog.rb
Created May 14, 2011 18:15
Retrive S3 files with Fog
require 'fog'
con = Fog::Storage.new(
provider: 'AWS',
aws_secret_access_key: 'ABC123',
region: 'eu-west-1',
aws_access_key_id: 'ABC123'
)
=> Fog::AWS::Storage object
@tahl
tahl / installer.sh
Created June 15, 2011 06:56
Android SDK + NDK + Eclipse and ADB Installer
#!/bin/bash
#
#This script is designed to install the Android SDK, NDK, and Eclipse in Linux Mint 11 and make it easier for people that want to develop for Android using Linux.
#Script written by @ArchDukeDoug with special thanks to @BoneyNicole, @tabbwabb, and @animedbz16 for putting up with me and proofreading and/or testing the script.
#I can be reached at [email protected], twitter, or linuxrandomly.blogspot.com
#Script version: 1.0.5
#Changelog: 1.0.5 - Fixed the Android SDK search parameters to fit the new naming scheme on http://developer.android.com/sdk
i=$(cat /proc/$PPID/cmdline)
if [[ $UID != 0 ]]; then
echo "Please type sudo $0 $*to use this."
@paveltyk
paveltyk / attachment_fu.rake
Created June 23, 2011 22:56
Ever needed to refresh (regenerate, update) attachment_fu attachments on amazon-s3? Here you go!
def logger
@logger_for_attachment_fu_rake_task ||= Logger.new STDOUT
end
def raise_with_logger(msg)
logger.error msg
raise msg
end
def obtain_class
@alexagui
alexagui / ruby_debug_pow.markdown
Created July 22, 2011 03:26
How to Ruby Debug with Pow

How to Ruby Debug with Pow

Below are steps I followed to get ruby debugger ruby-debug running with Pow. Based on info from this thread basecamp/pow#43 and this blog post http://flochip.com/2011/04/13/running-pow-with-rdebug/

1) Update your Gemfile

Assuming you're writing your app in Ruby 1.9 and using Bundler, just add the dependency to your development gems:

@matpowel
matpowel / tableless.rb
Created July 23, 2011 10:04
An ActiveRecord emulating Tableless model which works with Rails 3.1
class Tableless < ActiveRecord::Base
def self.column(name, sql_type = nil, default = nil, null = true)
columns << ActiveRecord::ConnectionAdapters::Column.new( name.to_s, default, sql_type.to_s, null )
end
def self.columns()
@columns ||= [];
end