Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Demindiro's full-sized avatar
🦆
🦀

David Hoppenbrouwers Demindiro

🦆
🦀
View GitHub Profile
@Demindiro
Demindiro / init_react_electron.sh
Last active October 20, 2022 18:50
There's quite a few posts explaining how to set up a React + Electron app but somehow I couldn't find a single-file script to just set up something.
#!/usr/bin/env bash
# https://mmazzarolo.com/blog/2021-08-12-building-an-electron-application-using-create-react-app/
set -ex
if [ $# != 1 ]
then
echo "Usage: $0 <path>" >&2
exit 1
@Demindiro
Demindiro / lz4_decode.py
Last active September 30, 2022 18:05
Python script implementing decoder for LZ4 block format. License: 0BSD
import lz4.block
f = open('lz4_Block_format.md', 'rb').read()
e = lz4.block.compress(f, compression=12, store_size=False)
d = [0] * len(f)
i = k = 0
while i < len(e):
def get_len(l):
@Demindiro
Demindiro / curseforge_modpack_dl.py
Last active July 18, 2022 22:43
Mods downloader for CurseForge modpacks. CC0 so dowhatever you want
# Hacky script because I can't be arsed with both CF's bullshit
# Instructions:
# - Download modpack from CurseForge's website
# - Unzip
# - Run this script in the unzipped folder (manifest.json and modlist.html should be present)
# - Copy mods/ (& overrides/ maybe) folder wherever
import json, os, cloudscraper
@Demindiro
Demindiro / Cargo.toml
Created July 17, 2022 08:55
Silly program that replaces a string in a MPV process.
[package]
name = "hello_world"
version = "0.1.0"
edition = "2021"
[dependencies.procfs]
version = "0.13"
@Demindiro
Demindiro / media_http.py
Created June 25, 2022 19:46
Simple HTTP server for extension-less images. CC0 so do whatever you want.
#!/usr/bin/env python3
from http.server import HTTPServer, BaseHTTPRequestHandler
import magic, os
class MediaHandler(BaseHTTPRequestHandler):
def do_GET(self):
if '..' in self.path:
self.send_response(403)
self.end_headers()
@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;
}
@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 / 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 / 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 / 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