This file contains hidden or 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
| on appIsRunning(appName) | |
| tell application "System Events" to (name of processes) contains appName | |
| end appIsRunning | |
| on execInItermTab(_terminal, _session, _command) | |
| tell application "iTerm" | |
| activate | |
| set current terminal to _terminal | |
| tell _session | |
| select _session |
This file contains hidden or 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
| # app/models/user.rb | |
| class User < ActiveRecord::Base | |
| validates :zipcode, presence: true, zipcode: true | |
| end |
This file contains hidden or 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
| # Add these two gems | |
| gem 'ice_cube', '0.9.3' | |
| gem 'squeel', '1.0.16' |
This file contains hidden or 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
| # https://gist.github.com/1623632 | |
| # bundler bootstrap | |
| require 'bundler/capistrano' | |
| # main details | |
| set :application, "123" | |
| role :web, "#{application}.cloud.voupe.net" # #{application}.cloud.voupe.net | |
| role :app, "#{application}.cloud.voupe.net" | |
| role :db, "#{application}.cloud.voupe.net", :primary => true |
This file contains hidden or 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.configure do |config| | |
| config.around do |example| | |
| # For examples using capybara-webkit for example. | |
| # Remove this if you don't use it or anything similar | |
| if example.metadata[:js] | |
| example.run | |
| ActiveRecord::Base.connection.tables.each do |table| | |
| ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table};") | |
| end |
This file contains hidden or 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 | |
| set_path="cd /home/rails/my_app/current" | |
| case "$1" in | |
| start) | |
| echo -n "Starting delayed_job: " | |
| su - rails -c "$set_path; RAILS_ENV=production script/delayed_job start" >> log/delayed_job.log 2>&1 | |
| echo "done." | |
| ;; | |
| stop) |
This file contains hidden or 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 'net/telnet' | |
| cache_dump_limit = 100 | |
| localhost = Net::Telnet::new("Host" => "localhost", "Port" => 11211, "Timeout" => 3) | |
| slab_ids = [] | |
| localhost.cmd("String" => "stats items", "Match" => /^END/) do |c| | |
| matches = c.scan(/STAT items:(\d+):/) | |
| slab_ids = matches.flatten.uniq | |
| end |
This file contains hidden or 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
| ### Show stack trace for 500 errors | |
| ### (adapted from https://gist.github.com/1079020) | |
| # Given an application, yield to a block to handle exceptions | |
| class ExceptionRaiserApp | |
| def initialize(app) | |
| @app = app | |
| end | |
| def call(env) |
This file contains hidden or 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 'right_aws' | |
| s3_credentials = { | |
| :source_key => "...", | |
| :source_secret => "...", | |
| :source_bucket => "...", | |
| :destination_key => "...", | |
| :destination_secret => "...", | |
| :destination_bucket => "..." | |
| } |
This file contains hidden or 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
| P = programmer; NP = non-programmer | |
| NP: How long will it take? | |
| P: It'll take as long as it takes. | |
| NP: I don't understand. What does that mean? | |
| P: When you tell me that the product is finished, it's done. | |
| NP: You mean you can't estimate how long it'll take? | |
| P: I can't estimate when you'll decide that it is done, therefore an | |
| accurate prediction is impossible. From experience I know that a | |
| project like this can take from three to nine months. A lot |