Skip to content

Instantly share code, notes, and snippets.

# Generate a new schema from a legacy database from a generated hash map
# code released courtesy of Radio New Zealand under MIT license
# see http://www.abletech.co.nz/2009/06/rails-legacy-database-migration/ for more info
desc "generates migration code insert"
task :generate_migrations_sniplet => :environment do
s = "MIGRATIONS = \n"
s << " [\n"
con = ActiveRecord::Base.connection
con.tables.each do |table|
Country,CountryCode,Currency,Code
New Zealand,NZ,New Zealand Dollars,NZD
Cook Islands,CK,New Zealand Dollars,NZD
Niue,NU,New Zealand Dollars,NZD
Pitcairn,PN,New Zealand Dollars,NZD
Tokelau,TK,New Zealand Dollars,NZD
Australian,AU,Australian Dollars,AUD
Christmas Island,CX,Australian Dollars,AUD
Cocos (Keeling) Islands,CC,Australian Dollars,AUD
Heard and Mc Donald Islands,HM,Australian Dollars,AUD
@marcusbaguley
marcusbaguley / Scout plugin for monitoring solr
Created January 21, 2011 00:17
Scout plugin for monitoring solr
# Scout plugin for monitoring solr
class SolrMonitoring < Scout::Plugin
OPTIONS = <<-EOS
solr_port:
notes: Solr port
default: 8080
solr_host:
notes: The host that solr is running on
default: http://127.0.0.1
@marcusbaguley
marcusbaguley / .vimrc
Created May 12, 2011 02:34
vim for rails as textmate .vimrc
filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
set nocompatible
syntax on
filetype plugin indent on
" use softtabs
:set expandtab
:set tabstop=2
@marcusbaguley
marcusbaguley / vim installation
Created May 12, 2011 02:40
installing vim with ruby from source ubuntu
wget ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2
tar -xf vim-7.3.tar.bz2
cd vim73/
./configure --enable-perlin
terp --enable-pythoninterp --enable-rubyinterp --enable-cscope --with-features=huge --prefix=[SET YOUR HOME]
make
make install
@marcusbaguley
marcusbaguley / gist:1036601
Created June 20, 2011 21:14
VIM cheat sheet
u undo
C R redo
C ^ previous
C p complete
move foward and back methods
SHIFT {
SHIFT }
Shell
@marcusbaguley
marcusbaguley / ci_remote_sound.rb
Created July 11, 2011 00:06
Hudson / Jenkins Remote Sound Player
require 'net/http'
last_build = true
new_build = false
while(1) do
xml = Net::HTTP.get(URI.parse('http://fiji.island:8080/api/xml?tree=jobs[name=ims_ci,lastBuild[result]]'))
puts xml
if xml == '<hudson><job><lastBuild></lastBuild></job></hudson>'
new_build = true
elsif xml =~ /job/
current_build_status = !!(xml =~ /SUCCESS/)
@marcusbaguley
marcusbaguley / update_bundles
Created August 12, 2011 03:42
vim bundle script with pathogen and bundles
#!/usr/bin/env ruby
# stolen and adapted from
# https://raw.github.com/dsummersl/dotvim/master/update_bundles.rb
# http://tammersaleh.com/posts/the-modern-vim-config-with-pathogen
vim_command = '/usr/bin/vim'
git_command = 'git'
hg_command = 'hg'
@marcusbaguley
marcusbaguley / slow_running.rb
Created May 15, 2012 22:35
Slow running specs - just ignore them hack
# Allow you to record slow specs and ignore them when running test suite
# 1. RECORD: slow_running_record=true rake spec
# 2. IGNORE: slow_running_ignore=true rake spec
# Don't ignore slow specs on CI server. Review the .slow_running-specs file
class SlowRunning
SLOW_TEST = ENV['slow_running_threshold'] || '1.5'
SLOW_RUNNING_SPEC_FILE = File.join(Rails.root, '.slow_running-specs')
cattr_accessor :file_created
cattr_accessor :slow_tests
@marcusbaguley
marcusbaguley / docker-performance-comparison.txt
Last active February 25, 2019 18:48
Docker Performance Comparison
╔══════════════════════════════╦══════════╦════════════╗
║ Machine ║ One Test ║ Test Suite ║
╠══════════════════════════════╬══════════╬════════════╣
║ 1. Docker for Mac ║ 1m41.2s ║ 2m45 ║
║ 2. Mac - VM - Linux - Docker ║ 0m6.1s ║ 0m56 ║
║ 3. Linux - Docker ║ 0m4.2s ║ 0m23 ║
╚══════════════════════════════╩══════════╩════════════╝