Skip to content

Instantly share code, notes, and snippets.

Avatar

Chamnap Chhorn chamnap

View GitHub Profile
@aermolaev
aermolaev / kill-frozen-passenger-instances
Created Dec 4, 2010
Inspecting Phusion Passenger's status and killing frozen apps
View kill-frozen-passenger-instances
#!/usr/bin/ruby -w
# for passenger 3.0
#
# cron
# */15 * * * * root /root/bin/kill-frozen-passenger-instances
require 'rubygems'
require 'net/http'
require 'uri'
@yuki24
yuki24 / gist:1187574
Created Sep 1, 2011 — forked from travis/gist:1084767
testing facebook connect with capybara and rspec
View gist:1187574
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)
@cstrahan
cstrahan / pair.md
Created Apr 11, 2012 — forked from wm/pair.md
TMUX Pairing
View pair.md

SSH setup for remote pairing

If Animal and Fozzie wanted to pair on Animals machine and they both have access to shared.muppets.com then they could use the following setup

  • Animal will have the following in ~/.ssh/config
Host tunnel_from_muppets
  Hostname space.muppets.com
  RemoteForward 1235 localhost:22
@jshaw
jshaw / FacebookPageTabResizeiFrame.html
Created Jul 26, 2012
Resize the Facebook iFrame Tab Page with resizing content and different page heights on page loads.
View FacebookPageTabResizeiFrame.html
<!DOCTYPE html>
<html lang="en" style="overflow: hidden">
<body style="overflow:hidden">
<head>
<!-- You need to include jquery & FBSDK-->
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
@ryanb
ryanb / spec_helper.rb
Created Sep 12, 2011
Use RSpec tags to add behavior around specs.
View spec_helper.rb
# Add this to your spec_helper.rb
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.around(:each, :vcr) do |example|
name = example.metadata[:full_description].downcase.gsub(/\W+/, "_").split("_", 2).join("/")
VCR.use_cassette(name, :record => :new_episodes) do
example.call
end
end
end
@ryanb
ryanb / spec_helper.rb
Created Sep 12, 2011
Focus on specific specs in RSpec
View spec_helper.rb
# add this to your spec helper
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
end
# and then use the :focus tag in your specs
it "does something awesome", :focus do
@Mic92
Mic92 / index.html
Last active Dec 15, 2015
Zeroclipboard css styling for twitter bootstrap
View index.html
<button id="copy" class="btn">Copy</button>
View mongoid_observers.rb
module MyObservers
module Document
module ClassMethods
def observers= (*observers)
declared_observers.replace(observers.flatten)
end
def declared_observers
@declared_observers ||= []
end
@ryanb
ryanb / tasks_controller_refactoring.rb
Created Nov 9, 2012
Variation of RubyTapas episode "021 Domain Model Events" without using callbacks
View tasks_controller_refactoring.rb
class TasksController < ApplicationController
def update
tracker = TaskTracker.new(@task)
if @task.update_attributes(params[:task])
TaskPusher.new(tracker, socket_id).push_changes
TaskMailSender.new(tracker, current_user).deliver_email
# success response
else
# failure respond
end
@mrrooijen
mrrooijen / deploy.rb
Created Jun 26, 2011
Capistrano with Foreman Capfile
View deploy.rb
# 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"