Skip to content

Instantly share code, notes, and snippets.

@markjenkins
markjenkins / four_words.py
Last active October 8, 2021 22:00
wordlist based password generators
#!/usr/bin/env python3
from __future__ import print_function
from random import SystemRandom
from os.path import join, dirname
sysrandom = SystemRandom()
;;; https://leosstemhacks.wordpress.com/2018/03/27/np-complete-3rd-grade-math-problems/
;;; https://news.ycombinator.com/item?id=28343073
;;;
;;; I frame this as a satisfiability problem and tackle it with backtracking
;;; and an optimizing heuristic
;;;
;;; The heuristic is this, we sort the items from lowest value to greatest
;;; and only try to add the next lowest item available in our search
;;; if that item puts the total over, then we know all remaining items
;;; which are of greater value will do the same
@markjenkins
markjenkins / Barcode handling.js
Last active July 10, 2021 20:31 — forked from alexwebr/Barcode handling.js
Code snippet from MB Vaccine App
}, u.default.createElement(s.Camera, {
onBarCodeScanned: R ? function(t) {
var l, o, u, c, s, p, y;
return n.default.async(function(v) {
for (;;) switch (v.prev = v.next) {
case 0:
return l = t.type, o = t.data, v.next = 3, n.default.awrap(f.getNetworkStateAsync());
case 3:
if (!1 !== (u = v.sent).isConnected && !1 !== u.isInternetReachable) {
v.next = 8;
@markjenkins
markjenkins / bip39_english.txt
Created April 17, 2021 18:23
Create an Electrum segwit (0x100) seed from a standard seed (0x01) using BIP39 english list
abandon
ability
able
about
above
absent
absorb
abstract
absurd
abuse
@markjenkins
markjenkins / 2021-02-23_boardcandidates.txt
Last active February 24, 2021 00:25
2021-02-23 election
Elected by acclamation
Michael Kozakewich
Kyle Martin
Edwin Amsler
Thor Robinson
Pietra Shirley
<p>
<a href="https://markjenkins.ca">Return to markjenkins.ca</a>
</p>
<p>
This contact form submits to my
<a href="mailto:mark@markjenkins.ca">mark@markjenkins.ca</a> email address.
</p>
@markjenkins
markjenkins / example_ballots.txt
Last active August 5, 2020 04:03
Election of a single candidate by HMAC
Voter code yS2MuD4+iPrmZOoSIY76qLCMQWS/wQxnql8MmpN9AUY= votes for Pirates
non interactively
echo -e "yS2MuD4+iPrmZOoSIY76qLCMQWS/wQxnql8MmpN9AUY=\nPirates" | python3 hmac_vote.py
interactively
python3 hmac_vote.py
What's your code? > yS2MuD4+iPrmZOoSIY76qLCMQWS/wQxnql8MmpN9AUY=
Your code is:
yS2MuD4+iPrmZOoSIY76qLCMQWS/wQxnql8MmpN9AUY=
from functools import reduce
def map( func, iterable):
def f(a, b):
return a + [func(b)]
return reduce( f, iterable, [] )
#!/usr/bin/env python3
# Solution to http://adventofcode.com/2016/day/4 part 1
# Mark Jenkins <mark@markjenkins.ca>
from sys import stdin
from collections import Counter
from itertools import islice
CHECKSUM_SIZE = 5
#!/usr/bin/env python3
# functional solution to http://adventofcode.com/2016/day/3 part 1
# Mark Jenkins <mark@markjenkins.ca>
from sys import stdin
def possible_triangle(args):
assert(len(args)==3)
sum_args = sum(args)