Skip to content

Instantly share code, notes, and snippets.

@SuperDoxin
SuperDoxin / hello_world.usm
Last active December 27, 2015 06:19
Universal Machine
;temp: F
write A >data
write F >exit
write C >loop ;constant
write D 1 ;constant
write E 0 ;constant
loop: index F E A
out F
@SuperDoxin
SuperDoxin / logo.py
Last active November 25, 2022 22:57
Python Logo using bezier curves and the turtle module
import turtle
import math
def lerp(a, b, t):
"""Linear interpolation function. returns a when t==0, returns b when t==1
and linearly interpolates for values inbetween"""
return (a * (1 - t)) + (b * t)
@SuperDoxin
SuperDoxin / scope.py
Last active August 29, 2015 14:02
quick and dirty x/y osciloscope for playing audio files such as https://www.youtube.com/watch?v=o4YyI6_y6kw
"""
Usage:
scope.py <input_file>
"""
from __future__ import division
import pygame
import audiotools
from docopt import docopt
import itertools
import time
@SuperDoxin
SuperDoxin / tutorial.lua
Created June 10, 2014 17:39
lua script to show a very basic tutorial in The Powder Toy
function lerp(a,b,t)
return {(a[1]*(1-t))+(b[1]*t),(a[2]*(1-t))+(b[2]*t)}
end
function bezier(p0,p1,p2,p3,t)
local p4=lerp(p0,p1,t)
local p5=lerp(p2,p3,t)
local p6=lerp(p4,p5,t)
return p6
end
@SuperDoxin
SuperDoxin / test.fragment.glsl
Last active August 29, 2015 14:05
attempt at python/sdl/opengl3
#version 330 core
in vec2 pos;
out vec4 color_out;
void main()
{
color_out=vec4(1.0,0.0,0.0,1.0);
}
import kassa
import inspect
import pytest
import random
def test_classes():
assert inspect.isclass(kassa.Product)
def test_getprice():
p=kassa.Product(name="TestProduct",prijs=4.80,barcode="0001234567017")
import pygame
pygame.init()
screen=pygame.display.set_mode((640,480))
while True:
for event in pygame.event.get():
if event.type==pygame.QUIT:
raise SystemExit()
@SuperDoxin
SuperDoxin / split.py
Created August 30, 2014 19:22
split an email file into months and clean it up in general
import codecs
import os.path
import sys
import json
import email.parser
import email.generator
import parsedatetime.parsedatetime as pdt
import cStringIO as StringIO
import time
#import parsedatetime.parsedatetime_consts as pdc
from __future__ import division
from collections import namedtuple
import pygame
import math
import numpy as np
W,H=640,480#screen resolution
DIST=10#distance of the horizon
Y_SHIFT=200#how much to shift the plane down
Y_UNDU=100#how much to undulate the plane up and down
@SuperDoxin
SuperDoxin / game_of_life.py
Last active June 17, 2019 15:00
game of life
#!/usr/bin/python3
import numpy
from functools import reduce
import time
# I am terribly sorry for what is about to follow
initial_state = "random" # possible values: glider, random
if initial_state == "glider":