Skip to content

Instantly share code, notes, and snippets.

View uniphil's full-sized avatar

phil uniphil

View GitHub Profile
@uniphil
uniphil / stepper.h
Last active March 7, 2021 22:30
suzy plotter
#define MICROSTEPS 8
#define PERIOD_PER_MICROSTEP_200 2
class Stepper {
bool current_direction;
uint8_t stp, dir, en;
uint16_t period;
int steps_per_rev, current_step;
public:
Stepper(uint8_t step_pin, uint8_t dir_pin, uint8_t en_pin, uint16_t steps) {
#include "packetizer.h"
Packetizer::Packetizer(Stream *s) : stream(s) {}
int print_packet(Stream &s, String m, uint8_t mode=PACKET_NORMAL);
int send_packet(Stream &s, byte * message, size_t message_length, uint8_t mode=PACKET_NORMAL);
boolean Packetizer::might_have_something() {
return stream->available() > 0;
}
app.cli.add_command(db.cli)
@uniphil
uniphil / generate-dictionaries.py
Last active July 6, 2019 14:34
find luks password
from itertools import product
def product_bfirst(*args):
combos = product(*map(enumerate, args))
in_order = sorted(combos, key=
lambda combo: reduce(
lambda sum, (n, _): sum + n, combo, 0))
denumerated = map(lambda combo: map(lambda (_, v): v, combo), in_order)
return denumerated
@uniphil
uniphil / defines.cpp
Last active December 16, 2018 19:54
arduino thermal printer settings
// copy this near the top of your sketch!
// change the numbers here to change print settings
// look at your parts kit receipt for numbers that work well with your printer
#define DOTS 4
#define HEAT_TIME 127
#define HEAT_INTERVAL 64
#define PRINT_DENSITY 1
#define PRINT_TIMEOUT 3
@uniphil
uniphil / shader.frag
Created October 29, 2017 23:48
shader stuff
#ifdef GL_ES
precision mediump float;
#endif
/*
HUSL-GLSL v3.2
HUSL is a human-friendly alternative to HSL. ( http://www.husl-colors.org )
GLSL port by William Malo ( https://github.com/williammalo )
Put this code in your fragment shader.
*/
@uniphil
uniphil / index.js
Last active July 19, 2017 15:11
es6 modules combinator
export default (at, a = 1, b = 1) =>
at < 1 ? a : require('.').default(at - 1, b, a + b);
@uniphil
uniphil / sample output
Last active December 4, 2016 06:24
Signals helper for CISC-220
$ ./sig.sh ./shortLines poem.txt out.txt 24 USR1 USR2 USR1 USR2 INT
✎ For Whom the Bell Tolls
⚡ USR1
Input file: sig_pipe.fifo
Output file: out.txt
✎ John Donne
⚡ USR2
Lines read: 2
⚡ USR1
@uniphil
uniphil / index.html
Created November 22, 2016 20:36
poorly behaved svg in flexbox
<p>The blue boxes are SVG elements, which should stretch to fill their container, via <code>preserveAspectRatio="none"</code> and <code>viewBox="0 0 100 100"</code>.</p>
<p>In the fifth example, the SVG escapes the height that the flexbox layout should be giving it. It's broken in both FireFox and Chrome, in slightly different ways.</p>
<p>The issue only appears when the SVG is getting squished vertically. With tall containers, the SVG gets horizontally compressed just fine.</p>
<p>In the last example, <code>overflow: hidden</code> on the flex parent is convincing FireFox to squish the SVG to size. However, Chrome just clips it in this case.</p>
<input id="mode" type="checkbox" >
<label for="mode">
<span class="button" id="wide">wide</span>
<span class="button" id="tall">tall</span>
</label>
@uniphil
uniphil / blah.jsx
Last active September 20, 2016 03:42
React CSS API sketch
import React from 'react';
import css from 'blahcss';
const BlahSFC = ({ title }) => css((
<div>
<header>
<h1>{title}</h1>
<p>some text in the header</p>
</header>