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 |
| |
+----------------------------------------+
|
@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 / 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: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
@AndrewO
AndrewO / browser.rb
Created August 2, 2011 20:42
A small Macruby script to display HTML piped in from STDIN.
framework 'Cocoa'
framework 'WebKit'
require 'optparse'
class Browser
attr_accessor :view
def initialize
@view = WebView.alloc.initWithFrame([0, 0, 520, 520])
@AndrewO
AndrewO / macruby_js_bridge.rb
Created August 1, 2011 21:02 — forked from mattetti/macruby_js_bridge.rb
Fixed "kCGErrorInvalidConnection: CGSGetCurrentCursorLocation: Invalid connection"; turned off plugins
framework 'Cocoa'
framework 'WebKit'
class Cat
attr_accessor :name, :age
def initialize(name = 'kitty', age=42)
@name = name
@age = age
end
@AndrewO
AndrewO / gist:958039
Created May 5, 2011 21:48
A script to find approximate numbers of last names by color.
require 'open-uri'
require 'rubygems'
require 'hpricot'
LAST_NAMES = %w{
black
white
gray
green
red