Skip to content

Instantly share code, notes, and snippets.

@cacycleworks
cacycleworks / reconcile.php
Last active December 12, 2015 05:58
Recursive function in php to reconcile credit card batches to an array of charges where the sum of a subset of charges matches the batch amount. Absurdly easy to "see" and do with your mind, getting it programmed was not easy at all.
<?
$charges=Array(
'2863996511' => 154.00 ,'2863879671' => 10.88
,'2863992361' => 762.20 ,'2863858891' => 209.00
,'2863898975' => 49.00 ,'2863856334' => 148.00
,'2863894564' => 5.44 ,'2863367273' => -25.01
); print_r($charges);
$targets=Array(1302.63, 1327.64, 1322.20 );
foreach( $targets as $batch ) {
printf( "We seek combination of transId's to = $%-7.2f\n", $batch);
@cacycleworks
cacycleworks / git_update.sh
Last active February 18, 2023 23:41
Simple sh script to automate a git update
#!/bin/sh
if [ $# != 2 ]; then
echo "\nchris k's git update automater sh script. Edit to put a bunch of \`git add blah'"
echo "lines in the body then evoke with the branch name and commit description\n"
echo "Usage: $0 <branch_name> <\"Description of update\">\n"
echo " branch_name: the name of the git branch to be created"
echo " Description: Text for: git commit -m \"Description of update\""
echo ""
echo "Example:"
BRANCH="core_override"
@cacycleworks
cacycleworks / _mysqli_helper.php
Last active May 29, 2018 16:17
MySQLi helper functions I use to describe and understand tables. Great for Magento.
<?php
// (c) Chris Kelley of "Tech Nerd Chris", technerdchris at gmail
// This is my dev code to speed understanding of databases. Put up a search form
// and use this to render HTML results of table structures
//
// $db = mysqli handle
// optional $tbl_order lets you send in table names as an array to set order or limit results
function describe( $db, $tbl_order='' ){
$_colors =array( 'red' => "red", 'orn' => "orange", 'blue' => "#06f", 'gray' => "#666", 'grn' => "#0a3" );
foreach( $_colors as $var => $_c )