Skip to content

Instantly share code, notes, and snippets.

View madpilot's full-sized avatar

Myles Eftos madpilot

View GitHub Profile
blueprint:
name: Amber Light
description: Change the colour of a lamp based on the current Amber price
domain: automation
input:
amber_price_sensor:
name: Amber Price Sensor
description: The Amber price sensor you wish to track. If in doubt, use General Price.
selector:
entity:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
const char* ssid = "........";
const char* password = "........";
ESP8266WebServer server(80);
@madpilot
madpilot / bitbang.c
Created January 16, 2017 21:42
Bit-bang me some binary
/* hello-ftdi.c: flash LED connected between CTS and GND.
This example uses the libftdi API.
Minimal error checking; written for brevity, not durability. */
#include <stdio.h>
#include <ftdi.h>
#include <time.h>
#define CTS 0x08 /* CTS (brown wire on FTDI cable) */
@madpilot
madpilot / scale.rb
Created January 16, 2017 21:28
Scale the pulse width to 1 from 1.04
#!/usr/bin/env ruby -w
require 'csv'
file = ARGV[0]
out = file.split('.').join('-normalized.')
unless file
puts "Usage: normalize [filename]"
exit(1)
end
@madpilot
madpilot / normalize.rb
Last active January 16, 2017 21:27
Normalize the LabNation export for my air conditioner, so each pulse is exactly 1.04
#!/usr/bin/env ruby -w
require 'csv'
file = ARGV[0]
out = file.split('.').join('-normalized.')
unless file
puts "Usage: normalize [filename]"
exit(1)
end
@madpilot
madpilot / compress.rb
Created January 16, 2017 21:23
Takes a LabNation export, and finds transitions. The file can be loaded in D3, for visualization
#!/usr/bin/env ruby -w
require 'csv'
file = ARGV[0]
out = file.split('.').join('-compressed.')
unless file
puts "Usage: compress [filename]"
exit(-1)
end
gulp.task('build:javascripts', function(cb) {
webpack({
entry: __dirname + '/app/frontend/javascripts/gifts.js',
output: {
path: __dirname + '/app/assets/javascripts',
filename: 'gifts.js'
},
devtool: "#source-map",
module: {
loaders: [
@madpilot
madpilot / xio.io
Last active August 29, 2015 14:22
#!/bin/bash
getMyIP() {
local _ip _myip _line _nl=$'\n'
while IFS=$': \t' read -a _line ;do
[ -z "${_line%inet}" ] &&
_ip=${_line[${#_line[1]}>4?1:2]} &&
[ "${_ip#127.0.0.1}" ] && _myip=$_ip
done< <(LANG=C /sbin/ifconfig)
printf ${1+-v} $1 "%s${_nl:0:$[${#1}>0?0:1]}" $_myip
@madpilot
madpilot / icons.rake
Created April 17, 2015 01:53
Rake task to generate font icons from a folder full of SVGs
require 'fileutils'
RANGE = (0xe000...0xf8ff);
def map_fonts(src, map_file)
map = {
'meta' => {
'author' => "Redbubble"
},
'font' => {
@madpilot
madpilot / svg-check
Created November 27, 2013 01:15
SVG check (Stolen from Modernizr
var svg = (!!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect);