This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'uri' | |
def download(url) | |
Thread.new do | |
thread = Thread.current | |
body = thread[:body] = [] | |
url = URI.parse url | |
Net::HTTP.new(url.host, url.port).request_get(url.path) do |response| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rake task to launch multiple Resque workers in development/production with simple management included | |
require 'resque/tasks' # Require Resque tasks | |
namespace :workers do | |
# = $ rake workers:start | |
# | |
# Launch multiple Resque workers with the Rails environment loaded, | |
# so they have access to your models, etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SIGN UP | |
curl -H "Content-Type:application/json" -H "Accept:application/json" \ | |
-d "{\"user\":{\"password_confirmation\":\"12345678\", \"password\":\"12345678\", \"email\":\"test5@test.com\"}}" \ | |
http://your_server.com/users | |
SIGN IN | |
curl -H "Content-Type:application/json" -H "Accept:application/json" \ | |
-d "{\"user\":{\"remember_me\":\"0\", \"password\":\"12345678\", \"email\":\"test5@test.com\"}}" \ | |
http://your_server.com/users/sign_in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support/basic_object' | |
ActiveRecord::Base.class_eval do | |
class WithoutCallbacks < ActiveSupport::BasicObject | |
def initialize(target, types) | |
@target = target | |
@types = types | |
end | |
def respond_to?(method, include_private = false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
module Player | |
describe MovieList, "with optional description" do | |
it "is pending example, so that you can write ones quickly" | |
it "is already working example that we want to suspend from failing temporarily" do | |
pending("working on another feature that temporarily breaks this one") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby -w | |
# for passenger 3.0 | |
# | |
# cron | |
# */15 * * * * root /root/bin/kill-frozen-passenger-instances | |
require 'rubygems' | |
require 'net/http' | |
require 'uri' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) | |
require 'rvm/capistrano' | |
set :application, "hirefireapp" | |
set :repository, "git@codeplane.com:meskyanichi/myapp.git" | |
set :branch, "develop" | |
set :rvm_ruby_string, "1.9.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
Capistrano::Configuration.instance(:must_exist).load do | |
namespace :rails do | |
desc "Open the rails console on one of the remote servers" | |
task :console, :roles => :app do | |
hostname = find_servers_for_task(current_task).first | |
exec "ssh -l #{user} #{hostname} -t 'source ~/.profile && #{current_path}/script/rails c #{rails_env}'" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mogli' | |
module FacebookIntegrationHelpers | |
shared_context "with unconnected facebook user" do | |
let(:fb_user) { create_test_user(installed: false) } | |
after { fb_user.destroy } | |
end | |
def app_client | |
Mogli::AppClient.new(AppConfig.facebook.access_token, AppConfig.facebook.app_id) |
OlderNewer