- Start a Sinatra server on port 4000
- GET / to that server triggers a
git pull
and mod_rails restart - Hit port 4000 locally after pushing
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 | |
# Open a new tab in Terminal | |
# usage: tab [cmd] | |
# If cmd is specified, it will be run in new tab while old tab is reactivated. | |
# If no cmd, new tab is activated | |
require "rubygems" | |
require "appscript" | |
include Appscript | |
window = app("Terminal").windows.first |
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
# Get your commit hash from git log | |
git revert b899e585972342c4c33426535c30722f1f1ca14c | |
# Commit message if required (defaults to Created commit abe8722: Revert "YOur message") | |
git pull | |
git push | |
# Win. |
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
# Monitor HTTP requests being made from your machine with a one-liner.. | |
# Replace "en1" below with your network interface's name (usually en0 or en1) | |
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*" | |
# OR.. to be able to use as "httpdump" from anywhere, drop this into ~/.bash_profile: | |
# (again replace "en1" with correct network interface name) | |
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"" | |
# All the above tested only on OS X. |
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
postcodes = FasterCSV.read(data_source_for("postcodes.csv")) | |
postcodes.each do |(post_code, name, state_name, _, _, _, _, _, _, category)| | |
if category.squish == "Delivery Area" | |
post_code = sprintf("%04d", post_code.to_i) | |
state = State.find_or_create_by_name(state_name) | |
Locality.create(:post_code => post_code, :name => name, :state => state) | |
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
module Locality::Search | |
def self.included(base) | |
base.class_eval do | |
class << self | |
def search(criteria) | |
logger.debug("search") | |
results = find_all_by_name(criteria) | |
if results.empty? |
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
# Run the given block +num+ times and then print out the mean, median, min, | |
# max, and stddev of the run. For example: | |
# | |
# irb> stats(10) { sleep(rand / 100) } | |
# mean: 5.99ms | |
# median: 6.76ms | |
# min: 1.49ms | |
# max: 9.28ms | |
# stddev: 2.54ms | |
def stats(num) |
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
# Run the given block +num+ times and then print out the mean, median, min, | |
# max, and stddev of the run. For example: | |
# | |
# irb> stats(10) { sleep(rand / 100) } | |
# mean: 5.99ms | |
# median: 6.76ms | |
# min: 1.49ms | |
# max: 9.28ms | |
# stddev: 2.54ms | |
def stats(num) |
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
A few things left to do: | |
* Ability to add default options for each PDF, rather than having to pass it to each generate_* method call | |
* Doesn't check if the pdf already exists. By default, which should it do? | |
- Overwrite the existing file. Let your users decide what they'd like to do here. | |
* Consider the inclusion of css, or even generated css templates using pre existing libraries (lesscss or yerk – sass.) | |
Anything else? |
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
http://ujihisa.blogspot.com/2009/06/rubygems-best-practice.html |
OlderNewer