Skip to content

Instantly share code, notes, and snippets.

View bplaat's full-sized avatar
💻
Working on stuff

Bastiaan van der Plaat bplaat

💻
Working on stuff
View GitHub Profile
@bplaat
bplaat / .htaccess
Created December 30, 2021 17:27
Yet another single file PHP MVC framework
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ index.php [L]
@bplaat
bplaat / bulma-dark.min.css
Created December 11, 2021 17:01
Crude Bulma dark theme hack
.pagination-previous,.pagination-next,.pagination-link,.pagination-ellipsis,.file-cta,.file-name,.select select,.textarea,.input,.button{-moz-appearance:none;-webkit-appearance:none;align-items:center;border:1px solid transparent;border-radius:4px;box-shadow:none;display:inline-flex;font-size:1rem;height:2.5em;justify-content:flex-start;line-height:1.5;padding-bottom:calc(0.5em - 1px);padding-left:calc(0.75em - 1px);padding-right:calc(0.75em - 1px);padding-top:calc(0.5em - 1px);position:relative;vertical-align:top}.pagination-previous:focus,.pagination-next:focus,.pagination-link:focus,.pagination-ellipsis:focus,.file-cta:focus,.file-name:focus,.select select:focus,.textarea:focus,.input:focus,.button:focus,.is-focused.pagination-previous,.is-focused.pagination-next,.is-focused.pagination-link,.is-focused.pagination-ellipsis,.is-focused.file-cta,.is-focused.file-name,.select select.is-focused,.is-focused.textarea,.is-focused.input,.is-focused.button,.pagination-previous:active,.pagination-next:active,.paginat
@bplaat
bplaat / dl.js
Created November 19, 2021 14:00
Simple Deno application that list Deezer album information
#!/usr/bin/env deno run --allow-net
import { parse } from "https://deno.land/std/flags/mod.ts";
const httpGetJson = async (url) => await (await fetch(url)).json();
const args = parse(Deno.args);
if (args._.length == 0) {
console.log('Give an album name!');
Deno.exit();
@bplaat
bplaat / dl.py
Created November 19, 2021 08:57
Multithreaded youtube video music downloader with nice ansi progress bars
import math, os, re, subprocess, sys, tempfile, threading
size = os.get_terminal_size()
cursorY = 0
def printLine(y, line):
global cursorY
if (y <= cursorY):
sys.stdout.write('\033[F' * (cursorY - y))
if (y > cursorY):
@bplaat
bplaat / plaatlight.php
Created August 17, 2021 15:37
PlaatLight
<?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="plaatlight"');
}
if ($_SERVER['PHP_AUTH_USER'] != 'plaatlight' || $_SERVER['PHP_AUTH_PW'] != 'plaatlight') {
header('HTTP/1.1 401 Unauthorized');
echo 'Not authorized';
exit;
@bplaat
bplaat / build.sh
Created July 16, 2021 08:16
Kora Reincranation: simple RISC-V 32IM core simulator in C
rm -rf .vscode
if gcc -s -Os kora.c -o kora -lelf; then
./kora $(find riscv-tests/isa -name "rv32ui-p-*")
fi
@bplaat
bplaat / heap.c
Created May 26, 2021 06:05
A very bad but simple heap memory allocater
// Simple heap implemtation in C99 inspired by dlmalloc point structure
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
// The heap structure
#define DEBUG
typedef struct Heap {
uint8_t* data;
@bplaat
bplaat / systembar.c
Created February 2, 2021 08:30
Win32 macOS like systembar experiment
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define UPDATE_TIMER 1
int barHeight = 32;
COLORREF backgroundColor = RGB(142, 68, 173);
COLORREF fontColor = RGB(255, 255, 255);
char *fontName = "Segoe UI";
int fontSize = 19;
@bplaat
bplaat / sdl-test.cpp
Created November 16, 2020 11:42
A SDL2 C++ test app
// g++ -s -Os sdl-test.cpp -lSDL2 -o sdl-test && ./sdl-test
#include <SDL2/SDL.h>
#include <memory>
#include <functional>
#include <iostream>
int main(void) {
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
std::cerr << "[ERROR] Can't init SDL: " << SDL_GetError() << std::endl;
@bplaat
bplaat / demo3.ino
Created September 4, 2020 12:16
Introductieweek 2020-2021 - Arduino Presentatie - Demo 3
// DEMO 3 - De afstand sensor
// Laad servo bibliotheek
#include <Servo.h>
// De pins
#define ECHO_PIN 2
#define TRIGGER_PIN 3
#define SERVO_PIN 9