Skip to content

Instantly share code, notes, and snippets.

@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();
@jakeonrails
jakeonrails / Ruby Notepad Bookmarklet
Created January 29, 2013 18:08
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
@ghoulmann
ghoulmann / despotify-help.sh
Created April 11, 2013 15:13
Scripted installation of despotify on Raspberry Pi running Raspbian. Confirmed to work on Ubuntu Precise.
#!/bin/bash -ex
#use bash, be verbose
HOSTNAME=despotify
SVN_TARGET="/tmp/spotify"
#Check for Root
function check_for_root ()
{
LUID=$(id -u)
@cat-haines
cat-haines / pulse.js
Last active December 16, 2015 20:19
A simple Squirrel class for handeling pulses as a type of digital input and a simple example using it. NOTE: Accuracy has NOT been tested.
/*******************************************************************************
* Reads a pulse (either HIGH or LOW) on a pin. If the pulseValue is HIGH,
* the object will start timing when the pin goes HIGH, then waits for the pin
* to go LOW, and executes the callback (callback expects a function with one
* parameter, the length of the pulse in microseconds).
*
* The accuracy of this function has not been tested, and will have some
* variance because of how callbacks work.
******************************************************************************/
class Pulse {