Skip to content

Instantly share code, notes, and snippets.

View andrewrcollins's full-sized avatar

Andrew Collins andrewrcollins

View GitHub Profile
@andrewrcollins
andrewrcollins / pmt.php
Created June 22, 2013 04:12
Regular Payment at Regular Interval (PMT)
<?php
/**
* Future Value Interest Factor (FVIF)
*
* @param float $interest annual interest
* @param int $periods periods
* @throws InvalidArgumentException if $interest is not float
* @throws InvalidArgumentException if $periods is not int
* @return float future value interest factor
@andrewrcollins
andrewrcollins / fvif.php
Created June 22, 2013 03:55
Future Value Interest Factor (FVIF)
<?php
/**
* Future Value Interest Factor (FVIF)
*
* @param float $interest annual interest
* @param int $periods periods
* @throws InvalidArgumentException if $interest is not float
* @throws InvalidArgumentException if $periods is not int
* @return float future value interest factor
@andrewrcollins
andrewrcollins / mix_tint_tone_shade.php
Last active February 24, 2024 18:52
Color Mixing, Tint, Tone, and Shade in PHP
<?php
/**
* mix
*
* @param mixed $color_1
* @param mixed $color_2
* @param mixed $weight
*
* @return void
<?php
// http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Explicit_definition
// calculate C(n,k) aka binomial coefficient
// http://php.net/manual/en/ref.math.php#57895
function C($n, $k)
{
$j = $res = 1;
<?php
// http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_curves
// t : [0, 1]
// p0, p1, p2, p3 : n-dimensional point
// B(t) = (1-t)^3 * p0 + 3*(1-t)^2*t * p1 + 3*(1-t)*t^2 * p2 + t^3 * p3
function CubicBezierCurve($t, $p0, $p1, $p2, $p3)
{
$u = 1 - $t;
<?php
// t : [0, 1]
// p0, p1, p2 : n-dimensional point
// B(t) = (1-t)^2 * p0 + 2*(1-t)*t * p1 + t^2 * p2
function QuadraticBezierCurve($t, $p0, $p1, $p2)
{
$u = 1 - $t;
$uu = $u * $u;
$tt = $t * $t;
@andrewrcollins
andrewrcollins / collect.sh
Created February 6, 2012 21:05
OpenClipArt Collection Uploader
#!/bin/sh
AGENT="Mozilla/5.0 (Windows NT 5.1; rv:10.0) Gecko/20100101 Firefox/10.0"
SIGNIN="http://openclipart.org/signin"
USERNAME=xxxxxxxxxxx
PASSWORD=yyyyyyyyyyy
curl --cookie-jar cookies --user-agent "${AGENT}" --data "username=${USERNAME}&password=${PASSWORD}&process=login&submit=Sign in" --output "signin.html" "${SIGNIN}"
@andrewrcollins
andrewrcollins / upload.sh
Created February 6, 2012 21:03
OpenClipArt Uploader
#!/bin/sh
AGENT="Mozilla/5.0 (Windows NT 5.1; rv:10.0) Gecko/20100101 Firefox/10.0"
SIGNIN="http://openclipart.org/signin"
USERNAME=xxxxxxxxxxx
PASSWORD=yyyyyyyyyyy
USERUPID=zzzzzzzzzzz
@andrewrcollins
andrewrcollins / ppg.txt
Created January 11, 2012 04:44
Propylene Glycol
GLYCOLS ~ Propylene Glycol. Glycerin. Ethylene Glycol. Carbitol. Diethylene Glycol. Glycol literally means "glycerin" plus "alcohol." A group of syrupy alcohols derived from hydrocarbons and used in foods as emulsifiers and in chewing-gum bases and in cosmetics as humectants. The FDA cautions manufacturers that glycols may cause adverse reactions in users. Propylene glycol and glycerin are considered safe. Other glycols in low concentrations may be harmless for external application but ethylene glycol, carbitol, and diethylene glycol are hazardous in concentrations exceeding 5 percent even in preparations for use on small areas of the body. Wetting additives increase the absorption of glycols and therefore their toxicity.
HUMECTANT ~ A substance used to preserve the moisture content of materials and used to preserve moisture in confections and tobacco. Glycerin, propylene, glycol, and sorbitol are widely used humectants. See individual substances for toxicity.
ISOPROPYL ISOSTEARATE ~ See Stearic Acid and Pr
@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