Skip to content

Instantly share code, notes, and snippets.

View Aupajo's full-sized avatar

Pete Nicholls Aupajo

  • Christchurch, New Zealand
View GitHub Profile
@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;
@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;
}

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:

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)

Ideas:

  • Remove vendor/assets from Sprockets environment
  • Spin up a browserify process that can compile a specific JS when asked
  • Add a require lookup mechanism that can understand bower/npm manifest
  • Add browersify hook to compile JS as a Sprockets post-processor

Goal:

what I'd like to do: use a combination of bower, npm, or vendor/assets for front-end deps, use browserify for JS compilation, use sprockets for CSS and asset hashes

require 'redis'
require 'benchmark'
hash = {}
array = nil
redis = Redis.new
n_values = 720
redis.del redis.keys("demo:*")
require 'time'
june_first = DateTime.new(2014, 6, 1)
june_second = DateTime.new(2014, 6, 2)
june_first > june_second # => false
(june_first..june_second).max == june_second # => true
(june_first..june_second).min == june_first # => true
# Range#max and #min return nil if the first value in range is larger than the last value.
@Aupajo
Aupajo / config.rb
Created July 7, 2014 00:56
Revolving asset host in Middleman
activate :asset_host
# Will generate asset1.example.org...asset4.example.org deterministically
set :asset_host do |asset|
"//asset%d.example.org" % (asset.hash % 4 + 1)
end
@Aupajo
Aupajo / designer.html
Created July 17, 2014 22:15
designer
<link rel="import" href="../google-map/google-map.html">
<link rel="import" href="../speech-mic/speech-mic.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icon/core-icon.html">
<polymer-element name="my-element">
<template>
<style>
:host {
@Aupajo
Aupajo / candidacy.js
Last active August 29, 2015 14:06
Woto application
var Candidacy = function(applicant) {
this.applicant = applicant;
};
Candidacy.SCORE_DIMENSIONS = [
'creativity',
'socialMediaEngagement',
'freshGraduate',
'passionate',
'workEthic'