Skip to content

Instantly share code, notes, and snippets.

@timw4mail
timw4mail / openrc-build.log
Created May 7, 2024 14:29
OpenRC build.log
 * Package: sys-apps/openrc-0.54:0
 * Repository: gentoo
 * Maintainer: [email protected]
 * USE: abi_x86_32 debug elibc_glibc kernel_linux netifrc pam sysvinit unicode x86
 * FEATURES: network-sandbox preserve-libs sandbox userpriv usersandbox
 * Package: sys-apps/openrc-0.54:0
 * Repository: gentoo
 * Maintainer: [email protected]
 * USE: abi_x86_32 debug elibc_glibc kernel_linux netifrc pam sysvinit unicode x86
 * FEATURES: network-sandbox preserve-libs sandbox userpriv usersandbox
@timw4mail
timw4mail / colors.ts
Created January 10, 2024 20:57
256 color terminal demo
export enum Ground {
Fore = 38,
Back = 48,
}
const code = (
param: string | number | string[] | number[],
suffix: string = '',
): string => {
if (Array.isArray(param)) {
@timw4mail
timw4mail / index.php
Created June 2, 2023 14:32
One file procedurally generated game map, based on https://stitcher.io/blog/procedurally-generated-game-in-php
<?php declare(strict_types=1);
// ----------------------------------------------------------------------------
// Biomes
// ----------------------------------------------------------------------------
namespace Biome {
use Pixel;
interface Biome
@timw4mail
timw4mail / Base2Unit.php
Last active November 11, 2022 15:02
PHP 8.1+ Unit Formatter
<?php declare(strict_types=1);
enum Base2Unit: int implements UnitInterface {
case B = 1024**0;
case KB = 1024**1;
case MB = 1024**3;
case GB = 1024**4;
case TB = 1024**5;
case PB = 1024**6;
@timw4mail
timw4mail / GetSetTrait.php
Created October 14, 2022 16:08
A trait for removing Doctrine Boilerplate
<?php declare(strict_types=1);
namespace App\Entity;
use InvalidArgumentException;
/**
* Remove the need for all the Doctrine getter/setter Entity boilerplate
*/
trait GetSetTrait {
@timw4mail
timw4mail / GetLibrary.graphql
Created December 30, 2020 17:27
Kitsu Library GraphQL Query
query (
$slug: String!,
$type: MediaTypeEnum!,
$status: [LibraryEntryStatusEnum!],
$after: String
) {
findProfileBySlug(slug: $slug) {
library {
all(first: 100, after: $after, mediaType: $type, status: $status) {
pageInfo {
@timw4mail
timw4mail / index.php
Last active November 12, 2020 02:13
Image Viewer
<!DOCTYPE html>
<html>
<head>
<title>Image Viewer</title>
<style>
* {margin: 0}
img {
max-width: 100%;
<?php if (empty($_GET['zoom'])): ?>
max-height: 900px;
@timw4mail
timw4mail / kernel-update.sh
Created February 28, 2020 21:03
Gentoo Grub2 on OpenFirmware (PowerPC) New Kernel Update Script
#!/bin/bash
set -euo pipefail
# Adapted from: https://wiki.gentoo.org/wiki/GRUB_on_Open_Firmware_(PowerPC)
# Re-generate grub.cfg
grub-mkconfig -o /boot/grub/grub.cfg
# Make new OF grub img
grub-mkimage --prefix=/boot/grub --format=powerpc-ieee1275 --config=/boot/NWBB/grub-initial.cfg --output=/boot/NWBB/grub.img `cat /boot/NWBB/grub_mod-minimal.list`
@timw4mail
timw4mail / json-parser.js
Last active January 19, 2021 12:49
Pure JS JSON Parser
/**
* Pure JS JSON Parser
*
* @see https://lihautan.com/json-parser-with-javascript/
* @param {string} str
*/
function parseJSON(str) {
let i = 0;
const value = parseValue();
@timw4mail
timw4mail / optimize-images.sh
Last active January 24, 2020 01:41
Image Optimization script
#!/usr/bin/env bash
set -euo pipefail
declare threads=`getconf _NPROCESSORS_ONLN`
optimise () {
declare -a exts=("${!1}")
declare msg=$2
for ext in ${exts[@]}