Skip to content

Instantly share code, notes, and snippets.

View cat-haines's full-sized avatar

Cat Haines cat-haines

View GitHub Profile
@cat-haines
cat-haines / mary-had-a-little-lamb-remix.rb
Created March 25, 2016 03:14
Double Union Sonic Pi
live_loop :test do
with_fx :bitcrusher, bits: 8, mix: 0.25 do
sample :drum_bass_soft
sleep 0.5
sample :drum_bass_soft
sample :drum_snare_soft
sleep 0.5
sample :drum_bass_soft
@cat-haines
cat-haines / app.js
Last active January 4, 2016 19:42
Pebble.js Tutorial Part 1 - 1
var UI = require('ui');
// Create a Card with title and subtitle
var card = new UI.Card({
title:'Weather',
subtitle:'Fetching...'
});
// Display the Card
card.show();
#include <pebble.h>
static Window *s_main_window;
static TextLayer *s_time_layer;
static void update_time() {
// Get a tm structure
time_t temp = time(NULL);
struct tm *tick_time = localtime(&temp);
@cat-haines
cat-haines / helloWorld.device.nut
Created October 28, 2015 01:30
Hello World example for Electric Imp
led <- hardware.pin9; // LED Pin
ledState <- 0; // Current state of the LED
// Configure the LED
led.configure(DIGITAL_OUT, ledState);
function blink() {
// run blink() again in half a second
imp.wakeup(0.5, blink);
@cat-haines
cat-haines / imu.device.nut
Created April 15, 2015 15:49
Updated IMU example code.. now with interrupts
#require "lsm9ds0.class.nut:1.1"
/* RUNTIME START ------------------------------------------------------------ */
function xm_int1_cb() {
// you may want/need to debounce this function
if (xm_int1.read()) {
if (imu.clickIntActive()) {
server.log("Click interrupt on XM_INT1");
}
} else {
device.on("data", function(data) {
server.log(http.jsonencode(data));
});
device.on("data", function(data) {
server.log(http.jsonencode(data));
});
@cat-haines
cat-haines / imu.device.nut
Last active August 29, 2015 14:16
IMU Tail
// Copyright (c) 2014 Electric Imp
// This file is licensed under the MIT License
// http://opensource.org/licenses/MIT
class LSM9DS0TR {
static WHO_AM_I_G = 0x0F;
static CTRL_REG1_G = 0x20;
static CTRL_REG2_G = 0x21;
static CTRL_REG3_G = 0x22;
static CTRL_REG4_G = 0x23;
local html = @"<!doctype html>
<html lang=""en"">
<head>
<title>Humidity Control</title>
<link rel=""stylesheet"" href=""https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"" />
<link rel=""stylesheet"" href=""//d2c5utp5fpfikz.cloudfront.net/2_3_1/css/bootstrap.min.css"" >
<link rel=""stylesheet"" href=""//d2c5utp5fpfikz.cloudfront.net/2_3_1/css/bootstrap-responsive.min.css"" >
</head>
<body>
<div class='well' style='max-width: 320px; margin: 0 auto 10px; height:480px; font-size:22px;'>
@cat-haines
cat-haines / mailgun.agent.nut
Last active August 29, 2015 14:10
Mailgun API code
/******************** Constants ********************/
// Your MailGun settings
const API_KEY = "key-a1b2c3...";
const SUBDOMAIN = "sandbox123abc.mailgun.org";
// Define what email to notify
const EMAIL = "[email protected]";
/******************** LIBRARY CODE ********************/
function SendEmail(to, subject, text) {