Skip to content

Instantly share code, notes, and snippets.

View Enichan's full-sized avatar

Emma Maassen Enichan

View GitHub Profile
@Enichan
Enichan / GridPather.cs
Last active December 14, 2015 21:49 — forked from anonymous/GridPather.cs
// This file created by Emma 'Eniko' Maassen
// Licensed under Creative Commons Attribution 3.0 Unported (CC BY 3.0)
// http://creativecommons.org/licenses/by/3.0/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace Indigo.Framework.Random {
@Enichan
Enichan / Resumable.cs
Last active September 22, 2020 06:44
An implementation of coroutines for C#.
#region License
/*
Copyright © 2014 Emma Maassen
This work is free. You can redistribute it and/or modify it under the
terms of the Do What The Fuck You Want To Public License, Version 2,
as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
*/
#endregion
using System;
using System.Collections.Generic;
@Enichan
Enichan / browser_gamepad_id.txt
Created October 19, 2018 04:48
Gamepad id output for various controllers/gamepads across browsers, with regexes for how to get name, vendor id, and product id
This is output from the gamepad API's id property tested across a variety of browsers, along with regular expressions to
find the name, vendor id, and product id.
Chrome: Logitech Dual Action (STANDARD GAMEPAD Vendor: 046d Product: c216)
Xbox 360 Controller (XInput STANDARD GAMEPAD)
Wireless Controller (STANDARD GAMEPAD Vendor: 054c Product: 05c4)
Sony PLAYSTATION(R)3 Controller (STANDARD GAMEPAD Vendor: 054c Product: 0268)
Pro Controller (Vendor: 057e Product: 2009)
8Bitdo SF30 Pro (Vendor: 2dc8 Product: 6000)
Firefox: 046d-c216-Logitech Dual Action
@Enichan
Enichan / CommandLineArguments.cs
Created December 28, 2018 21:39
Much better than using the built-in command line argument parsing.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
public static class CommandLineArguments {
/// <summary>
/// Parses command line arguments.
@Enichan
Enichan / P8Writer.cs
Last active January 21, 2020 10:53
Takes a byte[] array with binary data, and outputs that to the .p8 pico 8 cartridge format
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class P8Writer {
public const int RomSize = 0x4300;
@Enichan
Enichan / IDGenerator.cs
Last active November 7, 2019 17:11
Serves long identifiers in a threadsafe manner.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
namespace Franca {
[StructLayout(LayoutKind.Explicit)]
public struct IncrementalID : IEquatable<IncrementalID>, IComparable<IncrementalID> {
@Enichan
Enichan / collatz.lua
Last active July 31, 2021 03:10
Eniko Collatz Fizzle Fade, Pico 8 implementation
seed = 38
function txp1()
if seed == 1 then
return seed
elseif seed % 2 == 0 then
seed /= 2
else
seed = seed * 3 + 1
end
@Enichan
Enichan / main.c
Last active August 28, 2023 10:07
Coroutines for C using Duff's Device based on Simon Tatham's coroutines
// coroutines for C adapted from Simon Tatham's coroutines
// https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
//
// this implementation utilizes __VA_ARGS__ and __COUNTER__
// to avoid a begin/end pair of macros.
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
// modify this if you don't like the `self->name` format
@Enichan
Enichan / triangle.p8
Last active October 6, 2021 07:42
Subpixel accurate triangle rasterizer prototype for Pico 8
pico-8 cartridge // http://www.pico-8.com
version 18
__lua__
--[[function spline(x0,y0,x1,y1,c)
local dx = x1 - x0
local dy = y1 - y0
local step = dx/dy
local x = x0 - (y0 % 1) * step
local y = flr(y0)
@Enichan
Enichan / interpretoy.html
Last active December 16, 2021 21:38
Interpretoy: a toy lisp interpreter with REPL built in javascript
<html>
<head>
<title>Interpretoy REPL</title>
</head>
<body>
<script>
// based on lispy by Peter Norvig: http://norvig.com/lispy.html
function load(source) {