Skip to content

Instantly share code, notes, and snippets.

View reececomo's full-sized avatar
🍊
Working on something cool

Reece Como reececomo

🍊
Working on something cool
View GitHub Profile
@reececomo
reececomo / audiospriteAsset.ts
Created June 19, 2024 11:16
Import audio sprite assets with @pixi/sound. For use with audiosprite / assetpack-plugin-audiosprite.
import { Sound, utils, sound } from '@pixi/sound';
import { Loader, ExtensionType, LoaderParserPriority } from 'pixi.js';
/** JSON file 'jukebox' format (the default format emitted by audiosprite) */
export interface AudiospriteJson {
resources: string[];
spritemap: Record<string, { start: number, end: number, loop?: boolean }>;
}
@reececomo
reececomo / SpritesheetAnimation.ts
Created June 14, 2024 12:29
Quickly generate spritesheet animations in PixiJS
import { AnimatedSprite, Assets, IPointData } from 'pixi.js';
/**
* A simple way to load animations.
*/
export class SpritesheetAnimation extends AnimatedSprite {
public constructor(name: string, {
autoPlay = false,
autoUpdate = true,
updateAnchor = false,
@reececomo
reececomo / sortObject.ts
Last active June 14, 2024 11:37
Sort an object in place or by copy (TypeScript/JavaScript)
// JavaScript versions at the bottom
// ----- TypeScript: -----
type ObjectCompareFn = (a: string, b: string) => number;
/** Sorts an object in place */
export function sortObject<T extends object>(obj: T, compareFn?: ObjectCompareFn): T {
Object.keys(obj).sort(compareFn).forEach(key => {
type Buffer = Uint8Array; // `Buffer` needs to be polyfilled in non-Node environments.
declare module "js-binary" {
export class Data {
constructor(capacity: number);
appendBuffer(data: Buffer): void;
writeUInt8(value: number): void;
writeUInt16(value: number): void;
writeUInt32(value: number): void;
import Foundation
/**
Simple fixed-size ring buffer / circular queue data structure.
This basic implementation uses an array under the hood.
Maintains a Write Queue and a Read Queue. Does not prevent "lapping" of the read/write queues.
*/
class RingBuffer<Element> {
@reececomo
reececomo / PrintBluepillJUnitResults.py
Created July 5, 2019 06:55
Print Bluepill JUnit Results to console
##
# Print JUnit Test Results.
#
# - Description: Only prints iOS-formatted results (AllTests > Suites > Subsuites > Cases).
#
# - Usage:
# - `python3 PrintBluepillJUnitResults.py <XML file>`
#
# - Arguments:
# - JUnit results XML file