Skip to content

Instantly share code, notes, and snippets.

View pineapplemachine's full-sized avatar
🍍
Is a pineapple

Sophie Kirschner pineapplemachine

🍍
Is a pineapple
View GitHub Profile
@pineapplemachine
pineapplemachine / resolvePromisesInOrder.js
Created February 1, 2018 08:51
Resolve a list of promises serially, in order
// Accepts a list of promises. Returns a promise which evaluates each promise
// in the input list serially, waiting for each to resolve before beginning the
// next one. If any promise in the list is rejected, then so is the output
// promise with the same rejection value. If every promise is resolved, then
// the output promise resolves with a list of resolution values.
function resolvePromisesInOrder(promises){
const resultList = [];
const makePromise = (promise, nextPromise) => new Promise((resolve, reject) => {
promise.then(result => {
resultList.unshift(result);
@pineapplemachine
pineapplemachine / tm_hm_flag_analysis.py
Created January 22, 2018 12:45
Determine TM/HM learnset flag data from Emerald disassembly
"""
Written to determine from a subset of known examples a likely pattern for which flags in an Emerald disassembly pertained
to the ability to learn which TM/HM. With 23 examples taken from Bulbapedia pages I was able to find a pattern and extrapolate
with some confidence the purpose of flags that were not narrowed down to one possible TM/HM.
Due to either an error in my copying the reference TM/HM learnset data from Bulbapedia, or an error in the data itself, this
script interestingly and erroneously concludes that no flags could possibly correlate to TM12 (Taunt) or TM20 (Safeguard).
The discovered pattern was that the bits such as this one represented, *from right-to-left*, TMs 1-50 then HMs 1-8.
Or, from left-to-right: HMs 8-1 then TMs 50-1.
// Memory management tool
import mach.sys.memory : malloc, realloc, memfree;
struct Allocator(T, size_t PageSize = 512){
struct Page{
enum size = PageSize;
T[size] objects;
size_t[size] references;
@pineapplemachine
pineapplemachine / lisp.js
Last active October 5, 2017 10:07
Lisp implemented in JavaScript
/*
This is an implementation of a Lisp in JavaScript. It does not provide
a full suite of the built-in functions one might expect, but it
does represent a solid basis for a more complete implementation.
I prototyped this interpreter because I want to expose a scripting
language to users of a project I'm working on and Lisp seemed like a
good choice.
@pineapplemachine
pineapplemachine / palvisualizer.d
Created April 15, 2017 17:35
Palette coverage visualization tool
/// This program reads an image from the path "palette.png", finds every unique
/// color in the image, and outputs a visualization to "visualpal.png" which
/// visualizes palette coverage by using white to represent colors very closely
/// representable by colors in the palette and black to represent colors that
/// are relatively distant from any color in the palette.
/// Try it with your favorite palette, for example the NES palette!
/// https://upload.wikimedia.org/wikipedia/en/8/80/NES_palette_color_test_chart.png
/// Written using mach commit e1e9c781fc69fe92fa4c632352c601fdd9a62d18

Keybase proof

I hereby claim:

  • I am pineapplemachine on github.
  • I am pinemach (https://keybase.io/pinemach) on keybase.
  • I have a public key whose fingerprint is 1969 A5BB 8A03 8BE7 DD7C FC80 72D1 A9D4 F7EF 6B19

To claim this, I am signing this object:

@pineapplemachine
pineapplemachine / assertf.d
Created April 15, 2016 20:48
Assert using string formatting
/++
Written by Sophie Kirschner: sophiek@pineapplemachine.com
zlib/libpng license: https://opensource.org/licenses/Zlib
+/
module mach.error.assertf;
private:
import core.exception : AssertError;
@pineapplemachine
pineapplemachine / StarNamesText.py
Last active January 24, 2016 20:32
Quick script to generate a StarNamesText.xml file for GalCiv III using a more convenient input format
names = '''
One
Star
Name
Per
Line
Hello
World
'''
@pineapplemachine
pineapplemachine / brainfuck.d
Last active April 8, 2016 16:32
Brainfuck interpreter in D
/+
Author: Sophie Kirschner (sophiek@pineapplemachine.com)
License: Public domain
+/
import std.stdio;
/+
// Example usage