Skip to content

Instantly share code, notes, and snippets.

View ben-biddington's full-sized avatar

Ben Biddington ben-biddington

View GitHub Profile

Consider the relational database. Queries to it return vectors of maps of (eventually) primitives. Databases as varied as Mongo and Redis do the same.

Consider communication to a Javascript or native app front end. It is via (JSON or XML) vectors and maps of (eventually) primitives.

The same applies in the reverse direction: maps and vectors come from the front end, are munged, and are inserted as maps and vectors of (eventually) primitives.

Are all apps 3-tier web apps? No. But I would claim they are the dominant kind of app today, in terms of mindshare and sheer amount of effort devoted to easing their development.

So, interesting: an enormous amount of effort is spent on apps that convert map/vector-structured data into map/vector-structured data.

@ben-biddington
ben-biddington / highfive.js
Last active September 9, 2015 06:37 — forked from kmoe/highfive.js
module['exports'] = function highFive(hook) {
// hook.io has a range of node modules available - see
// https://hook.io/modules.
// We use request (https://www.npmjs.com/package/request) for an easy way to
// make the HTTP request.
var request = require('request');
// The parameters passed in via the slash command POST request.
var params = hook.params;
@ben-biddington
ben-biddington / overtone-notes.md
Created February 26, 2015 07:11
Notes on getting overtone to work (it doesn't yet)

boneymin

Follow the advice here under section "If you can't start jackd without root rights"

Add user to audio group

sudo adduser ben audio
@ben-biddington
ben-biddington / unified_diff.rb
Created September 10, 2014 09:13
Unified diff with diff-lcs
require 'diff-lcs'
require 'diff/lcs/hunk'
old_data = ["xxx", "abc"]
new_data = ["xxy"]
pieces = Diff::LCS.diff old_data, new_data
hunk = Diff::LCS::Hunk.new(old_data, new_data, pieces[0], 3, 0)
puts hunk.diff(:unified).to_s
@ben-biddington
ben-biddington / richard_iii.rb
Last active August 29, 2015 14:05
Wire protocol documentation
require 'minitest/autorun'
require 'minitest/pride'
class WireConversationWithTwitter < MiniTest::Test
def test_that_it_rejects_an_unauthorised_request
when_I_request <<-TEXT
GET /1.1/statuses
Host: api.twitter.com
Accept: application/json
TEXT
@ben-biddington
ben-biddington / bob_example.md
Last active August 29, 2015 14:04
An object/data structure anti-symmetry example

The following is a functional solution to the Bob exercism example:

class Bob
  def hey(what)
    return 'Woah, chill out!' if shouted?(what)
    return 'Sure.' if question?(what) 
    return 'Fine. Be that way!' if blank?(what)
    'Whatever.'
 end
@ben-biddington
ben-biddington / interactions.md
Last active December 22, 2015 08:49
Decomposing interactions by following the messages

###"I have something I'd like you to look at" This one looks more like procedural decomposition, TwitterHandle#valid? is a function operating on a data structure (string). the target does not "know" anything other than what is supplied as its argument.

validator = TwitterHandleValidator.new
 
TwitterHandleValidator.valid? "ben-biddington"
require 'minitest'
require 'minitest/autorun'
Array.class_eval do
def accumulate(&block)
self.map &block
end
end
class ArrayTest < MiniTest::Unit::TestCase
module Audible
def on(event, &block)
listeners_for(event) << block if block_given?
end
protected
def notify(event, *args)
listeners_for(event).each do |listener|
listener.call event, args
@ben-biddington
ben-biddington / .rspec
Last active December 18, 2015 17:49
Zipping files
-c