Skip to content

Instantly share code, notes, and snippets.

View themadinventor's full-sized avatar

Fredrik Ahlberg themadinventor

View GitHub Profile

Keybase proof

I hereby claim:

  • I am themadinventor on github.
  • I am fahlberg (https://keybase.io/fahlberg) on keybase.
  • I have a public key ASD8SPCff3NDJjFKJ7tCfBIsZsToFc74_p9Y0CNgu6wCmAo

To claim this, I am signing this object:

@themadinventor
themadinventor / blink_suspend
Created February 8, 2017 22:13
Blink suspend led on Thinkpad
#!/usr/bin/env python3
import usb.core
import usb.util
class BusError(Exception):
pass
class USBI(object):
@themadinventor
themadinventor / sflash_stub.S
Created April 17, 2015 08:38
sflash stub for esptool
/*
* sflash_stub (c) 2015, Fredrik Ahlberg <fredrik@z80.se>
* Released under the GPLv2.
*/
.literal .P_offset, 0xdeadbeef
.literal .P_size, 0xcafebabe
.literal .P_count, 0xabad1dea
.literal .send_packet, 0x40003c80
@themadinventor
themadinventor / gist:3b0b097fb5aa50e23a0d
Created January 28, 2015 22:18
Convert binary file (blob) to c-style array.
bin2c() {
output=${2-/dev/stdout}
echo -n "uint8_t data[] = {" > "$output"
hexdump -v -e '"0x" 1/1 "%02X" ", "' $1 >> "$output"
echo "};" >> "$output"
}
@themadinventor
themadinventor / dbeam.py
Last active December 24, 2015 18:59
Disassemble beam files with pybeam (ff2798ff93eb58246addd64af6742ec3f7e8ba17). Now with float literal support. Woohoo!
#!/usr/bin/env python
#
# Quick and dirty BEAM disassembler
# using pybeam
#
# 131005 Fredrik Ahlberg <fredrik@z80.se>
import sys
import pybeam
from pybeam.opcodes import *