Skip to content

Instantly share code, notes, and snippets.


Rob Dunham Nilpo

View GitHub Profile
Nilpo / CustomException.php
Last active May 10, 2020
If you intend on creating a lot of custom exceptions, I've created an interface and an abstract exception class that ensures that all parts of PHP's built-in Exception class are preserved in child classes. It also properly pushes all information back to the parent constructor ensuring that nothing is lost. This allows you to quickly create new e…
View CustomException.php
* This code is free software; you can use it, redistribute it, and/or modify as you wish.
* This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY - implied or otherwise.
* This code is distributed "as is." All risk and cost are assumed by the user of the code and not the creator thereof.
* If you wish to give attribution, the original creator is Robert "Nilpo" Dunham (
interface IException
Nilpo / Session.php
Last active Jul 28, 2020
A simple session wrapper class to provide static OOP access to PHP sessions.
View Session.php
* Session Helper Class
* A simple session wrapper class.
* Recommended for use with PHP 5.4.0 or higher. (Not required.)
* Usage Example:
View gist-shortcode.php
// github gist Shortcode Usage: [gist id="" file=""]
function gist_shortcode( $atts ) {
'id' => '',
'file' => ''
), $atts));
return '<script src="'.$id.'.js?file='.$file.'"></script>';
add_shortcode('gist', 'gist_shortcode');
Nilpo / lazyload_google_analytics.html
Created Dec 26, 2013
Lazy load Google Analytics
View lazyload_google_analytics.html
<script type="text/javascript">
(function($) {
$("body").load(function() {
setTimeout(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
}, 1);
View jsbin.AFaxaFEQ.html
<!DOCTYPE html>
<meta name="description" content="An example of simple JavaScript animation for HTML5 meters and progress bars." />
<meta charset=utf-8 />
<title>JS Bin</title>
<p><meter id="meter" value="300" min="0" max="500">300Gb of 500Gb</meter></p>
View conditionally-load-jquery.js
// Conditionally Load jQuery (javascript)
// Source:
var init, loadjQuery;
init = function() {
jQuery(document).ready(function() {
alert('Your Code Here');
View .bashrc
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
View gh_hook.php
* This file serves as a post receive hook for a GitHub repository. It should be placed in the root of the repository.
* To begin, you will need to store a secret key in an environmental variable on the server.
* export SECRET_TOKEN=your_token
Nilpo / Autoloader.php
Last active Nov 11, 2019
A simple recursive PHP autoloader using the RecursiveDirectoryIterator.
View Autoloader.php
* The MIT License (MIT)
* Copyright (c) 2014 Rob Dunham
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
Nilpo / .bashrc
Created Oct 1, 2014
Adds colored bash prompt, Git completion, and git branch name in the bash prompt.
View .bashrc
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
You can’t perform that action at this time.