Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / _KiCad_Length_Matching
Last active February 10, 2021 05:18
Length matching scripts for KiCad
This script now has its own proper repo thanks to @mithro:
https://github.com/mithro/kicad-length-matching-checks
@projectgus
projectgus / sub_mate.txt
Created January 22, 2015 05:01
"Sub-Mate" homebrew Club Mate recipe
Translated from http://subsalzburg.blogsport.eu/2014/12/16/sub-mate-diy-cooking/
by desperate Club Mate enthusiasts from Australia
Sugar Syrup: 150g sugar, 1 pinch citric acid, 1 half teaspoon tamarind paste.
Mate: 5 full tablespoons Mate, 5x infused so a stronger brew results
Dissolve sugar syrup in Mate brew, add juice of one lemon
@projectgus
projectgus / user_main.c
Created March 3, 2015 11:08
Debuggable esp8266 program
#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"
#include "user_config.h"
#include <stdio.h>
volatile uint32_t fast_blink = 250*1000;
volatile uint32_t slow_blink = 1200*1000;
@projectgus
projectgus / winleak.c
Created April 28, 2015 07:17
Minimal test program for libusb leaks on Windows. Relates to https://github.com/libusb/libusb/pull/64
/* Quick sample to demonstrate Windows device leaks from libusb_get_device_list when reusing instances */
#include <stdio.h>
#include "libusb.h"
#include <assert.h>
/* Set to zero to stop after 100 iterations, for running under drmemory/other */
const int RUN_INFINITE = 0;
static libusb_device **stored = NULL;