Skip to content

Instantly share code, notes, and snippets.

View Demindiro's full-sized avatar
🦆
🦀

David Hoppenbrouwers Demindiro

🦆
🦀
View GitHub Profile
@Demindiro
Demindiro / netlogin.py
Last active February 21, 2019 11:36
A script to automatically login for Kotnet
#!/usr/bin/env python3
# Autologin for Kotnet
# Copyright (C) lololol
# This file is licensed under the AGPLv3
import requests
import re
from config import *
#!/usr/bin/env python3
def print_heap(l, lim=None):
lim = lim if lim else len(l)
for i in range((lim - 2) // 2 + 1):
m = i * 2 + 1
n = i * 2 + 2
d, k = 0, i + 1
@Demindiro
Demindiro / outline.shader
Last active October 7, 2021 21:51
2D outline shader
// Adapted from https://github.com/steincodes/godot-shader-tutorials/blob/master/Shaders/outline.shader
shader_type canvas_item;
render_mode unshaded;
uniform int size : hint_range(0,10);
uniform float precision : hint_range(0,1);
uniform vec4 outline_color : hint_color;
varying vec2 o;
@Demindiro
Demindiro / tictactoe.py
Created October 7, 2021 21:50
Simple text-based Tic Tac Toe implementation. I have no idea why I made this.
#!/usr/bin/env python3
# tictactoe by David Hoppenbrouwers
#
# To the extent possible under law, the person who associated CC0 with
# David Hoppenbrouwers has waived all copyright and related or neighboring rights
# to David Hoppenbrouwers.
#
# You should have received a copy of the CC0 legalcode along with this
# work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
@Demindiro
Demindiro / sudoku
Last active October 15, 2021 18:31
Simple sudoku solver written in Rust
___ ___ __6
__6 _2_ 7__
789 45_ 1_3
___ 8_7 __4
___ _3_ ___
_9_ __4 2_1
312 97_ _4_
_4_ _12 _78
@Demindiro
Demindiro / rbtest.py
Last active October 23, 2021 23:16
Red-Black tree fuzzy tester
#!/usr/bin/env python3
TEST_ELEM_COUNT = 20
TEST_FAILED_FILE = 'rbtest_failed.txt'
import random, sys, traceback, ast
import rb # Pas aan indien nodig
@Demindiro
Demindiro / bintree.hs
Created November 26, 2021 15:22
BST in Haskell
module BinTree where
data BinTree k v = BinTree { key :: k
, value :: v
, left :: Maybe (BinTree k v)
, right :: Maybe (BinTree k v) }
deriving (Show)
insert :: (Ord k) => k -> v -> Maybe (BinTree k v) -> Maybe (BinTree k v)
insert k' v' Nothing = Just $ BinTree k' v' Nothing Nothing
@Demindiro
Demindiro / assembler.py
Created November 27, 2021 23:21
Simple assembler for 12-bit data, 13-bit insrtuction ISA
una_ops = {
'not': 0b0001,
'inv': 0b0010,
'sll': 0b0011,
'srl': 0b0100,
'sla': 0b0101,
'sra': 0b0110,
'cp' : 0b0110,
}
@Demindiro
Demindiro / generate.sh
Last active August 15, 2022 13:36
Simple static site generator. Licensed under the CC0 so do whatever you want.
#!/usr/bin/env bash
for file in `find . -name '*.md'`; do
output=${file::-3}.html
if [[ `date -r "$file" "+%s"` -le `date -r "../$output" "+%s"` ]]
then
echo "Skipping $file"
continue
fi
mkdir -p ../$(dirname $output)
@Demindiro
Demindiro / algo.js
Created January 7, 2022 05:39
high-speed-chase-web
let weights = [0,1,2, 3,4,5, 6,7];
let centerWidth = 0;
let left = -1;
let right = 1;
//if (Math.min(scanArray.slice(8-centerWidth,9+centerWidth)) > 15) {
if (scanArray[8] > 15 && Math.min(scanArray[7],scanArray[9],) > 10) {
return 0;
}