Skip to content

Instantly share code, notes, and snippets.

Avatar

Myles Eftos madpilot

View GitHub Profile
View hass_amber_light_blueprint.yaml
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:
View WifiSwitch.ino
#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 Jan 16, 2017
Bit-bang me some binary
View bitbang.c
/* 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 Jan 16, 2017
Scale the pulse width to 1 from 1.04
View scale.rb
#!/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 Jan 16, 2017
Normalize the LabNation export for my air conditioner, so each pulse is exactly 1.04
View normalize.rb
#!/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 Jan 16, 2017
Takes a LabNation export, and finds transitions. The file can be loaded in D3, for visualization
View compress.rb
#!/usr/bin/env ruby -w
require 'csv'
file = ARGV[0]
out = file.split('.').join('-compressed.')
unless file
puts "Usage: compress [filename]"
exit(-1)
end
View gulpfile.js
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: [
View xio.io
#!/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 Apr 17, 2015
Rake task to generate font icons from a folder full of SVGs
View icons.rake
require 'fileutils'
RANGE = (0xe000...0xf8ff);
def map_fonts(src, map_file)
map = {
'meta' => {
'author' => "Redbubble"
},
'font' => {
@madpilot
madpilot / svg-check
Created Nov 27, 2013
SVG check (Stolen from Modernizr
View svg-check
var svg = (!!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect);