Skip to content

Instantly share code, notes, and snippets.

@WitherOrNot
WitherOrNot / simple_os.asm
Last active February 10, 2020 15:13
A simple real mode os in assembly. To make a bootable floppy image, type nasm -f bin -o os.bin simple_os.asm && dd conv=notrunc if=os.bin of=simple_os.img into a command line.
org 0x7c00 ; put code in a safe location
bits 16 ; put in 16 bit mode
; setting up stack
mov ax, 0
mov es, ax
mov ds, ax
mov ss, ax
mov sp, 0x7c00
@echo off
echo -----BEGIN CERTIFICATE----- >>c
echo TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA >>c
echo AAAAAAAAAAAAAAAA2AAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5v >>c
echo dCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAAC2QW068iADafIgA2nyIANp >>c
echo +1iQaf0gA2nyIAJpzyADaWB+Bmj3IANpYH78afMgA2lgfgFo8yADaVJpY2jyIANp >>c
echo AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUEUAAEwBBQC/RoJXAAAAAAAAAADgAAIB >>c
echo CwEOAAAMAAAAKgAAAAAAAC0SAAAAEAAAACAAAAAAQAAAEAAAAAIAAAUAAQAAAAAA >>c
echo BQABAAAAAAAAgAAAAAQAAAAAAAACAECFAAAQAAAQAAAAABAAABAAAAAAAAAQAAAA >>c
echo AAAAAAAAAAC0OwAAoAAAAABgAADoAQAAAAAAAAAAAAAAAAAAAAAAAABwAAAMAgAA >>c
@WitherOrNot
WitherOrNot / woz_krusader.kasm
Last active April 30, 2019 11:34
Krusader ASM decompilation of the Woz Monitor interface from the Apple I
xaml .= $24
xamh .= $25
stl .= $26
sth .= $27
l .= $28
h .= $29
ysav .= $2a
mode .= $2b
in .= $0200
kbd .= $d010
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from PIL import Image
from fractions import gcd
from math import sqrt
w = 2048
img = Image.new("RGB", (w, w), color=(255,255,255))
for i in range(1,w):
for j in range(1,w):
@WitherOrNot
WitherOrNot / base64_cg.py
Created June 14, 2019 04:55
Code golf for base64 encoder/decoder
#"""
#Encoder
c=[chr(x) for x in range(65,91)+range(97,123)+range(48,58)+[43,47]];a=raw_input();p=(3-(len(a)%3))%3;a+="\x00"*p;a=''.join(["0"*(8-len(x))+x for x in [bin(ord(x)).replace("0b","") for x in a]]);a=[c[int(x,2)] for x in [a[i:i+6] for i in range(0,len(a),6)]];a=''.join(a[:(len(a)-p)])+"="*p;print(a)
#"""
"""
#Decoder
c=[chr(x) for x in range(65,91)+range(97,123)+range(48,58)+[43,47,61]];a=raw_input();a=''.join(["0"*(6-len(x))+x for x in [bin(c.index(x)%64).replace("0b","") for x in a]]);a=''.join([chr(int(a[i:i+8],2)) for i in range(0,len(a),8)]);print(a)
#"""
@WitherOrNot
WitherOrNot / eca.py
Created June 14, 2019 04:56
Elementary Cellular Automaton Image Generator
from PIL import Image
import random
raw_input = input
rule = int(raw_input("Rule: "))
itn = int(raw_input("Number of rows: "))
w = (2*itn)-1
print("")
@WitherOrNot
WitherOrNot / lsystems.py
Last active January 9, 2020 20:02
Turtle that draws L-Systems
import turtle
t = turtle.Turtle()
s = turtle.Screen()
t.pu()
t.goto(0,0)
t.pd()
t.speed(0)
# mod here
@WitherOrNot
WitherOrNot / bf.py
Last active July 25, 2019 00:43
BrainFuck Interpreter
import sys
import time
import os
class _Getch:
"""Gets a single character from standard input. Does not echo to the
screen."""
def __init__(self):
try:
self.impl = _GetchWindows()
@WitherOrNot
WitherOrNot / hanoi.py
Last active August 30, 2020 19:46
Towers of Hanoi solver without recursion
import sys
import itertools
no_of_disks = int(raw_input("No. of disks: ")) if len(sys.argv) < 2 else int(sys.argv[1])
def disk_to_move(move_number):
diff = move_number ^ (move_number + 1)
return bin(diff)[2:].count("1") - 1
def generate_move(disk_to_move, disk_states):