Skip to content

Instantly share code, notes, and snippets.

@brendandawes
brendandawes / FieldNotesClip.scad
Created October 18, 2011 09:25
Field Notes Clip for 3D Printing - inspired by http://www.thingiverse.com/thing:3560
pencilRadius = 3.75;
wallThickness = 2.5;
pencilWall = pencilRadius + wallThickness;
height = 38;
length = 35;
difference() {
union() {
cylinder(height,pencilWall,pencilWall,true);
translate([-3.75,-length/2,0])
@brendandawes
brendandawes / gist:1584029
Created January 9, 2012 17:32
Happiness Machine code for Nanode / Arduino
// Happiness Machine Arduino / Nanode Code
// See www.brendandawes.com
#include <EtherCard.h>
#include <NewSoftSerial.h>
NewSoftSerial Thermal(2, 3); //Soft RX from printer on D2, soft TX out to printer on D3
#define FALSE 0
#define TRUE 1
@brendandawes
brendandawes / gist:1584039
Created January 9, 2012 17:34
Happiness Machine PHP code
<?php
function download($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FAILONERROR,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$retValue = curl_exec($ch);
@brendandawes
brendandawes / TwitterButton
Created August 31, 2012 18:02
Electric Imp example for a button to trigger a tweet - needs http://open.sen.se
// Simple button to Twitter
// Button is on pin1 and GND
local channelOutput = [ OutputPort("Ch 1", "string")];
// Event handler for state changes
function swEvent() {
local d = date();
@brendandawes
brendandawes / Ben Folds Five Poster - Cityscape Generator.pde
Last active December 11, 2015 21:48
Processing source code that was used to generate the little cityscapes for my Ben Folds Five poster.
// Ben Folds Five Poster - Cityscape Generator by Brendan Dawes
// http://brendandawes.com/projects/benfoldsfive/
// Requires library from http://toxiclibs.org
import toxi.color.*;
import toxi.util.datatypes.*;
import processing.pdf.*;
final color BACKGROUND_COLOR = color(240);
@brendandawes
brendandawes / James Bond Kills.pde
Last active December 12, 2015 04:18
Number of kills by James Bond in EON Production movies. Data provided by the Guardian Data Store.
import processing.pdf.*;
/*
James Bond Kills by Brendan Dawes
http://brendandawes.com/projects/jamesbondkills/
CSV import method by che-wei wang.
Requires CSV export from data provided by Guardian Data Store.
https://docs.google.com/spreadsheet/ccc?key=0AonYZs4MzlZbdEgyUE9aQktJR0ZEWFlURGlYODNISHc#gid=1
/*
Simple video scrubbing example using Leap Motion
Made for Processing – requires LeapMotionP5 library
An open hand pauses the video and then allows you to scrub the video left and right.
Closing your hand plays the video.
http://brendandawes.com/blog/leapmotion
*/
@brendandawes
brendandawes / Milkshake brings the boys to the yard
Last active March 15, 2016 15:07
Learn to code with Kelis' Milkshake Part 1
/*
Learn to code with Kelis' Milkshake
http://en.wikipedia.org/wiki/Milkshake_(song)
Created by Brendan Dawes brendandawes.com
*/
// "my milkshake brings all the boys to the yard"
var milkShake;
var boysToTheYard = 0;
@brendandawes
brendandawes / I could teach you but I'd have to charge
Last active March 15, 2016 15:13
Learn to code with Kelis' Milkshake Part 2
/*
Learn to code with Kelis' Milkshake
http://en.wikipedia.org/wiki/Milkshake_(song)
Created by Brendan Dawes brendandawes.com
*/
/ "I could teach you, but I'd have to charge"
var teachYou = true;
FIRST=
for FILE in *.csv
do
exec 5<"$FILE" # Open file
read LINE <&5 # Read first line
[ -z "$FIRST" ] && echo "$LINE" # Print it only from first file
FIRST="no"
cat <&5 # Print the rest directly to standard output