Skip to content

Instantly share code, notes, and snippets.

View Cxarli's full-sized avatar
🔓
'; DROP TABLE bugs --

Charlie Cxarli

🔓
'; DROP TABLE bugs --
View GitHub Profile
@Cxarli
Cxarli / enum.php
Created August 9, 2018 22:17
Enum implementation in PHP
<?php
abstract class Enum {
private static $cache = [];
// Helper function to load the required fields into the cache.
private static function loadCache(): void {
// Create cache for enum
self::$cache[static::class] = [];
// Get all constants
@Cxarli
Cxarli / indexer.c
Created February 2, 2019 13:00
Make a single file with the filesize, name and modification time of all files in the given directory
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#!/usr/bin/env bash
set -eu
set -o pipefail
IFS=$'\n'
source="$HOME/i3"
output="${1:-$HOME/.config/i3/config}"
@Cxarli
Cxarli / colorise.py
Created June 19, 2021 16:21
Take a random image and replace all distinct colours with a random other colour
"""Take a random image and replace all distinct colours with
a random other colour
:arg infile: The source image to read from
:arg loop: Whether to loop the list of colours instead of only replacing the N first
:arg upper: The upper bound of colours to replace
"""
from PIL import Image
from collections import defaultdict
@Cxarli
Cxarli / file-indexer.c
Last active October 24, 2021 18:56
A little script to write an index of all files in the current directory
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>