Skip to content

Instantly share code, notes, and snippets.

Avatar
🐳
~

James jaames

🐳
~
View GitHub Profile
View pathkit_with_webpack_5.md

PathKit's docs are out of date, and changes in Webpack 5 mean that their installation instructions don't work

Install the following from NPM:

  • pathkit-wasm
  • webpack 5
  • copy-webpack-plugin
  • node-polyfill-webpack-plugin

Make sure your Webpack config has the following:

@jaames
jaames / gbg_palette.txt
Created Jun 28, 2021
Game Builder Garage texture palette as hex rgba
View gbg_palette.txt
Game Builder Garage texture palette as hex rgba
// transparent
#00000000
// grays
#ffffffff
#edededff
#d9d9d9ff
#b5b5b5ff
@jaames
jaames / compileTemplate.ts
Created Jun 7, 2021
Tiny Typescript string template compiler
View compileTemplate.ts
// makes use of tagged template literals
const compileTemplate = (strings: TemplateStringsArray, ...expr: string[]) => {
return (replacements: Record<string, any>) => {
// convert ${'whatever'} instances to array of values
const values = expr.map(key => replacements[key] ?? key);
// rebuild string with replaced values
return strings.reduce((result, part, i) => result + part + (values[i] ?? ''), '');
}
}
@jaames
jaames / Sha256.ts
Created May 11, 2021
Tiny Typescript implementation of Sha256
View Sha256.ts
/**
* // hash content
* // content must be an uint8 typed array
* const hash = new Sha256();
* hash.update(content)
* // get digest as uint8 typed array
* const digest = hash.digest();
* // or get digest as hex string
* const hex = hash.hexDigest();
*/
@jaames
jaames / Crc32.ts
Last active Jun 14, 2021
Tiny Typescript implementation of CRC32
View Crc32.ts
const POLYNOMIAL = -306674912;
let crc32_table: Int32Array = undefined;
export function Crc32(bytes: Uint8Array, crc=0xFFFFFFFF) {
if (crc32_table === undefined)
calcTable();
for (let i = 0; i < bytes.length; ++i)
crc = crc32_table[(crc ^ bytes[i]) & 0xff] ^ (crc >>> 8);
return (crc ^ -1) >>> 0;
@jaames
jaames / Sha1.ts
Last active May 11, 2021
Tiny Typescript implementation of Sha1
View Sha1.ts
/**
* // hash content
* // content must be an uint8 typed array
* const hash = new Sha1();
* hash.update(content)
* // get digest as uint8 typed array
* const digest = hash.digest();
* // or get digest as hex string
* const hex = hash.hexDigest();
*/
@jaames
jaames / decode_kwz_filename.php
Last active Feb 1, 2021
Example PHP script to decode a KWZ filename
View decode_kwz_filename.php
<?php
function decode_filename(string $filename)
{
$bytes = base32_decode($filename);
// Convert to byte string
$bin = join('', array_map('chr', $bytes));
// Unpack data
// Hex FSID (9 bytes, 18 chars) | Creation timestamp (uint32) | Modified timestamp (uint32)
return unpack('H18fsid/Vcreated/Vmodified', $bin);
@jaames
jaames / fonts.md
Last active Apr 22, 2021
Cool free/cheap font foundries
View fonts.md
@jaames
jaames / ppm_filename_checksum.py
Last active Jul 21, 2020
Implementation of PPM filename checksum used when Flipnotes are saved into storage
View ppm_filename_checksum.py
checksum_dict = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def calc_check_digit(filename):
sumc = int(filename[0:2], 16)
for i in range(1, 16):
char = ord(filename[i])
sumc = (sumc + char) % 256
return checksum_dict[sumc % len(checksum_dict)]
def set_check_digit(filename):
@jaames
jaames / colors-beta-guide.md
Last active Jun 26, 2021
Colors Live Windows beta guide
View colors-beta-guide.md

Installing the Colors Live beta

The Windows beta is distributed through the Discord game library. To access it, head to the Colors Live Discord server, at the top of the channel list you should see a tag called Colors Live (Switch), click there, then click the Add to library button in the panel to the right.

Once the app has been added, go to your library by clicking the In Library header on the same panel. You should be able to install and launch the app from there!

Installing updates

To install an update, go to your Discord library and select the Colors Live beta. You may need to manually start the update install process by clicking the play button towards the top-right of the library page. One it has downloaded, you will be able to launch the app as normal.