Skip to content

Instantly share code, notes, and snippets.

@kitlith
kitlith / 00_README.md
Last active November 12, 2022 07:41
Code used for generating twitter compatible PNGs based off of a bunch of video segments and an m3u8

This is the collection of code I wrote to upload 4k60 video to twitter.

The order of steps was as follows:

  1. Use ffmpeg to segment and/or re-encode video. The important part is to reduce the segments to under 5MB in size, each.
    • I used this command line: ffmpeg -y -i ..\bbb_sunflower_2160p_60fps_normal.mp4 -codec copy -bsf:v h264_mp4toannexb -map 0 -f segment -segment_time 0.1 -segment_list "bbb_4k.m3u8" -segment_list_type m3u8 "bbb-%d.ts"
    • This resulted in 1269 segments for me to handle.
  2. Use generate_file_packing.py to solve the bin packing problem for the set of segments. I set the bin size to 5MiB - 8KiB, knowing I had a 4KiB image for the cover file.
    • I used the DVD logo as my cover image, and set the second palette color for each one to hsv(pack_index, 255, 255)
  3. Use pack_segments.rs to generate png files packed according to the solution file generated by the previous step.
  • This resulted in 250 png files for me to upload to twitter
@kitlith
kitlith / layer_viz.py
Created January 30, 2021 01:13
Layer visualization. Requires the graphviz and pillow python libraries be installed, and graphviz itself installed
from collections import deque
from io import BytesIO
from itertools import islice
from graphviz import Graph
from PIL import Image
class Comparator:
def __init__(self, value: int, is_sub: bool):
# assert(type(value) is int)
@kitlith
kitlith / MixinLocale.java
Last active December 13, 2018 21:33
failed translation mixin
package pw.kitl.oldboosters.mixin;
import net.minecraft.client.resources.Locale;
import org.apache.logging.log4j.LogManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@kitlith
kitlith / something.rs
Created September 9, 2018 05:44
type-level abstractions for scroll
#![feature(try_from)] // for "anything that can be converted into usize"
extern crate scroll; // if you're not using the edition 2018 preview
use scroll::ctx::TryFromCtx;
use std::convert::TryInto;
use scroll::Pread;
struct LengthData<Data, Length>(Data, std::marker::PhantomData<Length>);
@kitlith
kitlith / client.py
Last active April 17, 2017 03:09
WIP Mitmproxy script(s) that implement request/response rewriting for unencrypted connections.
from rewrite import form_rewrite
rewrite_table = {
"http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi": {
"Comments": "placeholder"
}
}
def request(flow): # An example for using the form rewriter.
form_rewrite(flow, rewrite_table)
@kitlith
kitlith / sm-nooutlines.pco
Last active December 1, 2016 23:42
Sun & Moon corbenik patches
# $name Sun/Moon No Outlines patch (Loader)
# $desc Patches Sun/Moon to remove (annoying?) outlines.
# $title 0004000000164800 0004000000175E00
# $ver 01
# $uuid 0003
# Quick 'n dirty. Not dynamic.
# Original patch by SciresM.
rel exe_text
@kitlith
kitlith / 1-ntrcardhax.md
Last active August 1, 2020 19:22
Collection of Information about ntrcardhax

NTRCARDhax

This is in progress, and is by no means finished, fork and comment with a link to your changes and I'll update here. Information on the 3DS side should be about done. I still have questions, though, which would be nice to know the answers to.
My thoughts on implementing the gamecard side of things can be found here.

ARM9hax

ARM9 code uses REG_NTRCARDMCNT, at physical address 0x1016400 as a reference. ARM9 triggers reading by writing 4 bytes to 4 bytes after this address, REG_NTRCARDROMCNT. This is located at 0x10164004.