Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonathan M. Hollin PerpetualBeta

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am PerpetualBeta on github.
  • I am jhollin (https://keybase.io/jhollin) on keybase.
  • I have a public key whose fingerprint is 9547 E5D6 4590 94C5 D627 F8BC 1616 3E98 79D4 DF03

To claim this, I am signing this object:

@PerpetualBeta
PerpetualBeta / create_drop_all_dbs.sql
Last active Aug 29, 2015
A MySQL script that will generate a list of statements to drop all DBs on a server.
View create_drop_all_dbs.sql
-- Run this script
SELECT CONCAT('DROP DATABASE `', schema_name, '`;') AS stmt
FROM information_schema.schemata
WHERE schema_name NOT IN ('information_schema', 'performance_schema', 'mysql')
ORDER BY SCHEMA_NAME;
-- Copy the output into your clipboard
SET FOREIGN_KEY_CHECKS = 0;
@PerpetualBeta
PerpetualBeta / web-page-envelope.php
Created Oct 25, 2012
PHP wrapper for servers where mod_expires and/or mod_deflate are not available. Files routed through this wrapper will be served gzip-compressed, with an ETag and with a "far future expires" header.
View web-page-envelope.php
<?php
/**
* Page delivery wrapper for servers where mod_expires and/or mod_deflate are
* not available.
*
* Route page requests through this wrapper (via mod_rewrite for example) and
* they will be served with far future expires, etags and will be gzip
* compressed.
*
@PerpetualBeta
PerpetualBeta / gist:3964029
Created Oct 27, 2012
Rename all files in a directory to their web-safe equivalents.
View gist:3964029
perl -e 'foreach $file (glob "*") { $dest_file = $file; $dest_file =~ s/ /_/sg; $dest_file =~ s/[^a-zA-Z_\-.0-9]//sg; rename $file, lc($dest_file) }'
@PerpetualBeta
PerpetualBeta / tinyImgCycle.js
Created Oct 27, 2012
Cycle through a series of images. Fade transition between slides. Loops back to first slide at end of collection.
View tinyImgCycle.js
// Requires the jQuery library - http://jquery.com/
// Demo: http://jsfiddle.net/DarkBlue/zM3A2/3/embedded/result/
function slideshow(){var a=$("#animation img.active");a.length==0&&(a=$("#animation img:last"));var b=a.next().length?a.next():$("#animation img:first");a.addClass("last-active");b.css({opacity:0}).addClass("active").animate({opacity:1},1E3,function(){a.removeClass("active last-active")})}$(function(){setInterval("slideshow()",5E3)});
@PerpetualBeta
PerpetualBeta / ticker.js
Created Oct 27, 2012
Compact, vertical, infinite ticker/scroller. Pauses on "mouseenter" event.
View ticker.js
(function ($) {
$.fn.ticker = function (options) {
var defaults = {
speed: 1000,
pause: 3000,
p: false
};
options = $.extend(defaults, options);
@PerpetualBeta
PerpetualBeta / gist:4009338
Created Nov 3, 2012
Adds a "fuzzy" search suggestion to the i18n_search plug-in for the GetSimple CMS
View gist:4009338
<?php
/**
* Fuzzy Search Suggestion Snippet for i18n_search plug-in for the GetSimple CMS
*
* Sometimes a search query produces no matches. This is occassionaly due to a
* miss-spelling in the query terms. This routine will attempt to offer a search
* suggestion to the user when a search results in no matches.
*
* For example:
@PerpetualBeta
PerpetualBeta / fixedTableHeader.js
Created Dec 9, 2012
On large HTML tables, in a height-constricted viewport, keeps the 'thead' visible while the table is scrolled.
View fixedTableHeader.js
(function($){
$.fn.extend({
fixedTableHeader: function(options) {
var defaults = { wrapper : null, offset : 0 };
options = $.extend(defaults, options);
return this.each(function() {
var o = options;
if (o.wrapper === null) { $(this).wrap('<div class="w" />'); o.wrapper = $('.w'); }
var scrollbarWidth = function(){var a=$('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div></div>');$('body').append(a);var b=$('div',a).innerWidth();a.css('overflow-y','auto');var c=$('div',a).innerWidth();$(a).remove();return b-c;};
$(this).clone().appendTo(o.wrapper).wrap('<div class="b" />');
@PerpetualBeta
PerpetualBeta / gist:6845202
Created Oct 5, 2013
Bash script to recursively chmod the permissions of files or folders.
View gist:6845202
#!/bin/sh
# Traverse a directory starting at $path and change the permissions of all files
# or folders (determined with options) to $permissions
helpText=$"Usage: ${0##*/} -(f|d) permissions path";
permissions=$2;
path=$3;
if [[ $path ]]
@PerpetualBeta
PerpetualBeta / gist:6653157
Created Sep 21, 2013
Bash script header to elevate a script that needs to run as "root" if it is run without sudo. Background here: http://darkblue.sdf.org/weblog/post/got-root
View gist:6653157
# /bin/sh
if [ "$(whoami)" != 'root' ]; then
echo 'This script must be run as "root".'
echo 'Enter password to elevate privileges:'
SCRIPTPATH=$( cd $(dirname $0) ; pwd -P )
SELF=`basename $0`
sudo $SCRIPTPATH'/'$SELF
exit 1
fi
You can’t perform that action at this time.