Skip to content

Instantly share code, notes, and snippets.

Pete Nicholls Aupajo

Block or report user

Report or block Aupajo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Aupajo
Aupajo / regex_tests.js
Last active Aug 29, 2015
CSV regex experiments
View regex_tests.js
// 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 Aug 29, 2015
ChucK shreds
View 70s-sci-fi.ck
SinOsc s => dac;
while(true) {
100::ms => now;
Std.rand2f(30.0, 1000.0) => s.freq;
}
View gist:add590ac7eab6046a8d4

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:

View fibs.rb
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)
View ruby-front-end-experiment.md

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

View redis-experiments.rb
require 'redis'
require 'benchmark'
hash = {}
array = nil
redis = Redis.new
n_values = 720
redis.del redis.keys("demo:*")
View date_ranges.rb
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 Jul 7, 2014
Revolving asset host in Middleman
View config.rb
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
View designer.html
<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 Aug 29, 2015
Woto application
View candidacy.js
var Candidacy = function(applicant) {
this.applicant = applicant;
};
Candidacy.SCORE_DIMENSIONS = [
'creativity',
'socialMediaEngagement',
'freshGraduate',
'passionate',
'workEthic'
You can’t perform that action at this time.