Skip to content

Instantly share code, notes, and snippets.

View bl0ckeduser's full-sized avatar

Gabriel Cormier-Affleck bl0ckeduser

View GitHub Profile
@bl0ckeduser
bl0ckeduser / factorial.asm
Created February 15, 2014 17:54
MARS recursive factorial
# MARS recursive factorial
# Sat Feb 15 12:50:25 EST 2014
.data
title: .asciiz "factorials\n==========\n\n"
nfactis: .asciiz "! is "
newline: .asciiz "\n"
.text
@bl0ckeduser
bl0ckeduser / avl.c
Created January 19, 2014 05:51
practicing AVL trees
/*
* trying to practice AVL trees
*
* input: numeric keys separated by newlines
* output: s-expression for final AVL tree,
* where nodes have format v=VALUE,h=HEIGHT
*
* Sun Jan 19 00:48:59 EST 2014
*/
@bl0ckeduser
bl0ckeduser / demo.py
Created December 24, 2013 20:10
pygame sloped platform game mini demo
#
# 2d platformer slope platform demo
# written to try to to help out someone on IRC
#
# controls:
# - left and right keyboard cursor keys: horizontal walking movement
# - up arrow cursor keyboard key: jump
#
# blockeduser
# Tue Dec 24 15:03:09 EST 2013
@bl0ckeduser
bl0ckeduser / mega-gaussian-elim.py
Created September 14, 2013 18:23
Improved gaussian reducer (supports expressions like ln(pi^2), uses fractions of bignums)
# Gaussian elimination
# -- fractional datatype version
# -- deluxe big integers and expressions edition
#
# By blockeduser the wannabe programmer
# Original clown version: September 1-3, 2012
# Python Deluxe big integers version: September 14, 2013
import sys
import re
@bl0ckeduser
bl0ckeduser / gist:5092461
Created March 5, 2013 17:57
Open .exe files intelligently, version 2
# Open .exe files in mono or wine depending
# on what the file(1) command says. Useful
# for practical double-clicking from a
# file manager.
if [ ! "$1" ]
then
echo "Use: $0 file"
exit 1
fi
@bl0ckeduser
bl0ckeduser / exefiles
Created November 11, 2012 22:16
Open .exe files intelligently
# Open .exe files in mono or wine depending
# on what the file(1) command says. Useful
# for practical double-clicking from a
# file manager.
if [ ! $1 ]
then
echo "Use: $0 file"
exit 1
fi
@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.
*
@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 / 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 / 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))))