Skip to content

Instantly share code, notes, and snippets.

@digarok
digarok / reset-pw-aws.sh
Created April 9, 2019 14:30
AWS reset users password
aws iam update-login-profile --profile aws-builder-master --user-name JimBob --password "yourpasswordhere"
@digarok
digarok / line_dynamic.s
Created July 9, 2019 02:39
An example of wrapping Andy McFadden's 65816 IIgs line drawing code to support arbitrary draw buffer addresses.
MyBuffer = $051800
* Just need to do this once after malloc
InitDrawlines
lda #<MyBuffer ; should be 1800
sta __p0
sta __p1
sta __p2
sta __p3
# Self-signed certificate generator for AWS by Dagen Brock
# The basic instructions come from Amazon:
# https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/configuring-https-ssl.html
#
# Specifically, you can generate a cert with these 3 commands:
# openssl genrsa 2048 > privatekey.pem
# openssl req -new -key privatekey.pem -out csr.pem
# openssl x509 -req -days 365 -in csr.pem -signkey privatekey.pem -out server.crt
#
# This script walks you through generation and puts them in your specified output dir.
@digarok
digarok / c1-striper.py
Created March 14, 2020 16:36
This takes a raw Apple IIgs $C1 image and writes zeros to every other "scanline".
# Invoke like:
# $ python stripe.py example.c1 output_dir
from sys import argv
from array import array
import os
data = array('B')
with open(argv[1], 'rb') as input_img:
@digarok
digarok / c1-to-png.py
Created April 10, 2020 15:02
Convert Apple IIgs SHR (Super Hi-Res) images to PNG files
### c1-to-png.py by Dagen Brock
#
# Example: python c1-to-png.py. mypicture.shr output.png
#
from PIL import Image, ImageDraw # `pip3 install pillow` if you don't have it
from sys import argv
def get_scanline_palette(scanline):
scb = shr_buffer[0x7D00+scanline] # SCBs start at $E19D00 (SHR RAM starts offset +$2000)
@digarok
digarok / c2-to-animgif.py
Last active July 31, 2022 16:11
Convert PaintWorks Animation (Apple IIgs $C2 filetype) to Animated GIF
# Example: python c2-to-animgif.py anim.c2 outputname.gif
from PIL import Image,ImageDraw # `pip3 install pillow==7.0.0` if you don't have it
from sys import argv, stdout
import glob, tempfile, struct, os
def get_scanline_palette(scanline):
scb = shr_buffer[0x7D00+scanline] # SCBs start at $E19D00 (SHR RAM starts offset +$2000)
cur_pal_num = scb & 0x0F
pal_offset = 0x7E00+(cur_pal_num*16*2) # each pal is 16 colors * 2 bytes per color
# now make a dict of each index => (r,g,b) tuple
@digarok
digarok / trust.bas
Created September 6, 2020 01:26
A nice HGR "floral" effect for Apple II computer in AppleSoft BASIC.
REM "Trust the voice inside of you" - Digarok 2020-09-04
REM Reference: "Three Ways of Looking At A Function""
REM by James Fuller
REM January 1983 (c) Creative Computing
100 DEF FN R(Q) = COS(9 * SIN(2*Q)) : HGR : POKE -16302,0: SZ=5:
700 FOR BB=SZ TO 0 STEP -1: SX=2*BB/SZ:SY=SX:HCOLOR=RND(1)*7+1
800 FOR G = 0 TO 360 STEP 1
810 T = G / 57.29576
820 X = FN R(T) * COS(T) : Y = FN R(T) * SIN(T)
* Disassembly of @deater object tweet https://twitter.com/deater78/status/1368790980237791232
* by @65816guy / digarok/ Dagen Brock
00/00E7: 20 D8 F3 JSR F3D8 ; HGR2 -- set hi-res, page2, full graphics
00/00EA: 8A TXA
00/00EB: 20 11 F4 JSR F411 ; HPOS2 - positions hi-res cursor without plotting
; (A) = Y-coordinate, (Y,X) = X-coordinate
00/00EE: A2 01 LDX #01
00/00F0: A0 F0 LDY #F0
00/00F2: 20 5D F6 JSR F65D ; XDRAW - Draws a shape inverting dots (eor/xor) on screen.
; (A) = rotation, (Y,X) = address of the shape table
@digarok
digarok / datagridder.py
Created July 14, 2021 16:02
Take a list of assembly DEFINE BYTE statements ( " DB $2C") and print them at various grid sizes to look for patterns/alignment.
import fileinput,re,time
# parameters
pattern_DEFINE_BYTE='^.+DB\s+\$([a-fA-F0-9][a-fA-F0-9])'
pause_seconds=0.5
grid_range = range(4,33) # range is not inclusive
join_str = "" # change to comma if you want CSV
def print_chunked(datalist, chunksize):
for i in range(0, len(datalist), chunksize):
## gcleanup #####
# I used to have a one liner but it was janky so reverting to a full blown function by golly gosh gee.
# I like to show the branches if they don't specify one, but in oh_my_zsh they have some interactive thing
# you need to turn off like:
# $ git config --global pager.branch false
#
gcleanup_function() {
if [ -z $1 ] ; then echo "You must specify a branch to cleanup." ; git branch ; return -1; fi
git checkout master