Skip to content

Instantly share code, notes, and snippets.

View bcobb's full-sized avatar
🌝

Brian Cobb bcobb

🌝
View GitHub Profile
# at_most(5.times) do
# some_volatile_operation
# end
def at_most(enum)
begin
yield
rescue => e
can_retry = enum.next rescue false
if can_retry
@bcobb
bcobb / postgis.markdown
Created March 19, 2013 21:25
Postgres+PostGIS on EC2, used from Heroku.
@bcobb
bcobb / thread_pool.rb
Created November 26, 2013 21:37
A small, probably bad Thread Pool written in the service of reproducing a bug.
require 'thread'
module ThreadPool
class Executor
def initialize(queue)
@queue = queue
@thread = nil
end
@bcobb
bcobb / cons-car-cdr.swift
Last active June 18, 2021 12:18
SICP cons/car/cdr in Swift
enum ConsPosition {
case Left, Right
}
func cons<T>(a: T, b: T) -> (ConsPosition -> T) {
func innerCons(i: ConsPosition) -> T {
if i == .Left {
return a;
} else {
return b;
@bcobb
bcobb / README.md
Last active March 24, 2016 16:45
Bank OCR Kata

Problem Description

User Story 1

You work for a bank, which has recently purchased an ingenious machine to assist in reading letters and faxes sent in by branch offices. The machine scans the paper documents, and produces a file with a number of entries which each look like this:

  _  _     _  _  _  _  _
| _| _||_||_ |_ ||_||_|
function emptyList() {
return function(which) {
return which(undefined, emptyList(), true);
};
}
function prepend(head, tail) {
return function(which) {
return which(head, tail, false);
};
@bcobb
bcobb / original.html
Created April 22, 2018 12:59
recipes
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style type="text/css">
/* Shared styles */
body {
font-family: HelveticaNeue, sans-serif;
font-size: 16.0px;
color: #34302e;
@bcobb
bcobb / SketchSystems.spec
Created June 29, 2018 19:29
Auto Refills Card
Auto Refills Card
Recommended Auto-Refills
Add Starter Set -> Considering Auto-Refills
Considering Auto-Refills
Add Auto-Refills -> Reviewing Auto-Refills
I prefer to Refill Manually -> Reconsidering Manual-Refills
Considering Manual-Refills
Review Order -> Reviewing Manual-Refills
I prefer Auto-Refills -> Reconsidering Auto-Refills
Reviewing Auto-Refills
@bcobb
bcobb / SketchSystems.spec
Created June 29, 2018 19:57
Auto Refills Card
Auto Refills Card
Recommended Manual-Refills
Add Starter Set -> Considering Manual-Refills
Recommended Auto-Refills
Add Starter Set -> Considering Auto-Refills
Considering Auto-Refills
Add Auto-Refills -> Reviewing Auto-Refills
I prefer to Refill Manually -> Reconsidering Manual-Refills
Considering Manual-Refills
Review Order -> Reviewing Manual-Refills