Skip to content

Instantly share code, notes, and snippets.

View Aupajo's full-sized avatar

Pete Nicholls Aupajo

  • Christchurch, New Zealand
View GitHub Profile
require 'benchmark'
def fib_vanilla(n)
return n if (0..1).include?(n)
fib_vanilla(n - 1) + fib_vanilla(n - 2)
end
fib_memoized = Hash.new { |numbers, index|
numbers[index] = fib_memoized[index - 2] + fib_memoized[index - 1]
}.update(0 => 0, 1 => 1)

Making an office dashboard with a Raspberry Pi

Steps taken with a basic Raspbian install.

Default username/password is pi/raspberry.

SSH access is enabled by default; run ifconfig on the Pi to find the IP address to connect to.

Bring everything up-to-date:

List of NZ Beers worth sampling

An incomplete list.

Sessionable

  • Emerson's 1812 (many supermarkets)
  • Emerson's Bookbinder (good “session” ale)
  • Cassel's Best Bitter (from The Brewery)
  • Beer Baroness Lady Danger (from Pomeroy's)
@Aupajo
Aupajo / 70s-sci-fi.ck
Last active August 29, 2015 13:59
ChucK shreds
SinOsc s => dac;
while(true) {
100::ms => now;
Std.rand2f(30.0, 1000.0) => s.freq;
}
@Aupajo
Aupajo / regex_tests.js
Last active August 29, 2015 13:57
CSV regex experiments
// Kids, this is a bad idea. Don't try this at home.
//
// npm install csv-spectrum
//
var CSV_REGEX = /^(([^,"]+)|("([^"]|"")*"))(,(([^,"]+)|("([^"]|"")*")))*$/;
var spectrum = require('csv-spectrum'),
passed = 0,
failed = 0;
<?xml version="1.0" encoding="UTF-8"?>
<json:object
xsi:schemaLocation="http://www.datapower.com/schemas/json jsonx.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx">
<json:string name="reply">Here's how you would encode a reply to your tweet!</json:string>
</json:object>
require 'dream_cheeky'
require 'nokogiri'
require 'httparty'
DreamCheeky::BigRedButton.run do
open do
reddit_home_page = HTTParty.get('http://www.reddit.com/')
doc = Nokogiri::HTML(reddit_home_page)
link_elements = doc.css('.link')
class MilesConverter
CONVERSIONS = {
km: 1.6,
m: 1.6 * 1000,
cm: 1.6 * 1000 * 100,
mm: 1.6 * 1000 * 100 * 10,
whatever: 103321
}
attr_reader :miles
class DonutShop
PRICES =
pink: 3.30
glazed: 5.00
sprinked: 4.40
constructor: (@name, @flavoursome = true) ->
@todaysRevenue = 0
serve: (customers) ->
source 'https://rubygems.org'
gem 'rack'