Skip to content

Instantly share code, notes, and snippets.

@haiitch
haiitch / dagobjects.rb
Created March 4, 2018 01:28
a trivial dsl for ipfs dag handling
dago1 = DAGObject.new
puts "DIR #{dago1.cid}"
dag1 = DAG.new( { a: 1, b: 2, c: 3 } )
puts "DAG #{dag1.cid}"
dag2 = DAG.new( { artist: "Ramones", phrase: "Hey, ho! Let's go!" } )
puts "DAG #{dag2.cid}"
dag3 = DAG.new( { country: "Australia", capital: "Canberra" } )
@haiitch
haiitch / raylib-go-test.go
Created October 14, 2017 12:52
A raylib-go test that crashes randomly
package main
import (
"fmt"
"image"
"math"
"time"
"math/rand"
"github.com/fogleman/gg"
@haiitch
haiitch / gossamy.go
Created May 26, 2017 00:22
Basic Gossamy abstraction
package gossamy
type Controller interface {
// here go user events
}
type Arranger interface {
func Arrange()
// here go
}
@haiitch
haiitch / gist:268fac0fb0435ebe6f84b4c11a7fa27e
Created April 24, 2017 17:15
Ethereum donations address
0xdbe89b2051535c084335a311ff0fdf7bcbe7f95f
@haiitch
haiitch / lookupable.rb
Created January 31, 2017 17:02
module Lookupable
# Either as a mixin or a separate implementation for Array and Hash
# this feels like something that should be in Ruby core.
# A better implementation of this, obviously, with identical functionality
module Lookupable
def lookup(lookupindex,lookupvalue,returnindex)
isarray = self.class == Array
self.each_with_index {|element,index|
record = isarray ? element : element.last
if record[lookupindex]==lookupvalue then
return record[returnindex]