Skip to content

Instantly share code, notes, and snippets.

View eparadis's full-sized avatar
💭
getting things done

Ed Paradis eparadis

💭
getting things done
View GitHub Profile
@eparadis
eparadis / fractal_tree_2.py
Created January 25, 2015 23:02
draw a fractal tree in Pythonista for iOS
import canvas
import math
branches_drawn = 0
def along( start, direction, fraction):
'''return a start point fraction amount in direction'''
newstart = ( start[0] + fraction * direction[0] * math.sin(direction[1]),
start[1] + fraction * direction[0] * math.cos(direction[1]) )
return newstart
@eparadis
eparadis / tracking-lookup-table-creating-code.md
Created June 10, 2017 08:18
Ginko Synthese Grains eurorack module 1v/oct lookup table generator (originally http://www.ginkosynthese.com/uploads/tracking-lookup-table-creating-code.doc)

The code below is written in C++ to create a lookup table for the grains for 1V/oct tracking

based on a linear PWM frequency of 31.25KHz, 32.70 is choosen as lowest frequency (C), 65536=2^16 is max pulsewidth on 31.25KHz, pow(x,y) is x^y pow(2,f) creates the exponential value of 0V to 5V in 1024 steps pow(2,0) = 1 generates a value of 32.50Hz pow(2,1) = 2 generates 32.50 * 2 = 65 Hz etc.

@eparadis
eparadis / hexdump.bas
Last active June 26, 2019 07:30
formatted hex dump of an area of memory in BASIC
5 INPUT "offset (dec) "; F
10 FOR I = 0 TO 255 STEP 16
11 IF I+F<16 THEN PRINT "0";
12 IF I+F<256 THEN PRINT "0";
13 IF I+F<4096 THEN PRINT "0";
15 PRINT HEX$(I+F);" ";
20 FOR J = 0 TO 15
25 V = PEEK(I+J+F)
27 IF V < 16 THEN PRINT "0";
30 PRINT HEX$(V);
@eparadis
eparadis / extensible_basic.md
Last active May 15, 2021 05:11
A modified BASIC designed to support language extensions

Extensible BASIC

A modified BASIC designed to support language extensions

6/12/2019

The common BASIC dialect on home computers of the 1970s and 1980s is Microsoft BASIC 4.7 or very similar. Generally speaking, the dialect supports a single user-defined FCN() which allows for a user defined expression with a single input parameter. Occasionally it will support machine-code methods with USR().

@eparadis
eparadis / sector_forth_boot.f
Created October 15, 2021 00:22
All the examples from sector forth concatenated, trimmed, and immediate executions removed. The idea is that this is what you would provide to get a running system
: dup sp@ @ ;
: -1 dup dup nand dup dup nand nand ;
: 0 -1 dup nand ;
: 1 -1 dup + dup nand ;
: 2 1 1 + ;
: 4 2 2 + ;
: 6 2 4 + ;
: invert dup nand ;
: and nand invert ;
: negate invert 1 + ;
@eparadis
eparadis / cpu_foo.c
Last active October 22, 2021 01:04
sketch of a 8 bit cpu simulator/emulator
#include <stdint.h>
#include <stdio.h>
typedef uint8_t FLAG;
typedef uint8_t INSTR;
typedef uint8_t REGISTER;
typedef uint16_t IP;
const FLAG FLAG_HALT = 0x80;
const INSTR INSTR_LOAD = 0x08;
@eparadis
eparadis / switch_composite.sh
Created October 27, 2021 00:54
script to switch to composite output on the NTC PocketCHIP
#!/bin/bash
export DISPLAY=:0
export XAUTHORITY=/home/chip/.Xauthority
C=`xrandr | grep 480x272 | grep "*"`
if [ "$C" = "" ]; then :
echo "composite active, switch back"
xrandr --output Composite-1 --off
xrandr --output None-1 --mode 480x272
else :
echo "display active, switching to composite"
Vendor Title Support Status
ECHO AudioFire Pre8 Community Support
M-Audio Ozonic Community Support
M-Audio FireWire Solo Community Support
MOTU Traveler Community Support
Yamaha GO46 Community Support
Yamaha GO44 Community Support
Focusrite Saffire PRO 24 Experimental
Focusrite Saffire Pro 14 Experimental
iCON FireXon Experimental
@eparadis
eparadis / state_machine.c
Created December 12, 2021 08:26
another frustrating dead end in C where I need fancier language features
struct state {
int some_info;
void (*next)(struct state *s);
};
void end(struct state *s) {
// do some clean up
s->some_info = 0;
s->next = halt;
}
void bar(struct state *s) {
@eparadis
eparadis / gol_eurorack.py
Created January 5, 2022 02:36
my Game of Life eurorack module. CircuitPython on an Adafruit QT Py
import random
import time
import board
import simpleio
from adafruit_ht16k33.matrix import Matrix8x8
import pwmio
import analogio
i2c = board.I2C()
matrix = Matrix8x8(i2c, auto_write=False)