Skip to content

Instantly share code, notes, and snippets.

View mcbrwr's full-sized avatar

Matthijs Brouwer mcbrwr

View GitHub Profile
@mcbrwr
mcbrwr / autogit.sh
Created March 2, 2014 08:44
AutoGit. Monitor a working copy and add/commit/pull/push on file changes. Nice for staging servers, not for production ofcourse..
#!/bin/bash
sha=0
previous_sha=0
commitmsg="online changes (autogit)"
if [ $1 ]; then
repo=$1
else
repo='.'
@mcbrwr
mcbrwr / isFunction
Created October 21, 2013 10:01
check if given argument is a function
function isFunction(functionToCheck) {
var getType = {};
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
}
function getElementsByClassName(node,classname) {
if (node.getElementsByClassName) {
// use native implementation if available
return node.getElementsByClassName(classname);
} else {
return (function getElementsByClass(searchClass,node) {
if ( node == null )
node = document;
var classElements = [],
els = node.getElementsByTagName("*"),
@mcbrwr
mcbrwr / currentHostname
Last active December 12, 2015 00:48
get current hostname in PHP
function currentHostname() {
isset($_SERVER['HTTPS']) ? $pageURL = 'https://' : $pageURL = 'http://';
$pageURL .= $_SERVER['SERVER_PORT'] != '80' ? $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"] : $_SERVER['SERVER_NAME'];
return $pageURL;
}