Skip to content

Instantly share code, notes, and snippets.

@boblail
boblail / mysql-insert_all-test.rb
Created February 27, 2021 14:01
Active Record Test single file
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails", branch: "master"
@boblail
boblail / lily.js
Last active May 5, 2020 20:32
Amazon's Angular app for v1 of the CCP
(function() {
angular
.module("ccpModule", ["ngRoute", "ngAnimate", "ngResource"])
.config(function($routeProvider) {
$routeProvider
.when("/", {
templateUrl: "index.html",
controller: "MainController"
})
.when("/dialPad", {
@boblail
boblail / lily.js
Created May 5, 2020 19:08
Amazon's Angular app for v1 of the CCP
(function() {
angular
.module("ccpModule", ["ngRoute", "ngAnimate", "ngResource"])
.config(function($routeProvider) {
$routeProvider
.when("/", {
templateUrl: "index.html",
controller: "MainController"
})
.when("/dialPad", {
@boblail
boblail / after_restart.rb
Created January 14, 2014 21:21
Configuring an EngineYard Deploy Hook to notify Houston
if %w{solo app_master}.member? config.current_role
app = config.current_path[/(?<=\/data\/)([^\/]+)(?=\/)/]
env = ENV["RAILS_ENV"]
sha = File.read("#{config.current_path}/REVISION").chomp
require 'net/http'
require 'uri'
uri = URI("http://status.cphepdev.com/projects/#{app}/deploy/#{env}")
configuration = config.configuration
@boblail
boblail / errbit.rb
Last active January 2, 2016 14:38
Configure Airbrake to inform Errbit of GIT_COMMIT
Airbrake.configure do |config|
# ...
config.user_attributes = %w{id email} # the default is just 'id'
config.async = true # requires the gem 'sucker_punch' and 'airbrake ~> 3.1.15'
end
# Inform Errbit of the version of the codebase checked out
GIT_COMMIT = ENV.fetch('COMMIT_HASH', `git log -n1 --format='%H'`.chomp).freeze
@boblail
boblail / ledger.md
Last active January 2, 2016 12:39
Refactor List

Ledger Refactors

  • Stop passing so many arguments to the TransactionEntry directive:
    • accounts and fiscalYears, at least, can be derived from root scope
  • Global months
  • Don't use expand and collapse methods
  • Nodes have both isAccount and resourceType
@boblail
boblail / sql_rocket
Last active December 17, 2015 09:29
Exports a MySQL database as XML, walks the XML stream with nokogiri, and outputs well-formed Postgres SQL
#!/usr/bin/env ruby
# encoding: utf-8
# https://gist.github.com/boblail/5587579
require 'benchmark'
require 'nokogiri'
require 'progressbar'
require 'tempfile'
class SqlRocket < Nokogiri::XML::SAX::Document
@boblail
boblail / pdftk.rb
Last active December 16, 2015 00:39 — forked from Echos/pdftk.rb
require 'formula'
class Pdftk < Formula
url 'http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk-1.44-src.zip'
homepage 'http://www.pdflabs.com/'
md5 '9eb50fffcd621a627d387750c60982b4'
# depends_on 'gcc' # with "--enable-java" option , required "Homebrew-alt" .
# via : https://github.com/adamv/homebrew-alt/
def install
@boblail
boblail / gist:2731915
Created May 19, 2012 18:45
A/B Testing; DDD
@boblail
boblail / find_easter.cs
Created April 25, 2011 20:44
Calculate the date of Easter given the year
public static DateTime FindEaster( int year ) {
int month, day, century, n, m, i, j, k, z, a, l;
century = year / 100;
n = year % 19;
m = (century - 17) / 25;
i = century - (century >> 2) - (int)((century - m) / 3) + 19 * n + 15;
j = i % 30;
z = (int)(j / 28);
k = j - z * (1 - z * (int)(29 / (j + 1)) * (int)((21 - n) / 11));