Skip to content

Instantly share code, notes, and snippets.

@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
@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 / ssl-sni-test.rkt
Created May 12, 2014 06:15
test for TLS SNI in racket
#lang racket
(require openssl)
(define (make-sctx pem)
(define sctx (ssl-make-server-context 'tls))
(ssl-load-default-verify-sources! sctx)
(ssl-set-ciphers! sctx "DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2")
(ssl-load-certificate-chain! sctx pem)
(ssl-load-private-key! sctx pem)
@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]]
#!/usr/bin/python
# inspired by
# http://www.reddit.com/r/mathpics/comments/ookpa/i_decided_to_play_with_the_chaos_game_after_that/
# also, not actually a cube
from OpenGL.GL import *
from OpenGL.arrays import vbo
from OpenGL.GL.shaders import *
@jkominek
jkominek / nasm.rkt
Created May 3, 2013 19:50
takes a string of assembly, feeds it to nasm, loads it into memory marked executable, and uses the ffi to turn pointers in it into procedures. obviously the assembly has to match your architecture, which has to be 32 or 64 bit x86, as well as your OS calling conventions. example assembly is for 64 bit unix.
(module nasm racket/base
(require racket/system
racket/file
racket/dict
ffi/unsafe
ffi/unsafe/alloc)
(define posix_memalign
; ((allocator free) ; can't auto free these pointers until we ensure that everything using