This file contains 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 http.client | |
import random | |
def random_string(n): | |
return "".join(chr(random.randrange(128)) for i in range(n)) | |
def str_to_bin(text): | |
""" translates text to binary reprersentation using | |
7 bits per character. Non ASCII characters are discarded""" | |
return ''.join('{:07b}'.format(ord(ch)) for ch in text if ord(ch) < 128) |
This file contains 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
#! /usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
''' | |
The VerilogBits provides Verilog-style representation of the numbers. | |
Copyright (C) 2015 Jan Marjanovic <jan@marjanovic.pro> | |
This program is free software: you can redistribute it and/or modify | |
it under the terms of the GNU General Public License as published by |
This file contains 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
# Requires python-imaging on Ubuntu | |
import PIL.Image, random, time | |
class AlexRand(random.Random): | |
'''This replicates how PHP does randint()''' | |
def randint(self, a, b): | |
self.seed() | |
return super(AlexRand, self).randint(a, b) | |
image = PIL.Image.new("1",(512,512)) # Creates a 512x512 bitmap |
This file contains 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
# coding: utf-8 | |
# Python Bitmap (bmp) Image Negation (using module struct) | |
import struct | |
with open('in.bmp', 'rb') as fd, open('out.bmp', 'wb') as out: | |
s = fd.read(1) | |
count = 1 | |
while s: | |
if count < 37: # header bytes |
This file contains 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 random import random, seed | |
def debug_func(fn): | |
def new(*args, **kwargs): | |
print 'DEBUG: function call:', fn.func_name, args, kwargs | |
return fn(*args, **kwargs) | |
return new | |
#@debug_func | |
def octave(step, amp, bitmap, modifier): |
This file contains 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
#!/usr/bin/env python | |
import os | |
import glob | |
import shutil | |
import subprocess | |
#ffmepg parameters | |
# file sequence format | |
dstform = u'a{seq:08d}.png' # python style |
This file contains 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
rawData = "1111111000001001101111111100000101010011110100000110111010000010111010111011011101011101111001011101101110100100000010101110110000010110001110010000011111111010101010101111111000000000110001000000000011111011110001011101010101111100100111100000001010001110101010101111001000110001101000110111111010001011011011101010001010111111101010100010001010001110111110110010111111100111011000011101001001001001101110110100011111111110000000000100101001000101011111111010000010101010011100000100100000110001001110111010100111111111111101011101011111010011111011101110101010110100010000110000010101000011110100011111111011000100011101011" | |
header = b'\x42\x4D\x4C\x00\x00\x00\x00\x00\x00\x00\x1A\x00\x00\x00\x0C\x00\x00\x00' | |
dimension = b'\x19\x00\x19\x00\x01\x00\x18\x00' | |
white = b'\xFF\xFF\xFF' | |
black = b'\x00\x00\x00' | |
data = [] |
This file contains 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 collections import deque | |
try: | |
set() | |
except: | |
from sets import Set as set | |
This file contains 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
#!/usr/bin/python | |
""" Generates vectorpixels based on bitmaps (2 color pictures). | |
TODO: use element tree for XML; implement Floyd-Steinberg | |
dithering for color and greyscale images; implement vertical | |
and horiontal scanlines """ | |
import Image | |
from sys import argv | |
class vectorpixel: |