This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import sys | |
from math import sqrt | |
def uniquepalette(image): | |
hist = set() | |
for j in range(image.size[1]): | |
for i in range(image.size[0]): | |
hist.add(image.getpixel((i,j))) | |
return hist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct, sys | |
def unpack_bytes(len, bytes): | |
if len == 3: | |
bytes.extend(b'\x00') | |
return struct.unpack('<I', bytes)[0] | |
def read_pgz_file(file_path): | |
with open(file_path, 'rb') as file: | |
# Read the file type signature (first byte) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for R in `aws ec2 describe-regions --query 'Regions[*].RegionName' --output text` ; do ; echo "Region: $R" ; echo "`aws ec2 describe-availability-zones --region $R --query \"AvailabilityZones[*].[ZoneName, ZoneId]\" --output text`" ; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: |
NewerOlder