Skip to content

Instantly share code, notes, and snippets.

View hikari-no-yume's full-sized avatar
🌟
trying to save beautiful things

hikari_no_yume hikari-no-yume

🌟
trying to save beautiful things
View GitHub Profile
@hikari-no-yume
hikari-no-yume / !summary.md
Last active July 29, 2020 12:05
GG2 CRLF versus LF

See Gang-Garrison-2/Gang-Garrison-2#242 for background.

GG2 repository as of Gang-Garrison-2/Gang-Garrison-2 master@4747a8b. Using macOS with clean repository, core.autocrlf=false.

CRLF files:

$ find * -type f -print0 |xargs -0 dos2unix -ic | wc -l
     328

LF files:

for (let i = 0; i < 12; i++) {
let elem = document.createElement('div');
elem.textContent = 'cache';
elem.style.textAlign = 'center';
elem.style.borderBottom = '1px solid';
elem.style.font = (10 ** (1 + i / 12)) + 'pt sans-serif';
document.body.appendChild(elem);
}
@hikari-no-yume
hikari-no-yume / glob.php
Created May 25, 2019 09:33
makes a directory listing
#!/usr/bin/env php
<?php declare(strict_types=1);
$glob = glob($argv[1] ?? "*");
echo "<!doctype html>";
echo "<meta charset=utf-8>";
echo "<body style=\"font-family: monospace;\">";
echo "<ul>";
foreach ($glob as $blob) {
@hikari-no-yume
hikari-no-yume / taxrates.php
Last active March 13, 2019 21:45
Calculate UK or Scottish income tax and find the point where one costs more than the other (https://twitter.com/hikari_no_yume/status/1105922831626502147)
<?php
const UK_2018 = [
0 => 11850,
20 => 46350,
40 => 150000,
45 => INF,
];
const UK_2019 = [
0 => 12500,
@hikari-no-yume
hikari-no-yume / loader.js
Last active September 3, 2017 17:23
wao
function load(stuffs, ondone) {
var loaded = {};
var loadedCount = 0;
stuffs.forEach(function (src, i) {
var img = document.createElement('img');
img.onload = function () {
loaded[src] = img;
loadedCount++;
if (loadedCount === stuffs.length) {
ondone(loaded);
@hikari-no-yume
hikari-no-yume / optimise.php
Last active February 11, 2019 17:16
Circular avatar optimiser: blacks out 16×16 blocks outside the circle (see: https://hikari.noyu.me/blog/2017-07-30-optimising-circular-avatars.html)
<?php declare(strict_types=1);
if ($argc !== 3) {
die("Usage: php optimise.php input.jpeg output.jpeg" . PHP_EOL);
}
$infile = $argv[1];
$outfile = $argv[2];
$img = imageCreateFromJPEG($infile);
@hikari-no-yume
hikari-no-yume / example.php
Created March 20, 2017 20:02
function chaining for PHP 7
<?php declare(strict_types=1);
require_once "✨.🐘";
✨($_)->strlen("foo")->var_dump($_);
@hikari-no-yume
hikari-no-yume / lesson.txt
Last active February 20, 2017 21:26
Advanced Japanese Lesson: #1
我 - I
我が - my
我がの - My
我がのな - Ours
我がのなの - Are you mine?
我がのなのは - Our nation is
我がのなのはん - My nakedness
我がのなのはんて - In my opinion
我がのなのはんてね - Do not be mine
我がのなのはんてねだ - It is my mind
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,<?=strtoupper(bin2hex(random_bytes(16)));?>
<?=wordwrap(base64_encode(random_bytes(2388)), 64, "\n", true);?>
-----END RSA PRIVATE KEY----
@hikari-no-yume
hikari-no-yume / Makefile
Last active November 19, 2016 21:24
Minimal Famicom assembly example using cc65 which (in PAL mode only, apparently?) flips the screen colour every 256 frames
game.nes: game.o
ld65 -C nrom128.x game.o -o game.nes
game.o: game.s
ca65 game.s -o game.o
clean:
rm *.o *.nes