Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mbainrot's full-sized avatar

Max Bainrot mbainrot

  • Canberra, Australia
View GitHub Profile
@mbainrot
mbainrot / knobby_midi.ino
Created October 15, 2022 09:50
Quick and dirty arduino sketch yields an 8 channel MIDI CC controller for cheap.
#include <MIDI.h>
#define STROBE 5
#define DATA 6
#define CLK 7
#define RTRN A0
#define MIDI_IN 2
#define MIDI_OUT 3
#define VCV_MODE 4
@mbainrot
mbainrot / setalltrackwidth.py
Created December 7, 2020 08:53
kicad pcbnew python set all track width
board = pcbnew.GetBoard()
tracks = board.GetTracks()
targetWidth = 300000 # 300000 = 0.3 mm
for track in tracks:
track.SetWidth(targetWidth)
@mbainrot
mbainrot / main.c
Last active April 16, 2018 08:09
How I got serial working on a PIC18F2550
/*
* File: main.c
* Author: max
*
* Created on April 14, 2018, 10:40 AM
*/
// Set the OSC to internal osc which is 8 MHz
#pragma config FOSC = INTOSC_EC
#pragma config WDT = OFF // turn off watch dog
@mbainrot
mbainrot / bash commands ran to clean up stuff.sh
Created July 30, 2016 08:11
Troublesome entries in ABCnewsmetadata.csv, this file is a diff of the original metadata csv and the one after I killed 36ish bad entires that where causing the import to fail. Quickly looking at it, it appears mostly to be unescaped double quotes. Seems like the only seperator that wouldn't cause any trouble is an open curly brackets.
echo "COPY article_meta_raw FROM '/tmp/ABCnewsmetadata.sedded.csv' DELIMITER ',' CSV HEADER;" > meh.sql
sed '31121d' /tmp/ABCnewsmetadata.csv > /tmp/ABCnewsmetadata.sedded.csv; cat meh.sql | psql govhack2016
sed '46943d' /tmp/ABCnewsmetadata.sedded.csv > /tmp/ABCnewsmetadata.sedded.csv.tmp; mv /tmp/ABCnewsmetadata.sedded.csv.tmp /tmp/ABCnewsmetadata.sedded.csv; cat meh.sql | psql govhack2016
sed '76305d' /tmp/ABCnewsmetadata.sedded.csv > /tmp/ABCnewsmetadata.sedded.csv.tmp; mv /tmp/ABCnewsmetadata.sedded.csv.tmp /tmp/ABCnewsmetadata.sedded.csv; cat meh.sql | psql govhack2016
sed '98705d' /tmp/ABCnewsmetadata.sedded.csv > /tmp/ABCnewsmetadata.sedded.csv.tmp; mv /tmp/ABCnewsmetadata.sedded.csv.tmp /tmp/ABCnewsmetadata.sedded.csv; cat meh.sql | psql govhack2016
sed '110072d' /tmp/ABCnewsmetadata.sedded.csv > /tmp/ABCnewsmetadata.sedded.csv.tmp; mv /tmp/ABCnewsmetadata.sedded.csv.tmp /tmp/ABCnewsmetadata.sedded.csv; cat meh.sql | psql govhack2016
sed '118533d' /tmp/ABCnewsmetadata.sedded.csv > /tmp/ABCnewsmetadat
X:12.00 Y:29.00 Z:2.90
# UP
G1 Z4.50 F100
# DOWN
G1 Z2.50 F100
# TOP LEFT
G1 X12 Y29 F1200
@mbainrot
mbainrot / get_all_petrol_stations2.py
Created November 29, 2015 04:31
Queries an OSM PostGIS database for all the petrol stations along a GPX route (obtained via openrouteservice).
#!/usr/bin/python3.4
import psycopg2
import xmltodict
import pickle
datafile = "/home/max/Desktop/map2.gpx"
with open(datafile) as fd:
oGpxFile = xmltodict.parse(fd.read())
@mbainrot
mbainrot / process_act_toilet_data.py
Created July 5, 2015 12:17
ACT Coordiniate System Info
EPSG Code - EPSG::5825
Name - AGD66 / ACT Standard Grid
Conversion: http://epsg.io/5825
proj4: +proj=tmerc +lat_0=-35.31773627777778 +lon_0=149.0092948305555 +k=1.000086 +x_0=200000 +y_0=600000 +ellps=aust_SA +towgs84=-117.808,-51.536,137.784,0.303,0.446,0.234,-0.29 +units=m +no_defs
WKT: PROJCS["AGD66 / ACT Standard Grid",GEOGCS["AGD66",DATUM["Australian_Geodetic_Datum_1966",SPHEROID["Australian National Spheroid",6378160,298.25,AUTHORITY["EPSG","7003"]],TOWGS84[-117.808,-51.536,137.784,0.303,0.446,0.234,-0.29],AUTHORITY["EPSG","6202"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4202"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",-35.31773627777778],PARAMETER["central_meridian",149.0092948305555],PARAMETER["scale_factor",1.000086],PARAMETER["false_easting",200000],PARAMETER["false_northing",600000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG
@mbainrot
mbainrot / cron
Last active August 29, 2015 14:22
Timelapse Script
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
#!/bin/bash
# For use with ubuntu 14.04 LTS, might work for ubuntu 14.10 though ymmv
add-apt-repository ppa:mapnik/boost
apt-get update
apt-get install libboost-dev libboost-filesystem-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev libboost-system-dev libboost-thread-dev
apt-cache policy libboost-dev
@mbainrot
mbainrot / gist:ea9e31f14060a0a205f4
Created April 25, 2015 23:57
Creation for the power monitoring table
CREATE TABLE IF NOT EXISTS `tbldailytotal` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`meterid` int(11) NOT NULL,
`day` int(11) NOT NULL,
`month` int(11) NOT NULL,
`year` int(11) NOT NULL,
`hour` int(11) NOT NULL,
`minute` int(11) NOT NULL,
`start_ts` int(11) NOT NULL,
`end_ts` int(11) NOT NULL,