Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢
hi, I'm a turtle!

Peder Bergebakken Sundt pbsds

🐢
hi, I'm a turtle!
View GitHub Profile
@pbsds
pbsds / .remoteenv
Created Nov 2, 2020
A .remoteenv file to use with remote-cli when using poetry on a remote host you don't have sudo access to.
View .remoteenv
#!/usr/bin/env bash
MINICONDA_PY38_URL="https://repo.continuum.io/miniconda/Miniconda3-py38_4.8.2-Linux-x86_64.sh"
MINICONDA_PY38_HASH="879457af6a0bf5b34b48c12de31d4df0ee2f06a8e68768e5758c3293b2daf688"
# Assumes repo is put in a "remotes/NAME-HASH" folder
ENVIRON_NAME="py38_$(basename $(pwd))"
REMOTES_DIR="$(dirname $(pwd))"
export POETRY_VIRTUALENVS_IN_PROJECT=true
View class_init_decorator.py
# this is untested
from functools import wraps
from itertools import chain
def autoassign(init_method): # decorator
"""
@autoassign
def __init__(self, a: int, b: float):
pass
@pbsds
pbsds / scene.json
Last active Sep 2, 2020
RayGrounds Cornell scene expressed in JSON vs what it could have been using TOML
View scene.json
{
"settings": {
"depth": 3
},
"objects": [
{
"type": "quad",
"translate": [ 1, 0, 1 ],
"scale": [ 2, 2, 1 ],
"rotate": [ 0, 1, 0, -90 ],
View pvv quick setup.sh
#!/usr/bin/env bash
if ! test "$(whoami)" = "root"; then
echo "You're not running this as root"
exit 1
fi
INSTALL="apt-get install -y"
if type -P dnf >/dev/null 2>/dev/null; then INSTALL="dnf -y install"; fi
if type -P pacman >/dev/null 2>/dev/null; then INSTALL="pacman -S"; fi
@pbsds
pbsds / alu_hier.dg
Last active Sep 2, 2020
nmigen's ali_hier.py example dogelang
View alu_hier.dg
# TODO: imports, test, m.d.conf and m.d.sync
#from nmigen import *
#from nmigen.cli import main
# helpers:
DgModule = subclass Module where
If = cond body_func ~>
with @@If cond => body_func!
@pbsds
pbsds / install micro.sh
Last active Nov 16, 2018
Install sane Micro
View install micro.sh
#!usr/bin/env bash
if ! which micro > /dev/null; then
echo installing micro...
echo
cd ~
mkdir -p bin
cd bin
curl https://getmic.ro | bash
@pbsds
pbsds / bgmmd5.py
Last active Aug 29, 2015
Computes a md5 hash from the bgm data of a flipnote
View bgmmd5.py
import PPM, sys, hashlib, warnings
warnings.filterwarnings("ignore")#disables the futurewarnings from numpy, bad practice!
if len(sys.argv) < 2:
print "error, no ppm filepath provided"
sys.exit(1)
flip = PPM.PPM().ReadFile(sys.argv[1], ReadFrames=False, ReadSound=True)
if not flip.SoundData[0]:
print "No BGM"
else:
print hashlib.md5(flip.SoundData[0]).hexdigest()
@pbsds
pbsds / nbf.py
Last active May 25, 2017
Converts hatena's .nbf files to .png and back
View nbf.py
#written by pbsds
#quick and dirty, i may add this to UGO.py in Hatenatools
#
#This converter is licensed under AGPL3
#See http://www.gnu.org/licenses/agpl-3.0.html for more information
import sys, numpy as np, Image
def decode(input, output):
f = open(input, "rb").read()
len1 = np.fromstring(f[8:12], dtype=np.uint32)[0]
@pbsds
pbsds / Latency Simulator.py
Created Sep 18, 2014
This is something i made quick to get a feel of how a monitor with a certain input lag would feel like.
View Latency Simulator.py
import pygame
pygame.init()
pygame.display.set_caption("Mouse Latency Simulator - by pbsds")
pygame.font.init()
window = pygame.display.set_mode((1280, 720))
font = pygame.font.Font(None, 20)
pygame.mouse.set_visible(False)
@pbsds
pbsds / MapGenerator.py
Created May 9, 2013
A simple random map generator using seeding and growth to produce it's landmasses.
View MapGenerator.py
import Image, random, math
#Made by pbsds/Peder Bergebakken Sundt
#Requires PIL to work
Palette = (0x0045A0,#0 - Dark water
0x0059BC,#1 - Water
0x0078F9,#2 - Shore water
0xFFF65E,#3 - Sand
0x2BE81F,#4 - Grass
0x26B719,#5 - Dark Grass