Skip to content

Instantly share code, notes, and snippets.

@brendandawes
brendandawes / README.md
Last active January 12, 2023 08:29
Sine waves created with p5.js

This was born out of weekend of playing with p5.js that eventually ended up being my Twitter profile banner updated every hour via a cron job on the server, using Phantomjs to snap the resultant image.

if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5
// internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
@brendandawes
brendandawes / ISOPaperSizes.pde
Created April 23, 2013 15:44
ISO 216 paper sizes in pixels @ 300dpi
/*
ISO 216 paper sizes converted to pixels @ 300dpi
Drop this file in your Processing sketch and use like so: size(A1w, A1h);
*/
final int A5w = 1748;
final int A5h = 2480;
final int A4w = 2480;
/*
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 / 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
@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 / Toy Rocket Construction Kit.scad
Last active April 11, 2018 02:40
OpenSCAD file for the Toy Rocket Construction Kit
/*
Toy Rocket Construction Kit by Brendan Dawes
brendandawes.com
Nose cone isn't great but it suffices for now!
*/
rocketRadius = 20;
connectorHeight = 5;
@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 / 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 / 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