Skip to content

Instantly share code, notes, and snippets.

@hatzopoulos
hatzopoulos / command_exists.inc.php
Last active August 29, 2015 14:13
Miscellaneous PHP Functions
<?php
function command_exists($cmd) {
return shell_exec('command -v '.$cmd.' >/dev/null && echo 1 || echo 0');
}
@hatzopoulos
hatzopoulos / Git.md
Last active August 29, 2015 14:13
Git, GitHub, and Git Workflows
@hatzopoulos
hatzopoulos / ip-white-list-cron.php
Created January 21, 2015 02:54
IP White List Update Cron
<?php
## ./ip-white-list-cron.php
$whitelist_json = __DIR__.'/whitelist.json';
$cache_mtime = filemtime($whitelist_json);
$write_error = 'Write Error. This needs to be properly setup to be able to write to '.$whitelist_json.PHP_EOL;
if ( $cache_mtime === false ) {
if ( touch($whitelist_json) === false) {
@hatzopoulos
hatzopoulos / ua.js
Last active April 22, 2019 10:23
Optimized Google Universal Analytics
// Optimized Google Universal Analytics
// optional requirement 1:
// if using ga_track_pre_url feature;
// the DOM element must exist before document.getElementById('ga_track_pre_url').value
// like going just before the closing </body> tag
// optimized http://mathiasbynens.be/notes/async-analytics-snippet#universal-analytics
(function(G,o,O,g,l){G.GoogleAnalyticsObject=O;G[O]||(G[O]=function(){(G[O].q=G[O].q||[]).push(arguments)});G[O].l=+new Date;g=o.createElement('script'),l=o.scripts[0];g.src='//www.google-analytics.com/analytics.js';l.parentNode.insertBefore(g,l)}(this,document,'ga'));
@hatzopoulos
hatzopoulos / .vimrc
Last active August 29, 2015 13:58
#vim #vimrc
colorscheme molokai
" Allow cursor keys in insert mode
set esckeys
" Allow backspace in insert mode
set backspace=indent,eol,start
" Use UTF-8 without BOM
set encoding=utf-8 nobomb
" Don't add empty newlines at the end of files
set binary
set noeol