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
#!/bin/sh | |
# Use socat to proxy git through an HTTP CONNECT firewall. | |
# Useful if you are trying to clone git:// from inside a company. | |
# Requires that the proxy allows CONNECT to port 9418. | |
# | |
# Save this file as gitproxy somewhere in your path (e.g., ~/bin) and then run | |
# chmod +x gitproxy | |
# git config --global core.gitproxy gitproxy | |
# | |
# More details at http://tinyurl.com/8xvpny |
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 'tempfile' | |
require 'java' if defined?(JRUBY_VERSION) | |
require 'test/unit' | |
require 'fileutils' | |
class TestTempfilesCleanUp < Test::Unit::TestCase | |
def setup | |
@tmpdir = "tmp_#{$$}" | |
Dir.mkdir @tmpdir rescue nil |
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/env ruby | |
require 'rubygems' | |
require 'active_support' | |
require 'json' | |
require 'commander/import' | |
program :name, "xml2json" | |
program :version, "1.1.0" | |
program :description, "XML to JSON converter" |
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
#Deploy and rollback on Heroku in staging and production | |
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag'] | |
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag'] | |
namespace :deploy do | |
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU' | |
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU' | |
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag] | |
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on] |
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" | |
http = Net::HTTP.new("example.com") | |
http.open_timeout = 2 | |
http.read_timeout = 3 # Must be greater than open_timeout | |
begin | |
http.start | |
begin | |
http.request_get("/whatever?") do |res| | |
res.read_body | |
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
=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') |
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
var sys = require('sys'), | |
exec = require('child_process').exec; | |
// fs = require('fs'); | |
// ecsv = require('ecsv') | |
function Queue () { | |
var waiting = []; | |
this.max = -1; | |
this.current = 0; | |
//run checks if we're under the max processors, and runs if there is room. |
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 'test_helper' | |
require 'minitest/autorun' | |
module Tenderlove | |
class Spec < MiniTest::Spec | |
include ActiveSupport::Testing::SetupAndTeardown | |
include ActiveRecord::TestFixtures | |
alias :method_name :__name__ if defined? :__name__ | |
self.fixture_path = File.join(Rails.root, 'test', 'fixtures') |
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
class Integer | |
def ordinal | |
cardinal = self.abs | |
digit = cardinal%10 | |
if (1..3).include?(digit) and not (11..13).include?(cardinal%100) | |
self.to_s << %w{st nd rd}[digit-1] | |
else | |
self.to_s << 'th' | |
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
class User < ActiveRecord::Base | |
devise :invitable, :database_authenticatable, :registerable, :recoverable, | |
:rememberable, :confirmable, :validatable, :encryptable | |
# ... | |
# devise confirm! method overriden | |
def confirm! | |
welcome_message | |
super |
OlderNewer