Skip to content

Instantly share code, notes, and snippets.

@jkominek
jkominek / pal2verilog.py
Last active June 25, 2024 14:37
really dumb code for converting a PAL file into verilog
#!/usr/bin/env python3
import sys
import re
palfile = [ x.strip() for x in open(sys.argv[1]).readlines() ]
part = palfile[0]
reference = palfile[1]
checksum = palfile[2]
@jkominek
jkominek / async_fifo.v
Last active June 15, 2024 04:40
FTDI 232H synchronous FIFO fed by a on-FPGA clock domain crossing FIFO, in Verilog
// Asynchronous FIFO module
module async_fifo #(
// Parameters
parameter DATA_SIZE = 8, // Number of data bits
parameter ADDR_SIZE = 4 // Number of bits for address
) (
// Inputs
input [DATA_SIZE-1:0] w_data, // Data to be written to FIFO
@jkominek
jkominek / bytegen.v
Created June 14, 2024 18:31
FTDI 232H synchronous mode Verilog + libftdi1 example code
module bytegen(input clk,
input clkout,
input txe,
output reg [7:0] outdata,
output reg wrb,
output siwu,
output [7:0] led);
reg [19:0] counter = 20'b0;
@jkominek
jkominek / solarcron.py
Created February 2, 2022 05:52
generate cron jobs based on sunrise/sunset, independent of daylight savings time
#!/usr/bin/env python3
import ephem
from datetime import datetime, timedelta, timezone
# don't generate any invocations until
SKIP_UNTIL = datetime(2021, 10, 16, 12, 0, 0)
# times to run per day
FOODS = 8
# thing to run
@jkominek
jkominek / 14impacts.txt
Created March 15, 2021 06:27
Grand piano hammer striking a CNY70 with roughly increasing intensity
This file has been truncated, but you can view the full file.
0.22188506458333335 0
0.22195119791666668 504
0.22201742291666668 511
0.22208362291666667 510
0.22214973125 511
0.22221593958333333 0
0.22228210625 511
0.22234823958333333 511
0.22241446875 504
0.22248198125 511
@jkominek
jkominek / casttojson.py
Created September 21, 2020 02:22
sqlalchemy postgresql poor man's custom types
# I had a fancy custom type in PG, and wanted to use it in
# SQLAlchemy. I didn't care to jump through all of the custom
# type stuff, and the type had an reasonable representation
# to JSON, and PG could convert it to/from JSON very easily.
# So I added cast conversions to PG, and then this special
# type:
class CastToJSONB(sqlalchemy.types.TypeDecorator):
'''A JSON object where we force PostgreSQL to cast our
interactions with the value to JSON. Useful when we've
got a PG data type that is a pain in the ass, but has an
@jkominek
jkominek / solo-piano-with-midi.ly
Last active October 22, 2019 06:12
Lilypond template for solo piano with correct dynamics and pedalling in the MIDI
\version "2.18.2"
\language "english"
right = \relative c'' {
\key c \major
\numericTimeSignature
\time 4/4
\tempo "Whatever" 4=60
% ...
}
@jkominek
jkominek / NumericNegationFunctionKeyExpression.java
Created August 12, 2019 21:32
numeric negation function key expression
age record.layer.demo;
import com.apple.foundationdb.record.metadata.expressions.FunctionKeyExpression;
import com.apple.foundationdb.record.metadata.expressions.QueryableKeyExpression;
import com.apple.foundationdb.record.metadata.expressions.KeyExpression;
import com.apple.foundationdb.annotation.API;
import com.apple.foundationdb.record.metadata.Key;
import com.apple.foundationdb.record.metadata.MetaDataException;
import com.apple.foundationdb.record.provider.foundationdb.FDBRecord;
import com.google.protobuf.Message;
@jkominek
jkominek / ami.rkt
Created June 15, 2015 23:20
Asterisk Manager Interface for Racket
#lang racket/base
(require racket/tcp racket/async-channel racket/match racket/function)
(define-struct ami [input-port
output-port thread
request-channel
response-channel
event-channel
[dead? #:mutable]]
@jkominek
jkominek / updatestars.py
Last active March 26, 2022 15:21
Maintain a mirror of all your Github stars.
#!/usr/bin/python
#################
# NOTE
# Now at https://github.com/jkominek/updatestars
#################
import requests
import json
import re