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 / popwindow.js
Last active August 29, 2015 14:03
Perform a window.open, centering it (even for dual monitor setups), and only allow one open instance of each identifier at a time
/*
Pops open a new window given the identifier (name), url, width, height, and
optional additional options (as normally passed to window.open()), centered
on the screen. Additionally, it will not open more than one instance of each
identifier.
Amalgamation of:
https://developer.mozilla.org/en-US/docs/Web/API/Window.open "Best Practices"
http://stackoverflow.com/questions/4068373/center-a-popup-window-on-screen
"Single/Dual Monitor Function"
@abcarroll
abcarroll / backup-rsync
Created June 7, 2014 13:49
Simple BTRFS Incremental
# A.B. Carroll [email protected]
# File location in my setup:
# /media/zebra/launch-zebra-backup
# chmod +x /media/launch-zebra-backup
date > /media/zebra/last-backup.start
date >> /media/zebra/all-backup.start
rsync -avh --delete --progress /svn-migrate /media/zebra/
rsync -avh --delete --progress --exclude=/apps/php_errors.log /apps /media/zebra/
@abcarroll
abcarroll / gist:23495fb510148fec1900
Last active August 29, 2015 14:02
.htaccess for gtmetrix (yslow/page speed)
# Expiration and compression
# This will generally improve gtmetrix (yslow/page speed) score at no expense.
ExpiresActive On
ExpiresByType image/x-icon "access plus 6 weeks"
ExpiresByType image/png "access plus 6 weeks"
ExpiresByType image/jpg "access plus 6 weeks"
ExpiresByType image/gif "access plus 6 weeks"
ExpiresByType image/jpeg "access plus 6 weeks"
ExpiresByType application/x-shockwave-flash "access 6 weeks"
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
@abcarroll
abcarroll / predis-dump-into-php
Created May 15, 2014 18:40
Dumps contents of a redis database relatively well into a text file via predis
<?php
/* Load predis object into $redis
here */
$out_file = 'REDIS-DUMP.txt';
$fp = fopen($out_file, 'w+');
echo "Starting... \n";
echo "KEYS... ";
$objects = $redis->keys("*");
@abcarroll
abcarroll / create_class.php
Created September 13, 2013 03:54
A simple one-time use function to generate the inside part of a PHP class based on functions from a text file. Pulls and uses the function's prototype/synopsis from the PHP manual, as well as adds the full prototype/synopsis and description in a comment. This makes it easy to convert procedural style PHP extensions into classes. Written specific…
<?php
/*
* Copyright (c) 2013, Armond B. Carroll III, [email protected]
* This 'gist' (file) is distributed under the BSD 2-Clause License.
*
* This code will turn a function list into the inside part of a class, with
* the synopsis, and each member calling the original procedural style function.
* It was written to turn ncurses_* functions into a class.
*
* TO USE, load a text file into a file (ncurses.txt in this revision), with