Skip to content

Instantly share code, notes, and snippets.

- unless Rails.env.development?
/ Require jQuery
= javascript_include_tag 'http://yandex.st/jquery/1.7.1/jquery.min.js'
/ Require Google's jQuery if Yandex is down
:javascript
window.jQuery || document.write('<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">\x3C/script>')
/ Require local jQuery if Google is down / is development env
:javascript
window.jQuery || document.write('<script src="#{asset_path('jquery.js')}">\x3C/script>')
@tonyc
tonyc / gist:1384523
Last active June 3, 2024 15:34
Using strace and lsof

Using strace and lsof to debug blocked processes

You can use strace on a specific pid to figure out what a specific process is doing, e.g.:

strace -fp <pid>

You might see something like:

select(9, [3 5 8], [], [], {0, 999999}) = 0 (Timeout)

@qichunren
qichunren / client.rb
Created November 18, 2011 02:29
ruby udp
require 'socket'
socket = UDPSocket.new
socket.send("I am ok.", 0, 'localhost', 1234)
text, sender = socket.recvfrom(16)
socket.close
@Bregor
Bregor / spec__requests__history_items_spec.rb
Created June 29, 2011 09:09
Capybara request helpers for devise
require 'spec_helper'
describe "HistoryItems" do
before(:each) {login_as :user}
describe "GET /history_items" do
it "works!" do
visit history_items_path
response.should be_success
end
end
@bopm
bopm / book.rb
Created April 29, 2011 21:08
Batch processing in rails
class Book < ActiveRecord::Base
has_many :pages
belongs_to :p2fline
belongs_to :print_profile
belongs_to :publish_profile
acts_as_audited :except => [:name, :file_name]
include AASM
aasm_column :state
# http://unicorn.bogomips.org/SIGNALS.html
rails_env = ENV['RAILS_ENV'] || 'production'
rails_root = ENV['RAILS_ROOT'] || "/data/github/current"
God.watch do |w|
w.name = "unicorn"
w.interval = 30.seconds # default
# unicorn needs to be run from the rails root
@vvalgis
vvalgis / Capistrano tasks for starting unicorn.rb
Created May 7, 2010 08:13
Capistrano tasks for starting unicorn
set :rails_env, :production
set :unicorn_binary, "/usr/bin/unicorn"
set :unicorn_config, "#{current_path}/config/unicorn.rb"
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
namespace :deploy do
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && #{try_sudo} #{unicorn_binary} -c #{unicorn_config} -E #{rails_env} -D"
end
task :stop, :roles => :app, :except => { :no_release => true } do