Skip to content

Instantly share code, notes, and snippets.

Pekka Väänänen seece

  • Espoo, Finland
Block or report user

Report or block seece

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@seece
seece / pytorchraster.py
Last active Jan 9, 2019
A dumb triangle rasterizer with PyTorch.
View pytorchraster.py
import numpy as np
import matplotlib.pyplot as plt
from numpy import array
import torch
from torch import Tensor
"""
A dumb triangle rasterizer with PyTorch.
It evaluates the barycentrics for all image pixels for each triangle
and then picks the "colors" (just barycentrics again) for each pixel
@seece
seece / triangle.py
Last active Jun 16, 2018
NumPy triangle rasterizer
View triangle.py
import numpy as np
import matplotlib.pyplot as plt
from numpy import array
width = 100
height = 80
# The triangle
d = np.array([ [ [0.9, 0.5], [0.5, 0.8], [0.1, 0.15] ] ])
@seece
seece / tweak_values.inc
Created Mar 18, 2018
C++ tweak variable example.
View tweak_values.inc
// This file is automatically generated, but you can add your own variables here too.
// Syntax: SET_VAR(variable_name, default, low_limit, upper_limit, slider_exponent)
// In code you can read the variable with: GET_VAR(variable_name)
SET_VAR(tower_height, 520.0f, 0.0f, 3000.0f, 1.0f)
SET_VAR(KSpring, 520.0f, 1.0f, 3000.0f, 1.0f)
SET_VAR(WireRadius, 2.0f, 0.1f, 34.0f, 1.0f)
SET_VAR(volcanic_sun_x, 0.088000, -20.0f, 20.0f, 1.0f)
SET_VAR(mothership_sun_x, 2.026000, -5.0f, 5.0f, 1.0f)
SET_VAR(mothership_sun_y, 0.507000, -5.0f, 5.0f, 1.0f)
SET_VAR(wire_fog_exp, 0.0f, 0.0f, 100.0f, 1.0f)
@seece
seece / ebin
Created Jun 3, 2016
A terrible binary number printer
View ebin
#!/usr/bin/python
import sys
from ast import literal_eval
if len(sys.argv) != 2:
print "Usage: ebin INTEGER"
sys.exit(1)
s = "{0:08b}".format(literal_eval(sys.argv[1]))
n = 4 # split into 4 bit blocks
# awful reversing hack to get proper formatting
s = s[::-1]
@seece
seece / LAAMATUT.TXT
Created May 26, 2016
Laaman tie DJGPP-peliohjelmointiin versio 2.10. By Jokke / BAD KARMA
View LAAMATUT.TXT
▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄
█▓▒░ ░█ █▓▒░ ░▒▓▒█ █▒░ ░▒▓▒░ █ █░ ░▒▓▒░█ █▓▒░ ░▒▓█ █ ░▒▓▒░ ░▒█
█▒░ ░▒█ █▒░ ░▒▓▒░█ █░ ░▒▓▒░ ░█ █ ░▒▓▒░ █ █▒░ ░▒▓▒█ █░▒▓▒░ ░▒▓█
█░ ░▒▓█ █▒░ ░▒▓▒░ ░█ █░ ░▒▓▒░ ░▒▓█ █░▒▓▒░ ░▒█▒░ ░▒▓▒░█ █▒▓▒░ ░▒▓▒█
█ ░▒▓▒█ █░ ░▒▓▒░ ░▒█ █ ░▒▓▒░ ░▒▓▒█ █▒▓▒░ ░▒▓▒░ ░▒▓▒░ █ █▒▓▒░ ░▒▓▒░ █
█░▒▓▒░█ █ ░▒▓██ ░▒▓█ █░▒▓▒░██▒▓▒░█ █▓▒░ ░▒▓▒░ ░▒▓▒░ ░█ █▓▒░ ░██▒░ ░█
█▒▓▒░ █ █░▒▓▒██░▒▓▒█ █▒▓▒░ ██▓▒░ ░██▒░ ░▒█▒░ ░▒█▒░ ░▒█ █▒░ ░▒██░ ░▒█
█▓▒░ ░█ █░▒▓▒░██▒▓▒░ █▒▓▒░ ░██▒░ ░▒██░ ░▒▓█░ ░▒▓█░ ░▒▓█ █░ ░▒▓██ ░▒▓█
█▒░ ░▒█▄▄▄█▒▓▒░ ░▒▓▒░ ░█▓▒░ ░▒▓▒░ ░▒▓██ ░▒▓▒█ ░▒▓▒█ ░▒▓▒██░ ░▒▓▒░ ░▒▓▒░█
█░ ░▒▓▒░ ░▒▓▒░ ░▒▓▒░ ░▒▓▒░ ░▒▓▒░ ░▒▓▒░ ░▒▓▒░██▒▓▒██░▒▓▒░██ ░▒▓▒░ ░▒▓▒░ █
@seece
seece / ttrack.py
Created May 10, 2016
A "timetracker" "application"
View ttrack.py
import readline
import datetime
logpath = "times.txt"
lines = []
try:
with open(logpath, "r") as f:
lines = f.readlines()
except:
@seece
seece / nes_controller.pde
Created Jan 13, 2016
How to read NES controller button presses with an Arduino
View nes_controller.pde
/* This code is released into the public domain.
* Pekka Väänänen, 2016 */
/*
http://www.mit.edu/~tarvizo/nes-controller.html
+----> Power +5V (white)
|
5 +---------+ 7
| x x o \
@seece
seece / build.bat
Created Dec 7, 2015
Build MSVC2015 project
View build.bat
@echo off
REM Setup vcvars if they are not defined
if not defined DevEnvDir (
call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x86
)
call msbuild.exe /VERBOSITY:quiet /property:Configuration=Release solution.sln
echo done %date% %time%
@seece
seece / do.bat
Created Oct 27, 2015
ffmpeg and imagemagick - split video to frames and back
View do.bat
rem see https://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/image_sequence
ffmpeg -i "video.mp4" -vf -fps=14.985015 captures\out%04d.png
REM scale the frames and quantize to 24 color palette
for %%f in (%1\*.png) do ( E:\tools\imagemagick\convert.exe "%%f" -resize x144 -unsharp 0x1 -crop 160x144+48+0 -dither None -colors 24 -scale 300%% "%2\%%~nf.png" )
ffmpeg -framerate 14.985015 -i scaled\out%04d.png -crf 18 video.mp4
@seece
seece / compare.py
Created Mar 9, 2015
File byte distribution comparison
View compare.py
"""
compares the byte value distribution of the first argument with all the files in victims/
"""
from distr import calc_distribution
import os
import pickle
import sys
def dot(d1, d2):
You can’t perform that action at this time.