Skip to content

Instantly share code, notes, and snippets.

@AndrewO
AndrewO / diagram.txt
Created February 12, 2020 22:31
Scripts to Rule Them All
+----------------------------------------+
|script/cibuild |
| build and test on CI server |
| |
| * calls script/test |
| * sets environment variables for CI |
| |
+----------------------------------------+
|

Stephen's Shitlist

Person/Place/Thing Shit-storm level (tm)
Obama / Healthcare ![1][poo] ![2][poo] ![3][poo] ![4][poo] ![5][poo]
ERB and HAML templates ![1][poo] ![2][poo] ![3][poo] ![4][poo] ![5][poo]
Matt Newton Metaprogramming ![1][poo] ![2][poo] ![3][poo] ![4][poo] ![5][poo]
T-Mobile ![1][poo] ![2][poo] ![3][poo] ![4][poo] ![5][poo]
Ruby Hash Rockets ![1][poo] ![2][poo] ![3][poo] ![4][poo] ![5][poo]
PHP Developers ![1][poo] ![2][poo] ![3][poo] ![4][poo] ![5][poo]
class A
attr_reader :val
def initialize(a, &b)
@val = a || (b ? b.call : :nada)
end
end
class B < A
def initialize(b)
super(b)
@AndrewO
AndrewO / multi_index_elastic_search.rb
Created April 16, 2014 20:38
Multi-index searching with highlighting across heterogenous types.
# We have a couple of indices that have been created independently.
# Now we want to search across them, with highlighting (and ideally
# suggestors as well) without breaking exisiting services.
#
# The mappings do not have consistent field names, but they have fields that can
# be semantically mapped into "title" or "body" (and some others) fields.
#
# From the size of the data, I'm told that creating a new purpose-build index is
# out of the question--even something that would duplicate data in another field
# in the same index is a stretch.
@AndrewO
AndrewO / Main.hs
Created February 6, 2014 14:05 — forked from anonymous/Main.hs
module MountJSON where
-- import Prelude hiding (getContents)
import qualified Data.Aeson as JSON
import qualified Data.ByteString.Lazy.Char8 as Char
main :: IO ()
main = do
input <- Char.getContents
case JSON.eitherDecode input of
@AndrewO
AndrewO / enumerator_with_final.rb
Created May 2, 2013 21:52
Lazily adding information to Ruby's Enumerator's.
module Enumerator::WithFinal
# Emits a boolean indicating whether or not the current iteration is the final one.
def self.with_final(prev_enum)
begin
while next_val = prev_enum.next
is_final = begin
prev_enum.peek
rescue StopIteration
true
else
@AndrewO
AndrewO / app.js
Created April 20, 2013 01:04
Angular.js: editing arrays of objects the hard(er) way
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.dudes=[
{name:'Leonardo'},
{name:'Donatello'},
{name:'Raphael'},
{name:'Michaelango'}
];
@AndrewO
AndrewO / app.js
Created April 20, 2013 01:02
Angular.js: simple controls for arrays of object.
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.dudes=[
{name:'Leonardo'},
{name:'Donatello'},
{name:'Raphael'},
{name:'Michaelango'}
];
});
@AndrewO
AndrewO / gist:1841191
Created February 16, 2012 02:45
PhantomJS code to dump computed styles of all elements and take a screenshot
[url, height, width, output_dir] = phantom.args
console.log("url #{url}, height #{height}, width #{width}, output_dir #{output_dir}")
page = require('webpage').create()
page.viewportSize =
width: width
height: height
page.onConsoleMessage = (msg) ->
@AndrewO
AndrewO / gist:1168665
Created August 24, 2011 17:48
Some steps to extract a changed vendor'd plugin into a branch off of its main repo
# Following instructions found on http://stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository/359759#359759
# Clone your project repo (making sure to copy all files, even hard links)
git clone --no-hard-links my_app my_active_shipping
cd my_active_shipping
# In your new repo, extract only the commits related to the vendor'd plugin and move that into the new root
git filter-branch --subdirectory-filter vendor/plugins/active_shipping/ HEAD
git reset --hard
# Clean out all of the other commits
git gc --aggressive
git prune