Skip to content

Instantly share code, notes, and snippets.

View fhwang's full-sized avatar

Francis Hwang fhwang

View GitHub Profile
@fhwang
fhwang / git-stale-branches
Created December 19, 2018 18:28
A script for finding local branches that have not changed in X days.
#!/usr/bin/env ruby
unless ARGV.size == 1
puts "git-stale-branches [days ago]"
exit
end
require 'date'
days_ago = ARGV.first.to_i
@fhwang
fhwang / gist:1887192
Created February 22, 2012 20:55
Rake tasks for running spec files that match a pattern. Developed for the good folks at HowAboutWe.
namespace :spec do
namespace :units do
desc "Run unit specs with PATTERN in the spec file name"
RSpec::Core::RakeTask.new(:selective => "db:test:prepare") do |t|
t.pattern = FileList["spec/**/*#{ENV['PATTERN']}*_spec.rb"].exclude("spec/integration/**/*_spec.rb")
end
end
namespace :integration do
desc "Run integration specs with PATTERN in the spec file name"
@fhwang
fhwang / gist:1120210
Created August 2, 2011 13:48
Git pre-commit hook for JSHint and Rails
#!/usr/bin/env ruby
# To use this:
# * Set up the jshint Gem with your Rails app: https://github.com/liquid/jshint_on_rails
# * Copy this file to [YOURPROJECT]/.git/hooks/pre-commit
# * chmod 0755 .git/hooks/pre-commit
files_changed = `git diff --name-only HEAD`
if files_changed.any? { |line| line =~ %r|public/javascripts| }
puts "Running jshint to check changes to javascript ..."
0.000000 67.214.211.240 -> 208.85.151.4 DNS Standard query AAAA app.profitably.com
0.038723 208.85.151.4 -> 67.214.211.240 DNS Standard query response
0.038903 67.214.211.240 -> 208.85.151.4 DNS Standard query AAAA app.profitably.com.blueboxgrid.com
0.040013 208.85.151.4 -> 67.214.211.240 DNS Standard query response, No such name
0.040165 67.214.211.240 -> 208.85.151.4 DNS Standard query A app.profitably.com
0.079842 208.85.151.4 -> 67.214.211.240 DNS Standard query response A 208.85.144.70
0.080195 67.214.211.240 -> 208.85.144.70 TCP 59764 > https [SYN] Seq=0 Win=5840 Len=0 MSS=1460 TSV=3099548928 TSER=0 WS=7
0.080386 208.85.144.70 -> 67.214.211.240 TCP https > 59764 [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460 WS=4
0.080415 67.214.211.240 -> 208.85.144.70 TCP 59764 > https [ACK] Seq=1 Ack=1 Win=5888 Len=0
0.090365 67.214.211.240 -> 208.85.144.70 SSL Client Hello
18.356621 67.214.211.240 -> 208.85.151.4 DNS Standard query AAAA app.profitably.com
18.357004 208.85.151.4 -> 67.214.211.240 DNS Standard query response
18.357079 67.214.211.240 -> 208.85.151.4 DNS Standard query AAAA app.profitably.com.blueboxgrid.com
18.357454 208.85.151.4 -> 67.214.211.240 DNS Standard query response, No such name
18.357535 67.214.211.240 -> 208.85.151.4 DNS Standard query A app.profitably.com
18.357956 208.85.151.4 -> 67.214.211.240 DNS Standard query response A 208.85.144.70
18.358148 67.214.211.240 -> 208.85.144.70 TCP 55367 > https [SYN] Seq=0 Win=5840 Len=0 MSS=1460 TSV=2257194637 TSER=0 WS=7
18.358274 208.85.144.70 -> 67.214.211.240 TCP https > 55367 [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460 WS=4
18.358296 67.214.211.240 -> 208.85.144.70 TCP 55367 > https [ACK] Seq=1 Ack=1 Win=5888 Len=0
18.367894 67.214.211.240 -> 208.85.144.70 SSL Client Hello
def read_only_struct(*attrs)
c = Class.new
eval_me = <<-CLASS_EVAL_OH_NOES
def initialize(#{attrs.map { |sym| sym.to_s }.join(', ')})
#{attrs.map { |attr| "@#{attr} = #{attr}" }.join("\n")}
end
attr_reader #{attrs.map { |sym| ":#{sym.to_s}" }.join(', ')}
CLASS_EVAL_OH_NOES
c.class_eval eval_me
class NilClass
def foobar=(fb)
@foobar = fb
end
def foobar_is_true?
@foobar == nil?
end
end