Skip to content

Instantly share code, notes, and snippets.

@AndrewO
AndrewO / certification_client.exs
Created April 28, 2024 13:45
Draft of certification test for Elixir Varlink client
defmodule CertificationClient do
@moduledoc """
Varlink client certification tests.
"""
@doc """
Runs the client certification tests.
## Ported from [the Python certification test code](https://github.com/varlink/python/blob/master/varlink/tests/test_certification.py#L31
@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) ->