Skip to content

Instantly share code, notes, and snippets.

@bazzargh
bazzargh / hacker.rb
Created November 13, 2015 21:45
hackertyper style presentation tool, leverages ttyrec to let you play back the presentation from random keystrokes
#!/usr/bin/env ruby
# hackertyper-style playback of series of tty recordings created by
# ttyrec.
#
# usage:
# hacker slides/*
#
# - Type randomly to move forward inside file
# - backspace to skip back or prev file
@bazzargh
bazzargh / tv.rb
Last active July 15, 2022 09:51
discover tv control url for panasonic viera
#!/usr/bin/env ruby
require 'socket'
require 'net/http'
require 'pstore'
require 'rexml/document'
require "curses"
class Television
COMMAND_URN = "urn:panasonic-com:service:p00NetworkControl:1"
@bazzargh
bazzargh / ublock
Created February 27, 2018 22:04
ublock rules for twitter misfeatures
! Block friends favourited tweets
twitter.com##.tweet-has-context:not([data-retweeter])
! fake activity
twitter.com##li[data-component-context="generic_activity"]
! since you were away
twitter.com##.TimelineTweetsModule
! don't care what's trending
twitter.com##.trends.Trends.module
-- solve Dudeney's 6 coins puzzle: https://boingboing.net/2018/05/03/coin-puzzle-how-do-you-make-a.html
-- start from
-- O O O
-- O O O
-- finish with
-- O O
-- O O
-- O O
-- in 3 moves, sliding coins; coins must finish touching 2 other coins.
@bazzargh
bazzargh / gitlink.sh
Last active April 19, 2019 16:20
open code in github at a specific revision and optionally at a line
import Data.List
import Data.Function (on)
-- I don't like the formulation of the exercise, since it seems to suggest you should
-- just look at the picture to get the local over/under relations then solve for the global order.
-- Shouldn't haskell be able to figure out the local relations too?
-- so, as input, just give it the puzzle:
puzzle=zip [0..15] [7,7,8,8,7,1,1,2,6,1,1,5,3,3,4,5]
-- here I'm numbering cells 0..15, top left to bottom right.
-- The top left cells of each square are all different (otherwise a square would be completely
@bazzargh
bazzargh / scrabble.sh
Created December 24, 2020 15:08
scrabble by mail
#!/bin/bash
case "${1:-help}" in
inspect)
cat bag|openssl aes-256-cbc -a -d -salt -pass pass:scrabble
;;
start)
CONTENTS=$(
(
echo EEEEEEEEEEEE;
@bazzargh
bazzargh / bitmap.md
Last active May 15, 2021 17:13
bbc basic bitmap to character codes

To get bitmaps into bbcmicrobot code, one way is to embed them as characters in an initial REM, where they will have address PAGE+5. I find it most convenient to write the bitmap so it is read from bottom to top, with the individual bits of each byte in reverse order; but to write them out that way hurts your head, best to just type in the rows as you see them and let the computer do the work.

There's a trick for embedding bytes with codes < 32 or > 127 - add 256 and only the lower bits will be used by the emulator. Character codes 10 and 13 are not allowed, you'll find they cause reading to skip to the next line; this happens in the manic miner bitmap, so I just used a different character there and mapped that back with an IF. The javascript code below does all the manipulations needed to get the characters you want to paste - I just paste this code in the browser developer console.

@bazzargh
bazzargh / binop.py
Last active September 29, 2022 02:45
spike on an abstract interpreter for a simple python subset using multiinterval arithmetic
import ast
import math
class Interval:
def __init__(self, value1, value2 = None):
self.low = value1
self.high = value1 if value2 is None else value2
def __repr__(self):
return f"[{self.low}, {self.high}]"
@bazzargh
bazzargh / signs.py
Created September 29, 2022 14:41
abstract interpreter following lecture 16 of http://web.mit.edu/afs/athena.mit.edu/course/16/16.399/www/
import ast
import math
import enum
# implement the abstract interpreter used in lecture 16 of http://web.mit.edu/16.399/www/
# abstraction of sets of machine integers by initialization and simple sign
class Value(enum.Enum):
BOT = 0
NEG = 1
ZERO = 2