Skip to content

Instantly share code, notes, and snippets.

View abcarroll's full-sized avatar

A.B. Carroll III abcarroll

View GitHub Profile
Array functions:
array_search $needle, $haystack
in_array $needle, $haystack
String functions:
strchr $haystack, $needle
stripos $haystack, $needle
stristr $haystack, $needle
strpos $haystack, $needle
strrchr $haystack, $needle
/*
* This clears the LESS.js cache, since it aggressively caches @import statements.
* Credit: Attaboy, https://gist.github.com/attaboy/1346280
* Additional key checks and debugging output by A.B. Carroll. (http://github.com/nezzario)
* License: Assumed MIT/BSD-like license, please give credit where credit is due.
*/
less.env = 'development';
console.log("If you are seeing this in a production environment you are likely doing something wrong or forgot to remove the destroyLessCache() script.");
@abcarroll
abcarroll / HTTP Cookie header parser
Last active September 12, 2015 08:39 — forked from pokeb/HTTP Cookie header parser
Quick and dirty HTTP cookie header parser in PHP
#!/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" ) |\
@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 / 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!!!');
#include <stdio.h>
#include <iostream>
#include <thread>
#include <list>
#include <sapi/embed/php_embed.h>
int main(int argc, char* argv[]) {
PHP_EMBED_START_BLOCK(argc, argv)
@abcarroll
abcarroll / README.md
Created October 1, 2019 05:03 — forked from joyrexus/README.md
Perl one-liners

Hi:

perl -e 'print "hello world!\n"'

A simple filter:

perl -ne 'print if /REGEX/'

Filter out blank lines (in place):

@abcarroll
abcarroll / lmdb.tcl
Created November 9, 2019 06:10 — forked from antirez/lmdb.tcl
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <antirez@gmail.com>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!
@abcarroll
abcarroll / lmdb.tcl
Created November 9, 2019 06:10 — forked from antirez/lmdb.tcl
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <antirez@gmail.com>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!