Skip to content

Instantly share code, notes, and snippets.

View quad's full-sized avatar

Scott Robinson quad

View GitHub Profile
@quad
quad / lr.c
Created October 31, 2012 02:24
Local Register
#include <arpa/inet.h>
#include <errno.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <dns_sd.h>
void callback(DNSServiceRef sdRef,
@quad
quad / hey.rb
Created December 8, 2012 19:04
hey! a minimalist CRM
#!/usr/bin/env ruby
#
# hey! a minimalist CRM for http://todotxt.com/
#
# hey tells you one thing you should do regularly, but haven't done lately.
#
# $ todo.sh lf hey
# 1 @phone Mom (+1 234 567 8901) +family
# 2 @skype Dad +family
# 3 @email mentor
@quad
quad / dci_spec.rb
Last active December 10, 2015 19:48
Working through the DCI example from Singapore Ruby (2013-1-8)
require 'minitest/autorun'
class Account < Struct.new :balance
end
class MoneyTransfer < Struct.new :source, :destination
def initialize source, destination
super
source.extend Transferrer
end
@quad
quad / dci_bench.rb
Last active April 3, 2017 09:59
Because Rubyists knows the value of everything, but the cost of nothing.
require 'benchmark'
require 'delegate'
class Direct
def method
'direct'
end
def base
'base'
@quad
quad / jshint-runner.js
Created April 23, 2013 04:58
A phantomjs runner for JSHint
// PhantomJS doesn't support bind yet
Function.prototype.bind = Function.prototype.bind || function (thisp) {
var fn = this;
return function () {
return fn.apply(thisp, arguments);
};
};
(function(p) {
var fs = require('fs'),
@quad
quad / mini-proof.rb
Created May 10, 2013 05:18
A (probably incorrect) proof of work system based on my understanding of Hashcash. For instructional purposes only!
require 'digest/sha1'
class Proof < Struct.new :data, :difficulty, :token
def valid?
hash = Digest::SHA1.hexdigest("#{data} #{difficulty} #{token}")
pl = prefix_length(hash.to_i(16))
difficulty <= pl
end
def increment
@quad
quad / Sanke.pas
Last active December 18, 2015 01:39
SANKE THE SNAKE By Brandon Ethakada & Tai Bell-Liu 10J Ported Scott Robinson
program YearTenComputerSystemsProjectByBrandonEthakadaAndTaiBellLiu;
uses ptccrt, ptcgraph;
var keyz : string;
selection,speed : integer;
procedure InitIt;
var gd, gm : integer;
begin
Gd := d8bit;
Gm := m640x480;
@quad
quad / edit_behavior.py
Last active August 29, 2015 13:57
edit_behavior.py customization for Chinese study
# -*- coding: utf-8 -*-
# Welcome to the Chinese Support Add-on's field edition ruleset.
# Here, you can tweak the note editor helper's behavior to your liking.
#
# If you messed things up, you can safely delete file
# addons/chinese/edit_behavior.py from your Anki directory.
# It will be recreated the next time you restart Anki.
#
# You can read about all available functions at:
# https://github.com/ttempe/chinese-support-addon/wiki/Edit-behavior
@quad
quad / times.rb
Last active August 29, 2015 14:07
Because implementing cron is always a good idea.
require 'date'
require 'minitest/autorun'
class Time
def self.normalize time
dt = DateTime.parse(time).to_time.utc
Time.utc(Time.now.year, nil, nil, dt.hour, dt.min)
end
def inbetween start_time, end_time
@quad
quad / subtype_registration_example.rb
Created March 12, 2015 03:10
A rough sketch to how I'd register subtypes.
class Thing < Struct.new(:color)
@@things = {}
def self.parse description
type_name, color = description.split
@@things[type_name].new color
end
def self.type_code code
@@things[code] = self