Skip to content

Instantly share code, notes, and snippets.

View elandesign's full-sized avatar

Paul Smith elandesign

View GitHub Profile
@elandesign
elandesign / oldest-line.rb
Created March 16, 2016 17:47
Find the oldest line of extant ruby code in a git repository
class OldestLineOfCode
IGNORE_LINES = /.*?\)\s*(class |module |def |#|$)/
def initialize
@oldest = "2016-03-16"
@oldest_file = nil
@oldest_line = nil
end
def scan
@elandesign
elandesign / Rakefile
Last active March 3, 2016 12:29
Add some metrics to your Rakefiles
task :environment do
puts "environment"
end
namespace :metrics do
task :before do
# Get time task started
@started_at = Time.now.to_i
end
@elandesign
elandesign / ofx-generator.rb
Created November 25, 2015 10:37
Script to generate a dummy ofx bank statement
#!/usr/bin/env ruby
# == Synopsis
# Generate a dummy OFX bank transactions file
# Depends on nokogiri, faker and pickup gems
# OFX format reverse engineered from my Nationwide bank download. YMMV.
#
# == Usage
# ofx-generator [options] > file.ofx
#
@elandesign
elandesign / rerun-bookmarklet.js
Last active November 10, 2015 16:30
Rerun failed specs from Jenkins output
javascript:(function()%7Bfunction%20callback()%7Bvar%20output%20%3D%20%24(%22pre%22).text()%3Bvar%20failures%20%3D%20output.match(%2Frspec%20%5C.%5C%2F%5B%5E%20%5D%2B%2Fg)%3Bvar%20command%20%3D%20%22rspec%20%22%20%2B%20failures.map(function(s)%7Breturn%20s.match(%2F%5C.%5C%2F.*%2F)%5B0%5D%7D).join(%22%20%22)%3Bif(%24(%22%23rerun%22).length%20%3D%3D%200)%24(%22%23main-table%22).prepend(%22%3Cthead%3E%3Ctr%3E%3Ctd%20colspan%3D%5C%222%5C%22%20id%3D%5C%22rerun%5C%22%3E%22%20%2B%20command%20%2B%20%22%3C%2Ftd%3E%3C%2Ftr%3E%3C%2Fthead%3E%22)%7Dvar%20s%3Ddocument.createElement(%22script%22)%3Bs.src%3D%22https%3A%2F%2Fcode.jquery.com%2Fjquery-1.11.3.min.js%22%3Bif(s.addEventListener)%7Bs.addEventListener(%22load%22%2Ccallback%2Cfalse)%7Delse%20if(s.readyState)%7Bs.onreadystatechange%3Dcallback%7Ddocument.body.appendChild(s)%3B%7D)()

Keybase proof

I hereby claim:

  • I am elandesign on github.
  • I am elandesign (https://keybase.io/elandesign) on keybase.
  • I have a public key whose fingerprint is EA2D BB4B 06A4 6A6C E94A 466B 5B8A 6E6D B65F 8A10

To claim this, I am signing this object:

@elandesign
elandesign / noip-update.rb
Created February 6, 2014 17:19
No-IP update script
#!/usr/bin/env ruby
require 'logger'
USERNAME = "me%40example.org"
PASSWORD = "password"
HOSTNAME = "subdomain.no-ip.biz"
TEMPFILE = "/tmp/ip_address"
TTL = 86400
LOGFILE = "/var/log/noip.log"
build_package_patch_ruby_railsexpress() {
fetch_git rvm-patchsets git://github.com/skaes/rvm-patchsets.git master
patch -p1 < rvm-patchsets/master/patches/ruby/1.9.3/p484/railsexpress/07-export-a-few-more-symbols-for-ruby-prof.patch
patch -p1 < rvm-patchsets/master/patches/ruby/1.9.3/p484/railsexpress/08-thread-variables.patch
patch -p1 < rvm-patchsets/master/patches/ruby/1.9.3/p484/railsexpress/09-faster-loading.patch
patch -p1 < rvm-patchsets/master/patches/ruby/1.9.3/p484/railsexpress/10-falcon-st-opt.patch
patch -p1 < rvm-patchsets/master/patches/ruby/1.9.3/p484/railsexpress/11-falcon-sparse-array.patch
patch -p1 < rvm-patchsets/master/patches/ruby/1.9.3/p484/railsexpress/12-falcon-array-queue.patch
patch -p1 < rvm-patchsets/master/patches/ruby/1.9.3/p484/railsexpress/14-show-full-backtrace-on-stack-overflow.patch
@elandesign
elandesign / ofx-generator
Created December 6, 2013 17:32
Generate an OFX file of dummy, sane(ish) transactions. Used to test bank statement uploads for FreeAgent.
#!/usr/bin/env ruby
# == Synopsis
# Generate a dummy OFX bank transactions file
# Depends on nokogiri, faker and pickup gems
# OFX format reverse engineered from my Nationwide bank download. YMMV.
#
# == Usage
# ofx-generator [options] > file.ofx
#
@elandesign
elandesign / 3-element-benchmark-array-concatenation.rb
Last active December 29, 2015 02:29
Is it quicker to concatenate individual elements, or construct a new array and add that to the existing one?
require 'benchmark'
repeats = 3
iterations = 1_000_000
def check(repeats, &block)
times = []
repeats.times do
times << Benchmark.realtime(&block)
end
# Return the average
@elandesign
elandesign / mysql.rb
Created October 31, 2013 10:22
brew formula to install MySQL 5.5.29 (updated URL to point to a valid source)
require 'formula'
class Mysql < Formula
homepage 'http://dev.mysql.com/doc/refman/5.5/en/'
url 'http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.29.tar.gz'
version '5.5.29'
sha1 '40e26b193b6ece86ce97896c0c9c524d479e37be'
bottle do
sha1 '3c5b57df466eb538db58654c5f046ddf7bc675e9' => :mountainlion