Skip to content

Instantly share code, notes, and snippets.

View lerouxb's full-sized avatar

Le Roux Bodenstein lerouxb

View GitHub Profile
@lerouxb
lerouxb / ulp_test.py
Created January 2, 2024 18:29
A display driver for Sharp's LS013B7DH03 display entirely in the ESP32's ULP coprocessor
from esp32 import ULP
from machine import mem32
from esp32_ulp import src_to_binary
source = """\
# constants from:
# https://github.com/espressif/esp-idf/blob/v5.0.2/components/soc/esp32/include/soc/reg_base.h
#define DR_REG_RTCIO_BASE 0x3ff48400
# constants from:
@lerouxb
lerouxb / index.js
Created November 30, 2022 11:50
Parse & Analyse .csv files
'use strict';
const fs = require('fs');
const Papa = require('papaparse');
const { ObjectId } = require('bson');
function parseObjectId(value) {
// trying to parse just any string seems to be quite slow, so just support hex strings for now
if (value.length !== 24) {
return null;
[
[1, 'A0', 27.5],
[2, 'A♯0/B♭0', 29.13524],
[3, 'B0', 30.86771],
[4, 'C1', 32.7032],
[5, 'C♯1/D♭1', 34.64783],
[6, 'D1', 36.7081],
[7, 'D♯1/E♭1', 38.89087],
[8, 'E1', 41.20344],
[9, 'F1', 43.65353],
@lerouxb
lerouxb / index.js
Last active October 22, 2020 13:26
Http and websocket proxy that allows you to mess with websocket connections
'use strict';
const proxy = require('./lib/proxy')({ host: 'localhost', port: 8006 });
proxy.listen(8015);
exports.whatIsIt = function (node) {
const matches = [];
for (const [key, value] of Object.entries(Recast.types.namedTypes)) {
if (value.check(node)) {
matches.push(key);
}
}
@lerouxb
lerouxb / README.md
Last active May 20, 2018 20:18
browser e2e testing idea using teenytest and puppeteer

My main goal is to have tests fail as soon as things go wrong rather than the usual thing where failures in browser testing of single page web apps tend to manifest as timeouts.

Second goal is to have really useful errors so you don't have to try and infer what went wrong quite so often.

In terms of style I want to be able to use async/await, my favourite assertion library and a normal test runner. Basically not nightwatch, not anything selenium/chromedriver related. Also a knowable, sane system.

It is a pity that puppeteer would basically lock you into chrome, but I've already seen a Firefox headless wrapper that mimicks the API. Maybe Microsoft will catch on and do the same? I feel strongly that Selenium/Webdriver is a dead end.

--

@lerouxb
lerouxb / snippet.js
Created October 19, 2016 12:42
Unique Airbnb types
var json = JSON.parse(document.getElementById('_bootstrap-neighborhood_card').attributes.content.value);
var unique = Object.keys(json.place_recommendations.reduce(function(memo, place) { memo[place.type] = true; return memo;}, {}));
unique.sort();
console.log(unique.join('\n'));
@lerouxb
lerouxb / names.txt
Created October 19, 2016 12:38
Maki icon names for use with MapBox GeoJSON
aerialway
airfield
airport
alcohol-shop
america-football
amusement-park
aquarium
art-gallery
attraction
bakery
@lerouxb
lerouxb / geartrain.scad
Created December 10, 2015 20:22
A 256:1 gearbox
include <MCAD/involute_gears.scad>
$fn = 100;
gear_module = 0.75;
pressure_angle = 20;
gear_thickness = 5/2;
shaft_radius = 1.5;
small_teeth = 11;
function a(input) {
var index = [];
var item;
for (var i=0; i<input.length; i++) {
item = input[i];
if (index.indexOf(item) === -1) {
index.push(item);
}
}
return index;