Skip to content

Instantly share code, notes, and snippets.

View gist:9d5f7de8fea56c36d3181e515216e808
//var f = "uncomment me to change colours";
var yellow = new Uint16Array([0x0000,0xFFC0],0,1); // black, yellow
var white = new Uint16Array([0x0000,0xffff],0,1); // black, white
var red = new Uint16Array([0x0000,0xf800],0,1); // black, red
var buf = Graphics.createArrayBuffer(240,160,1, {msb:true});
function flip(x,y,palette) {
g.drawImage({width:240,height:40,bpp:1,buffer:buf.buffer, palette:palette},x,y);
View img2nn.pl
#!/usr/bin/perl
# neural net to represent an image by mapping (x,y) => (r,g,b)
# James Stanley 2021
# inspired by https://news.ycombinator.com/item?id=28448626
use strict;
use warnings;
use AI::FANN qw(:all);
View cat-laser.ino
/* Cat Laser */
#include <Servo.h>
// pin configuration
const int xservopin = 2;
const int yservopin = 3;
const int speedpin = A0;
const int dwellpin = A1;
const int xrangepin = A2;
View gzipboi.py
#!/usr/bin/env python3
import gzip, os, sys
infile = open("fresh-food-16.json", "r")
b = bytes(infile.read(),"utf8")
n = 0
View tyre-squeal.gd
# This is the tyre squeal model from this clip: https://youtu.be/Likwgc5s_T0
# You need an "AudioStreamPlayer3D" at the position of each wheel, and then run
# this function from _process_physics, with each wheel node passed
func tyre_squeal(tyre):
# increase squeal amplitude with road speed
var speed_factor = 1
if (get_speed_kph() < 100):
speed_factor = 0.5 + 0.5 * (get_speed_kph()/100)
View jesboard.ino
#include <Keyboard.h>
#define NKEYS 3
unsigned long mintime = 20; // ms (debounce time)
int keypin[NKEYS] = {2,3,4};
char letter[NKEYS] = {'j', 'e', 's'};
int isdown[NKEYS];
unsigned long lastchange[NKEYS];
View diff
diff --git a/Vagrantfile b/Vagrantfile
index 317fd6d..54ecde1 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -45,12 +45,11 @@ Vagrant.configure("2") do |config|
-p 5601:5601 \
--network audit"
- d.run "docker.elastic.co/beats/filebeat:7.7.0",
+ d.run "docker.elastic.co/beats/filebeat:7.7.0 -e -strict.perms=false",
View jesblog
#!/usr/bin/perl
# jes's crappy blog generator
use strict;
use warnings;
use DateTime;
use DateTime::Format::Strptime;
use File::Copy;
use JSON qw(decode_json);
@jes
jes / rc2014-vga.ino
Created Oct 21, 2019
VGA Serial output for RC2014 (19x10 character display)
View rc2014-vga.ino
// 19x10 VGA serial display
// James Stanley <james@incoherency.co.uk>
// Note that this needs a modified version of VGAX.h that only uses 1bpp instead of 2bpp else there isn't enough RAM
#include <VGAX.h>
//font generated from BITFONZI - by Sandro Maffiodo
#define FNT_NANOFONT_HEIGHT 6
#define FNT_NANOFONT_SYMBOLS_COUNT 95
//data size=570 bytes
View jesblog
#!/usr/bin/perl
# jes's crappy blog generator
use strict;
use warnings;
use DateTime;
use DateTime::Format::Strptime;
use File::Copy;
use JSON qw(decode_json);