Skip to content

Instantly share code, notes, and snippets.

@hollobon
hollobon / 6502_opcodes.py
Last active July 31, 2017 22:59
8-Bit CPU Opcode matrices
#!/usr/bin/env python
mnemonics = """
ADC AND ASL BCC BCS BEQ BIT BMI BNE BPL BRK BVC BVS CLC
CLD CLI CLV CMP CPX CPY DEC DEX DEY EOR INC INX INY JMP
JSR LDA LDX LDY LSR NOP ORA PHA PHP PLA PLP ROL ROR RTI
RTS SBC SEC SED SEI STA STX STY TAX TAY TSX TXA TXS TYA
""".split()
for m in mnemonics:
@hollobon
hollobon / avrwait.sh
Last active August 28, 2015 13:27
Program Adafruit atmega32u4 from Linux with avrdude
#!/usr/bin/zsh
while ( [ ! -e /dev/ttyACM0 ] ) {
echo wait...
sleep 0.2
}
# To program, use something like:
# sudo echo && (make && avrwait && sudo avrdude.sh -V -p m32u4 -P /dev/ttyACM0 -c avr109 -U flash:w:Keyboard.hex)
@hollobon
hollobon / convert 0b to 0x.el
Created August 25, 2015 16:01
Convert binary (0b) literals to hex (0x) literals in Emacs
M-x replace-regexp 0b\([01]+\) \,(format "0x%X" (string-to-number \1 2)))
@hollobon
hollobon / gist:7579947
Last active December 28, 2015 23:38
Get NTFS hard link count for file(s)
import os
import sys
import tempfile
import win32file
from glob import glob
def get_link_count(filename):
if os.path.isdir(filename):
dwFlagsAndAttributes = win32file.FILE_FLAG_BACKUP_SEMANTICS
else:
@hollobon
hollobon / gist:5859974
Created June 25, 2013 16:32
Make an Emacs frame fullscreen (no caption or window borders) on Windows.
"""Make the Emacs window full-screen on Windows
At present, this will only adjust the first Emacs frame found. It could be modified to use
win32api.EnumWindows and win32api.GetClassName / win32api.GetWindowText in order to adjust all
Emacs frames.
"""
import argparse
import sys
import win32gui