Skip to content

Instantly share code, notes, and snippets.

View abcarroll's full-sized avatar

A.B. Carroll III abcarroll

View GitHub Profile
<?php
/*
* (C) Copyright 2015 A.B. Carroll <[email protected]>. MIT or BSD License - your choice.
*/
class Utility {
/**
* Converts either a array of integers or string of comma-separated integers to a natural english range, such as "1,2,3,5" to "1-3, 5". It also supports
@abcarroll
abcarroll / sleepcountdown.sh
Last active December 5, 2015 08:05
Counts down a long sleep
#!/bin/bash
# Written by A.B. Carroll <[email protected]>
# Use as:
# sleepcountdown HOUR MIN SEC "Optional Prefix"
# Example:
# sleepcountdown 00 00 10 "Time until next run: "
# echo "Done with first countdown!"
# sleepcountdown 01 00 05 "Time until next run: "
# echo "Done with second countdown!"
@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
@abcarroll
abcarroll / countsheep.bash
Created September 4, 2015 08:37
Countdown with
countsheep(){
hr=$1
min=$2
sec=$3
if [ -z "$4" ]
then
prefix=""
else
prefix="$4"
@abcarroll
abcarroll / makeStatistics.php
Created July 4, 2015 10:42
Make a hopefully pronounceable word based on vowel, constant patterns. Patterns are pregenerated from analyzing dictionary files.
<?php
// A.B. Carroll, <[email protected]>
// "Do whatever the fuck you want license"
// Generates a 'statistics chunk' for use in pronounceable word generation
// It's a one-time generation, so it doesn't need to be fast.
$file = file('/usr/share/dict/american-english');
$patterns = [];
@abcarroll
abcarroll / rtunnel-auto
Last active August 29, 2015 14:23
Attempts to maintain a reverse ssh tunnel
#!/bin/bash
#
# rtunnel-auto: (C) Copyright 2014-2015 A.B. Carroll <[email protected]>
#
# On the remote server
# AllowTcpForwarding must be configured in order for tunneling to work.
# If LOCAL_HOST is an IP address that is local to the server this script
# is running on, it can be set to either 'yes' or 'local'.
# Beginnger
sudo apt-get install vim netselect-apt
# Basics
sudo apache2-utils autossh bc beep btrfs-tools cryptsetup curl dnsutils dos2unix e2fsprogs file ftp git hexedit hfsprogs htop iftop iotop iptraf less links lrzsz lvm2 md5deep mercurial nmap ntp parted patch pax putty-tools pv rsync screen sudo sysstat tmux tree vim wget whois xz-utils
# Paritioning, File System & FS Encryption
sudo apt-get install lvm2 cryptsetup e2fsprogs hfsprogs btrfs-tools
# Monitoring
@abcarroll
abcarroll / go-lemp
Last active August 29, 2015 14:20
Install LEMP, Postfix, and PowerDNS
#!/bin/bash
packages=(
# > > System utilities
netselect-apt sudo rcconf parted
# > > Internet Services, Programming
nginx
php5-fpm php5-cli
mysql-server
@abcarroll
abcarroll / str_distance_array.php
Last active August 29, 2015 14:19
str_distance_array()
<?php
/* A.B. Carroll, public domain */
function str_distance_array($needle, $haystack) {
$confidence_map = [];
foreach ($haystack as $h) {
if(strlen($needle) < strlen($h)) {
$normalize = strlen($needle);
} else {
$normalize = strlen($h);
/*
* 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.");