Skip to content

Instantly share code, notes, and snippets.

View bl0ckeduser's full-sized avatar

Gabriel Cormier-Affleck bl0ckeduser

View GitHub Profile
@bl0ckeduser
bl0ckeduser / permut.c
Created June 26, 2012 22:18
String permutations
/*
* Print all permutations of a string,
* using a tree-recursive routine. I
* bet there are smart algorithms out
* there that beat this. I did not look
* up an algorithm when writing this.
*
* Bl0ckeduser
* June 26, 2012
*/
@bl0ckeduser
bl0ckeduser / chromakeyman2.c
Created July 19, 2012 01:21
ChromakeyMan v2.1
/*
* ChromakeyMan v2.1
* by 'Bl0ckeduser'
*
* A simple chroma-key effect program
*
* Originally written in METAL Basic
* (on Mac OS 9) in 2007-2008 for ad-hoc
* use in a little VFX project.
*
@bl0ckeduser
bl0ckeduser / chromakeyman2.c
Created July 19, 2012 18:17
ChromakeyMan v2.2
/*
* ChromakeyMan v2.2
* by 'Bl0ckeduser'
*
* A simple chroma-key effect program
*
* Originally written in METAL Basic
* (on Mac OS 9) in 2007-2008 for ad-hoc
* use in a little VFX project.
*
@bl0ckeduser
bl0ckeduser / wannabe-regex-v1.c
Created August 25, 2012 20:36
NFA wannabe regex
/*
* Wannabe regex (egrep-style)
* Wannabe automatic regex tokenizer
* Wannabe egrep command (./a.out --wgr 'pattern')
*
* The wannabe egrep can make a picture of the compiled NFA
* this way:
* ./a.out --wgr 'pattern' --pic | pic | troff -ms
*
* Supported 'special' characters:
@bl0ckeduser
bl0ckeduser / wannabe-regex.c
Created August 26, 2012 21:36
NFA wannabe regex, revised
/*
* August 26, 2012 error fixes:
*
* Fixed * compilation to work properly with
* proper epsilon nodes. Fixed evaluator infinite
* loop check to work well with this.
* Removed large stack allocation in main().
*/
/*
@bl0ckeduser
bl0ckeduser / wannabe-regex-v2.c
Created August 27, 2012 23:41
NFA wannabe regex, with more fixes
/*
* August 27, 2012 error fixes:
*
* Fixed + compilation to work properly with
* proper epsilon nodes. Fixed evaluator infinite
* loop check to work well with this.
* Some comments on the new messy (but better-working)
* + / * nodes/edges.
* (Yeah, I know, it's mostly similar to yesterday).
*/
@bl0ckeduser
bl0ckeduser / perfect-numbers.rkt
Created August 31, 2012 21:59
Perfect numbers in Racket
#lang racket
; Prints out perfect numbers < 1000
(define (proper-factors-of n)
(filter
(lambda (x) (= 0 (modulo n x)))
; n is excluded
(sequence->list (in-range 1 n))))
@bl0ckeduser
bl0ckeduser / wannabe-regex-v4.c
Created September 7, 2012 03:21
NFA wannabe regex, 4th revision
/*
* September 6, 2012
* - Fixed $ compilation
* - Better pictures
*/
/*
* August 27, 2012 error fixes:
*
* Fixed + compilation to work properly with
@bl0ckeduser
bl0ckeduser / e-estim.py
Created September 28, 2012 23:47
Estimate e to "N" decimal places
# Print e, (believed) correct to N decimal places.
#
# [Not absolutely guaranteed accurate, because
# I'm not an expert or professional. Casually
# believed to work based on tests with N < 3000
# with some e-decimals sources on the Internet.]
#
# [e.g. to get identical formatting for comparison
# with NASA's "e.2mil", pipe through
# sed 's/2\./ 2\./g' | fold -60
@bl0ckeduser
bl0ckeduser / e.c
Created September 30, 2012 23:06
Estimate e to "N" decimal places - version 2
/*
* This program gives either "N - 2" terms of the
* series for e, or "N" decimal places of e
* (in the latter case converting the digit count
* to a term count by brute-force) using only C's
* built-in integer arithmetic (lots of it and lots
* of memory allocation and moving-around stuff).
* In both cases, it makes sure to stop giving
* you digits once the error margin is reached.
*