Skip to content

Instantly share code, notes, and snippets.

# calculate the WPM of a dit ".", dah "-", space (intra word)
# and "/" (inter word) string as per the output of
# https://morsecode.world/international/translator.html
#
# provide the number of seconds as an argument
#
# example run
# python3 .\count_dits_est_wpm.py 57
# . ...- . .-. -.-- / -.. .. - / .- -. -.. / -.. .- .... / -.-. .- .-. .-. .. . ... / .- / ...- --- .. -.-. . / .- -.-. .-. --- ... ... / - .... . / .- .. .-. .-- .- ...- . ... .-.-.-
# 7.768421052631578
from sys import stdin
from operator import sub
input_data = [ (int(a),int(b)) for a,b in (line.split() for line in stdin)]
print( sum( map(lambda a: abs(sub(*a)),
zip(sorted(a for a,b in input_data),
sorted(b for a,b in input_data)) )))
@markjenkins
markjenkins / output.txt
Created November 4, 2024 08:12
2024 US electoral college combinations
swing states
PA 19
GA 16
NC 16
MI 15
AZ 11
WI 10
NV 6
Democrats (226 baseline)
@markjenkins
markjenkins / extract_transcript_with_speaker_labels.py
Created September 25, 2024 05:07
A simple python script to take a AWS transcribe json file with speaker labels and print a plain text transcript
#!/usr/bin/env python3
# Take a AWS transcribe json file with speaker labels from stdin and
# print out a plain text transcript with the speaker_label items at the
# start of line with a colon
# Copyright Mark Jenkins <mark@markjenkins.ca>
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
@markjenkins
markjenkins / encode_wave_to_opus.sh
Created June 7, 2024 01:57
morse code play tools
#!/bin/sh
opusenc $1 `basename -s .wav $1`.opus
@markjenkins
markjenkins / tone1.bas
Last active January 12, 2024 04:28
A VIC20 BASIC tone generator using the user port for morse code practice
rem VIC-20 basic program to act as a tone
rem generator for morse code practice
rem author Mark Jenkins <mark@parit.ca>
rem checks portB pin 0 e.g. pin "C"
rem hardware connected to user-port
rem should short that pin to ground when a
rem switch is closed.
rem
@markjenkins
markjenkins / x11vnc_notes.txt
Created October 15, 2023 16:41
invoking x11vnc with unix auth, localhost binding and no ssl requirements
UNIXPW_DISABLE_SSL=1 x11vnc -display :0 -forever -localhost -unixpw
@markjenkins
markjenkins / IQ511_record_to_cronolog_avi.sh
Created October 13, 2023 08:28
IQ511 record mjpeg avi to cronolog
#!/bin/sh
# for IQ511
# $1 is the last octet of the ipv4 address
# created files are not cleaned up
# regarding /now.jpg urls
# snap=spush0.25 means camera push a frame every 0.25 seconds
# ds=2 downsample by a factor of 2 (half size)
#
#!/usr/bin/env python3
# https://adventofcode.com/2022/day/1 Parts 1 and 2 with constant memory
# Mark Jenkins
from heapq import nlargest
def gen_elf_lines():
"""a generator of consecutive elf lines, converted to int
@markjenkins
markjenkins / aoc2021_d01p1.py
Last active December 10, 2022 08:47
Advent of code 2021 in Python and Guile Scheme https://adventofcode.com/2021/
#!/usr/bin/env python3
EOFDEPTH = -1
def read_depth_line():
try:
line = input()
return int(line)
except EOFError:
return EOFDEPTH