Skip to content

Instantly share code, notes, and snippets.

View adamnew123456's full-sized avatar

Chris Marchetti adamnew123456

  • Chapel Hill, NC
View GitHub Profile
@adamnew123456
adamnew123456 / parametric.html
Created December 2, 2014 17:23
A Simple Parametric Equation Grapher
<html>
<title> Equation Mixer </title>
<body>
<canvas id="grid" width="600" height="600"> </canvas> <br/>
x(t): <input id="func_x" type="text" value="Math.sin(t)"> </input>
y(t): <input id="func_y" type="text" value="Math.cos(t)"> </input> <br/>
X Min: <input id="xmin" type="text" value="-1"> </input>
X Max: <input id="xmax" type="text" value="1"> </input> <br/>
@adamnew123456
adamnew123456 / mop.js
Last active August 29, 2015 14:11
A Javascript Meta-Object System, Modelled On Python's OO
/**
* A small meta-object protocol for describing a Python-like class system in
* Javascript.
*
* In this MOP, objects are (at bottom) represented as a mapping of three things:
*
* - a list of parent classes
* - a list representing the object's MRO
* - a mapping of attribute names to attributes
*
@adamnew123456
adamnew123456 / curses.js
Last active January 19, 2024 00:08
A Small Javascript Library For Emulating Curses
/**
* An implementation of an API similar to ncurses, but which instead runs on
* HTMl5 canvas.
*
* Specifically, this is designed to duplicate the following elements of ncurses:
*
* - Basic text printing
* - Colors
* - Handling window hierarchies, which respect their parents bounds (so that
* drawing doesn't occur outside of a window's boundaries). They have their own
@adamnew123456
adamnew123456 / pyc.py
Last active October 31, 2023 11:39
Using Inline C Code In Python Programs
"""
Inserts C code directly into Python files, which can then be dynamically linked
in and called via ctypes.
"""
import atexit
import ctypes
import os
import shlex
import sys
import tempfile
@adamnew123456
adamnew123456 / dispatchmethod.py
Last active May 15, 2020 15:37
dispatchmethod - Using functools.singledispatch For Methods
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
@adamnew123456
adamnew123456 / wikiword.py
Created January 5, 2015 17:00
WikiWord - A Static Wiki-Like Site Generator
"""
Converts a tree of wiki pages into a tree of HTML pages.
"""
from collections import defaultdict
import configparser
import glob
import itertools
import os, os.path
import re
import shutil
@adamnew123456
adamnew123456 / arithmetic.py
Last active February 11, 2024 15:49
Pratt Parser For Arithmetic Expressions
"""
This implements a fairly simple expression language via a Pratt-style parser.
The language supports fairly standard floating point literals, such as:
5
1.09
.16
12e7
@adamnew123456
adamnew123456 / usm
Created April 5, 2015 17:28
USM Fix
#!/bin/sh
set -u
USAGE='Usage: usm COMMAND ...
usm help
usm init
usm copy-script
usm add SOFTWARE VERSION
usm set-current SOFTWARE VERSION
<canvas id="canvas" width="600" height="600">
</canvas> </br>
Method: <input id="algorithm" type="text"> </input> <br/>
Timestep (Hz): <input id="timestep" type="text"> </input> <br/>
<input id="start_stop" type="button" value="Start" onclick="run()"> </input> <br/>
<script>
////////////////////
var PERSON_RADIUS = 1;
var PERSON_SPEED = 5;
@adamnew123456
adamnew123456 / fizzbuzz.s
Created May 13, 2015 20:59
FizzBuzz In x86 Assembly
// FizzBuzz in x86 assembly - written on 32-bit Linux using the GNU ASsembler
.data
FIZZSTR:
.asciz "Fizz"
BUZZSTR:
.asciz "Buzz"
NEWLINE:
.asciz "\n"
// strtoa stores its data here. Since FizzBuzz runs 1-100, it won't need more than 3 bytes