Skip to content

Instantly share code, notes, and snippets.

@projectgus
projectgus / plot_dropout.plot
Created November 22, 2014 08:57
Very basic scripts for logging a Reload:Pro current sweep, plotting results in GNUPlot. Could be better in many many ways.
set datafile separator comma
set xlabel "IOUT (mA)"
set ylabel "VOUT (mV)"
set key left bottom
plot \
'reg_dropout_7_2v_heatsink.csv' using 2:3 with lines title 'VIN 7.2V with Heatsink', \
'reg_dropout_7_2v_nohs.csv' using 2:3 with lines title 'VIN 7.2V no Heatsink', \
'reg_dropout_7_5v_nohs.csv' using 2:3 with lines title 'VIN 7.5V no Heatsink', \
'reg_dropout_8v_heatsink.csv' using 2:3 with lines title 'VIN 8V with Heatsink', \
'reg_dropout_8v_nohs.csv' using 2:3 with lines title 'VIN 8V no Heatsink', \
@projectgus
projectgus / my_i3status.py
Created October 9, 2014 22:41
i3status/i3bar custom status fields using JSON formatting
#!/usr/bin/env python3
import os, json, sys, subprocess, re
"""
i3_status/i3bar output munger using JSON formatted status lines,
allows you to add custom fields to the i3 status line.
In this example I add a "Backup Running" warning message at the
beginning if a duplicity backup is running, and also put 2.4GHz or
5GHz in the existing wlan0 status line.
@projectgus
projectgus / snippet.mk
Last active August 29, 2015 14:06
Looking for a nice way to have openocd upload via an existing instance if it exists, or run standalone if not
install: $(APP).elf
# try to upload via a running openocd instance first, if that
# fails then fail over to running openocd program
( echo "halt; flash write_image erase $(APP).elf; reset" | nc localhost 4444 ) || \
$(OPENOCD) --command "program $(APP).elf; reset"
@projectgus
projectgus / WebServerFromSD.ino
Created March 17, 2014 00:50
Arduino WebServerFromSD example (simple mashup of Ethernet WebServer & SD DumpFile examples)
/*
Web Server from SD
Take the contents of "datalog.txt" and output it in response to HTTP request on /
Simple mashup of the existing WebServer & DumpFile example sketches by Tom Igoe, Limor Fried, others.
*/
#include <SPI.h>
#include <Ethernet.h>
@projectgus
projectgus / gerblook_it.py
Last active August 29, 2015 13:55
A command line program to upload a directory (or zip file) of gerbers to the excellent online gerber preview tool http://gerblook.org/
#!/usr/bin/env python3
"""
usage: gerblook_it.py [-h] [-m COLOUR] [-s COLOUR] [-c COLOUR] [-n] [GERBERS]
Upload a zip file (or directory of gerbers) to gerblook
Most basic use to upload a whole directory of gerber files is:
cd <gerber_directory>
gerblook_it.py .
@projectgus
projectgus / linpack_bench.ino
Last active March 31, 2021 19:49
Linpack Floating Point benchmark that runs as an Arduino sketch. (Yes, I know...) I wanted to generically measure Arduino Floating Point performance, this seemed like a reasonable(ish) way to do it. Runs with N=10, single precision, but produces sane looking results & residual. (89 Linpack kFLOPS on a Freetronics Eleven, ie Arduino Uno compatibl…
# include <stdlib.h>
# include <stdio.h>
# include <math.h>
int do_benchmark ( void );
double cpu_time ( void );
void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy );
double ddot ( int n, double dx[], int incx, double dy[], int incy );
int dgefa ( double a[], int lda, int n, int ipvt[] );
void dgesl ( double a[], int lda, int n, int ipvt[], double b[], int job );
@projectgus
projectgus / gist:6757491
Created September 29, 2013 23:29
Arduino sketch to calculate CRC32 of a given file from the SD card
/*
* SD card CRC32 calculator by Angus Gratton for Freetronics
*
* CRC32 implementation based on the implementation in the C SNIPPETS archive
* http://web.archive.org/web/20080303102524/http://c.snippets.org/snip_lister.php?fname=crc_32.c
*
* Original Copyright (C) 1986 Gary S. Brown. You may use this program, or
* code or tables extracted from it, as desired without restriction.
*
* This version is released with the same lack of restrictions, use however you please.
@projectgus
projectgus / digikey_ordersplit.py
Last active December 20, 2015 07:29
At CCHS hackerspace we make a lot of group parts orders to save shipping costs. This script can split up a a DigiKey order's total by participant (assuming each person's name is listed in the Customer Reference field for the order.)
#!/usr/bin/env python3
"""
Digikey order splitter script for group buys. For Python 3.x. Public Domain.
Supports cases where people are paying in a different currency to the Digikey currency,
and also pro rata splitting of shipping costs.
If you use this then please sanity check the results before sending them
Usage:
@projectgus
projectgus / gist:6016251
Created July 16, 2013 23:37
Simple mashup of the Arduino Ethernet WebServer example and the SD DumpFile example
/*
Web Server
A simple web server that sends the contents of "hello.txt" on the SD card
to any web client that connects.
Modified from the "Ethernet -> WebServer" & "SD -> DumpFile" Arduino examples
by Angus Gratton <angus@freetronics.com>
*/