Skip to content

Instantly share code, notes, and snippets.

View PerpetualBeta's full-sized avatar

Jonathan M. Hollin PerpetualBeta

View GitHub Profile
@PerpetualBeta
PerpetualBeta / gist:6845202
Created October 5, 2013 19:35
Bash script to recursively chmod the permissions of files or folders.
#!/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 / karabiner.json
Created June 30, 2017 06:17
Karabiner Configuration File
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": false,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@PerpetualBeta
PerpetualBeta / daySensitiveCountdownTimer.js
Last active January 7, 2019 10:45
A real-time countdown timer for a web page. Will countdown to a target time, but only on days specified (eg: Mon-Fri).
if (document.getElementById('countdownTimer')) {
pad = function(n, len) { // leading 0's
var s = n.toString();
return (new Array( (len - s.length + 1) ).join('0')) + s;
};
var timerRunning = setInterval(
function countDown() {
var now = new Date();
if ( (now.getDay() >= 1) && (now.getDay() <= 5) ) { // Monday to Friday only
@PerpetualBeta
PerpetualBeta / sw.js
Created June 11, 2017 12:39
Perpetual βeta Service Worker
'use strict';
const version = 'v1.17l::';
const staticCacheName = version + 'pwa';
const pagesCacheName = version + 'pages';
const imagesCacheName = version + 'assets';
const offlinePage = '/local-offline.html';
const weblogSlug = '/weblog/';
const cacheList = [
@PerpetualBeta
PerpetualBeta / network_status.sh
Last active January 7, 2017 20:08
Network status monitor for BitBar (https://getbitbar.com/)
#!/bin/bash
PING_TIMEOUT=2
PING_ADDRESS=8.8.8.8
PING_STATUS=false
EXTERNAL_IP_LABEL='IP Address (external): '
ACQUIRE_EXTERNAL_IP='/usr/local/bin/wget -qO- http://ipecho.net/plain'
EXTERNAL_IP_ADDRESS="$(eval "$ACQUIRE_EXTERNAL_IP")"
EXTERNAL_IP="${EXTERNAL_IP_LABEL}${EXTERNAL_IP_ADDRESS}"
VPN_STATUS=false
@PerpetualBeta
PerpetualBeta / srcset_factory.php
Created May 15, 2016 17:51
Factory for producing `srcset` image sets
#!/usr/bin/env php
<?php
/* Inspired by: https://github.com/MattWilcox/Adaptive-Images */
# BEGIN: Configuration
$config = array (
'breakpoints' => array(10, 80, 480, 768, 820, 1024, 1280, 1640),
'group_breakpoints' => TRUE, // if TRUE, will group the images into folders for each breakpoint
@PerpetualBeta
PerpetualBeta / loading.svg
Created May 15, 2016 17:26
Spinning activity indicator.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PerpetualBeta
PerpetualBeta / gist:6653157
Created September 21, 2013 18:55
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
# /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
@PerpetualBeta
PerpetualBeta / fixedTableHeader.js
Created December 9, 2012 14:44
On large HTML tables, in a height-constricted viewport, keeps the 'thead' visible while the table is scrolled.
(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:4009338
Created November 3, 2012 23:39
Adds a "fuzzy" search suggestion to the i18n_search plug-in for the GetSimple CMS
<?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: