Skip to content

Instantly share code, notes, and snippets.

View abcarroll's full-sized avatar

A.B. Carroll III abcarroll

View GitHub Profile
@abcarroll
abcarroll / exceptions-tree.php
Created September 2, 2019 23:52 — forked from JingwenTian/exceptions-tree.php
Throwable and Exceptions tree
<?php
if (!function_exists('interface_exists')) {
die('PHP version too old');
}
$throwables = listThrowableClasses();
$throwablesPerParent = splitInParents($throwables);
printTree($throwablesPerParent);
if (count($throwablesPerParent) !== 0) {
die('ERROR!!!');
@abcarroll
abcarroll / DateTimeUtil.php
Created July 14, 2019 05:44
Simple "fuzzy" dateInterval string creation
<?php
namespace Tc\Std;
// Define these as descendands of \Exception or whaever
use Tc\Std\Exception\DateTimeInvalidArgument;
use Tc\Std\Exception\DateTimeUnexpectedResult;
abstract class DateTimeUtil
{
@abcarroll
abcarroll / HistoryTablePseudoCode.php
Created June 13, 2019 00:12
Example on how to use a history table as a "what has changed" system for ETLs
<?php
// Or, to put it another way
function runLoader() {
$position = queryAndFetch("SELECT * FROM `chat_msg_history_positions` WHERE `positionName` = 'maxChatHistoryId'")
if($position === null) {
runFullLoad();
} else {
runIncrementalLoad($position)
}
@abcarroll
abcarroll / parse.php
Created June 9, 2019 02:07
fun with token parser
<?php
error_reporting(-1);
ini_set('display_errors', true);
$savedValues = [];
$searchForVariableNames = ['$MetaKeys', '$MetaDesc'];
foreach(['test2.php', 'test3.php'] as $filename) {
$srcText = file_get_contents($filename);
$tokens = token_get_all($srcText);
@abcarroll
abcarroll / README.md
Created January 18, 2019 02:41 — forked from balupton/README.md
Remove script for Gmail that delets all email threads/messages that match search for when Gmail can't do it itself

Remove script for Gmail

function Intialize() {
  return;
}

function Install() {
  ScriptApp.newTrigger("purgeGmail")
 .timeBased().everyMinutes(10).create();
@abcarroll
abcarroll / state-by-timezone.php
Last active May 11, 2018 00:37
List of PHP compatible timezone by ISO 3166-1 alpha-2
<?php
$states = array(
'AL' => 'America/Chicago',
'AK' => 'America/Anchorage',
'AZ' => 'America/Phoenix',
'AR' => 'America/Chicago',
'CA' => 'America/Los_Angeles',
'CO' => 'America/Denver',
'CT' => 'America/New_York',
'DE' => 'America/New_York',
#cloud-config
# Specify the merge type every time... all the time
merge_type: 'list(append)+dict(recurse_array)+str()'
# Update apt
apt_update: true
apt_upgrade: true
apt_reboot_if_required: true
@abcarroll
abcarroll / warning-icon-base64.html
Created May 12, 2017 07:22
PNG for fa-exclamation-triangle-o "open" version (similar, at least)
<!DOCTYPE html>
<html>
<head>
<title>Warning Icon</title>
</head>
<body>
<!-- Taken from wikipedia commons, free for commercial use -->
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEwAACxMBAJqcGAAABqpJREFUeNrtnV2IlUUYx3+6mK2WhZnYl7lqpmZ7EeJNWIiWrh+pURlpWBlUehEkhlmpWVpGmoR9Qd2ElaClrrZRkWUWhRVYkGZpuWqmkVlJmrpaF+8rnJZzTu/M+zHznvP/wVztMs+z88ye8ztzZuYFIYQQQgghhBBCCCGEEEIIIYQQQgghhMg75wODgGFhGwScp2GpXLoC9wDrgN+Af0q0A8Ba4G6gi4Yt//QHlgHHyhS9VDsKvAJcqmHMH52AZ4EWi8K3bi3AM8AZGtZ8cCWwK4HCt24/hq4gPGaK5cu9ydvCJA2zn0xPsfCF7SQwTcPtF3dlVPzCNlnD7gfXJiR7pu0YcJWG3/2Czq8Oin+q7QvXGIQj3nFY/FNtjcrghokxirYFWARMDdtiYGuM/m5QObLlrPDl17RQW0NnKMUIYJtFv7uBjipLdiyxKNLrQG2EvjsCKy36X6iyZEO9hfUvA9oYxGgLLLf4VNBX5UmfjwwL8ylwmkWc9sAXhrHeU3nS5VbDgvwF9IwRrw9wxDDmTSqTP+I3K4G4syWE+RS/bZYv/a05HdghIcyf+A1PMP4oCWG+xO+NFHJolBDmR/y6p5BHnYUQ3qjyxaMT8LMD8SvFHAmh3+L3XULiJyH0gMsdi18pRksI/RS/NzPMba2EsDrET0KYE/F70KD/tgTHwRYAr4ZtPjA0/FlU5koI8yd+DeHvl+rrW8rvF4grhE+ovO7EbybRt33PiNjnGAlhPsT
@abcarroll
abcarroll / warning-icon-base64.html
Created May 12, 2017 07:21
PNG for fa-exclamation-triangle-o "open" version (similar, at least)
<!DOCTYPE html>
<html>
<head>
<title>Warning Icon</title>
</head>
<body>
<!-- Taken from wikipedia commons, free for commercial use -->
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEwAACxMBAJqcGAAABqpJREFUeNrtnV2IlUUYx3+6mK2WhZnYl7lqpmZ7EeJNWIiWrh+pURlpWBlUehEkhlmpWVpGmoR9Qd2ElaClrrZRkWUWhRVYkGZpuWqmkVlJmrpaF+8rnJZzTu/M+zHznvP/wVztMs+z88ye8ztzZuYFIYQQQgghhBBCCCGEEEIIIYQQQgghhMg75wODgGFhGwScp2GpXLoC9wDrgN+Af0q0A8Ba4G6gi4Yt//QHlgHHyhS9VDsKvAJcqmHMH52AZ4EWi8K3bi3AM8AZGtZ8cCWwK4HCt24/hq4gPGaK5cu9ydvCJA2zn0xPsfCF7SQwTcPtF3dlVPzCNlnD7gfXJiR7pu0YcJWG3/2Czq8Oin+q7QvXGIQj3nFY/FNtjcrghokxirYFWARMDdtiYGuM/m5QObLlrPDl17RQW0NnKMUIYJtFv7uBjipLdiyxKNLrQG2EvjsCKy36X6iyZEO9hfUvA9oYxGgLLLf4VNBX5UmfjwwL8ylwmkWc9sAXhrHeU3nS5VbDgvwF9IwRrw9wxDDmTSqTP+I3K4G4syWE+RS/bZYv/a05HdghIcyf+A1PMP4oCWG+xO+NFHJolBDmR/y6p5BHnYUQ3qjyxaMT8LMD8SvFHAmh3+L3XULiJyH0gMsdi18pRksI/RS/NzPMba2EsDrET0KYE/F70KD/tgTHwRYAr4ZtPjA0/FlU5koI8yd+DeHvl+rrW8rvF4grhE+ovO7EbybRt33PiNjnGAlhPsT
#!/usr/bin/env bash
URL="http://a0.awsstatic.com/pricing/1/ec2/ri-v2/linux-unix-shared.min.js"
echo -e "1S- = Std 1 Year Term \t3S- = Std 3 Year Term\t3C- = Convertibe 3 Year Term"
echo -e " -NON = No Up Front Cost\t -PRT = Partially Upfront\t -ALL = Entire Term Upfront"
echo ""
echo -e "Instance\tONDMND\t1S-NON\t1S-PRT\t1S-ALL\t3S-PRT\t3S-ALL\t3C-NON\t3C-PRT\t3C-ALL\n"
(echo 'function callback(data) { console.log(JSON.stringify(data)); }'; curl -s "$URL" ) |\