Skip to content

Instantly share code, notes, and snippets.

View andrewrcollins's full-sized avatar

Andrew Collins andrewrcollins

View GitHub Profile
@andrewrcollins
andrewrcollins / reconcile.awk
Created January 11, 2012 04:33
Loan Reconciliation
# Total Loan Amount 1500.00
#
# Monthly Payment 20.78
#
# Initial Rounding Adjustment 0.005000000
#
# Loan Raw Rounding Adjusted Truncated
# Lender Amounts Percentages Amount Adjustment Amount Amount Remainder
#
# A1 50.00 0.033333.. 0.69265974 [0.00500000] 0.69765974 0.69 0.00765974
@andrewrcollins
andrewrcollins / trim.awk
Created January 11, 2012 04:22
ltrim(), rtrim(), and trim() in awk
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
function trim(s) { return rtrim(ltrim(s)); }
BEGIN {
# whatever
}
{
# whatever
}
END {
@andrewrcollins
andrewrcollins / loans.sql
Created January 11, 2012 04:15
MySQL Loan Origination and Accurate Payment Stream Calculations
-- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-- stored procedures for loan origination and payment streams
-- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
DROP FUNCTION IF EXISTS fvif$$
CREATE FUNCTION fvif
(
@andrewrcollins
andrewrcollins / dates_times.sql
Created January 11, 2012 04:01
MySQL Dates and Times
-- ===================================================================
-- Various MySQL stored procedures for handling dates,
-- as well as populating date and time dimensions.
-- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
--
-- Date Dimension
--
@andrewrcollins
andrewrcollins / terrain.pas
Created January 6, 2012 02:47
#TJHSST ~ Starflight ~ Terrain Vehicle
program terrainvehicle;
uses crt,graph;
const
xsize = 50;
ysize = 50;
type
polys = array[1..5,1..3,1..5] of record
x,y : word;
end;
fillarea = array[1..5,1..3,1..2] of byte;
@andrewrcollins
andrewrcollins / ominoes.c
Created January 6, 2012 02:40
#TJHSST ~ Polyiminoes: Pentominoes, Hexominoes, etc.
/*
Polyiminoes :
Pentominoes,Hexominoes, etc.
*/
#include <stdio.h>
#include "conio.h"
#include "stdlib.h"
#define OMINOS 8
/* To check diagonal connections define DIAGONALS, otherwise for
@andrewrcollins
andrewrcollins / survive.c
Created January 6, 2012 02:34
#TJHSST ~ Survive! ~ A Sea Full Of Danger And Oceans Of Fun!
/* Survive */
#include <stdio.h>
#include <stdlib.h>
#include "conio.h"
/* The playing grid is OCEANXxOCEANY. */
#define OCEANX 13
#define OCEANY 12
/* These are the types of landforms there are in the game. */
@andrewrcollins
andrewrcollins / booleval.c
Created January 6, 2012 02:33
#TJHSST ~ Evaluate parenthesized boolean function of at most 9 variables
/*
Evaluates a parenthesized boolean function of at most 9 variables.
*/
#include <stdio.h>
#include <ctype.h>
#include <stdarg.h>
#define ANDSYMBOL (char)'*'
#define ORSYMBOL (char)'+'
#define XORSYMBOL (char)'@'
@andrewrcollins
andrewrcollins / flow.c
Created January 6, 2012 02:31
#TJHSST ~ Cellular Automata for Flow Modelling
/*
Cellular Automata for Flow Modelling
C++ version
Gordon Mercer and Andy Collins
January 24,1991
Adapted for C by Andy Collins
January 25,1991
*/
#include <stdlib.h>
#include <graphics.h>
@andrewrcollins
andrewrcollins / lifefast.c
Created January 6, 2012 02:30
#TJHSST ~ Game of Life
/*
"Life"
John Horton Conway's Cellular Automaton
Using meta-blocks
*/
#include <stdio.h>
/* For IBMs only. */
#include "conio.h"