Skip to content

Instantly share code, notes, and snippets.

View jaames's full-sized avatar
🐳
~

James jaames

🐳
~
  • UK, '97
  • 10:22 (UTC +01:00)
View GitHub Profile
@jaames
jaames / flipnote_studio_ui_strings.md
Created April 2, 2018 16:04
UI strings from Flipnote Studio for the Nintendo DSi

Message and layout text parsed from Flipnote Studio's .tbl and .bmg files.

Layout

Index ID Attr Message
0000 BackButton_BackButtonText 0x05 Back
0001 BackButton_SaveButtonText 0x05 Save
0002 BirthDay_BirthDayTitleDayText 0x06 Day
0003 BirthDay_BirthDayTitleMonthText 0x06 Month
@jaames
jaames / kwzSignature.py
Last active January 25, 2021 03:05
resign a kwz for flipnote studio 3d. handles signature and all crc32 checksums.
# usage: python3 kwzSignature.py <privkey.pem> <target.kwz>
# rsa module installed with:
# pip3 install rsa
# documentation here:
# https://stuvel.eu/files/python-rsa-doc/usage.html
import struct
import rsa
import zlib
@jaames
jaames / drawingimage.py
Last active January 25, 2021 03:05
python class for processing miiverse drawing images
from PIL import Image
SAMPLING_METHODS = {
"ANTIALIAS": Image.ANTIALIAS,
"BILINEAR": Image.BILINEAR,
"BICUBIC": Image.BICUBIC,
"NEAREST": Image.NEAREST
}
class drawingImage:
@jaames
jaames / thumbtool.py
Last active January 25, 2021 03:05
custom flipnote thumbnail tool
# Custom Flipnote (.ppm) Thumbnail Tool
# Create a ppm thumbnail from any 64 x 48 image
# Requires Pillow - https://github.com/python-pillow/Pillow
#
# By Jaames <github.com/jaames | @rakujira on twitter>
#
# Usage: python3 thumbtool.py input.ppm thumb.png
from PIL import Image
from sys import argv
@jaames
jaames / flipnoteThumbnailServer.js
Last active January 25, 2021 03:06
Node mini-server that extracts thumbnail images from Flipnote Studio PPM or KWZ animation files
// requires promise-fs, gm and flipnote.js and imagemagick
// npm i promise-fs gm flipnote.js
// https://imagemagick.org/index.php
const http = require('http');
const path = require('path');
const url = require('url');
const fs = require('promise-fs');
const flipnote = require('flipnote.js/dist/node');
const gm = require('gm').subClass({imageMagick: true});
@jaames
jaames / decode_kwz_filename.php
Last active February 1, 2021 11:28
Example PHP script to decode a KWZ filename
<?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 / dsi_browser_crash.html
Last active February 26, 2021 09:29
POC code that crashes the Nintendo DSi Browser on load (see https://rakujira.jp/dsi/crash.htm)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=256">
</head>
<body>
<div id="readout"></div>
<script type="text/javascript">
var readout = document.getElementById("readout");
<?php
class KwzParser {
protected $data = null;
protected $offset = 0;
protected $size = 0;
public $sections = [];
public $meta = null;
public $frameMeta = null;
@jaames
jaames / Sha1.ts
Last active May 11, 2021 10:02
Tiny Typescript implementation of Sha1
/**
* // 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 / Sha256.ts
Created May 11, 2021 10:03
Tiny Typescript implementation of Sha256
/**
* // 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();
*/