Skip to content

Instantly share code, notes, and snippets.

View kzap's full-sized avatar
🏠
Working from home

Andre Marcelo-Tanner kzap

🏠
Working from home
View GitHub Profile
@kzap
kzap / gist:9437363
Created March 8, 2014 19:15
MixPanel Wordpress Tracking Snippet - Add to the end of your WP Theme's functions.php file. Replace YOUR_MIXPANEL_TOKEN with the one from your MixPanel account.
<?php
add_action('wp_head', 'mixpanel_meta_codes');
function mixpanel_meta_codes() {
?>
<!-- start Mixpanel --><script type="text/javascript">(function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src=("https:"===e.location.protocol?"https:":"http:")+'//cdn.mxpnl.com/libs/mixpanel-2.2.min.js';f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f);b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==
typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.
@kzap
kzap / mongo-backup.sh
Last active August 29, 2015 13:56
Simple backup script for Mongodump. Requires mongodump from mongoclients debian package
TODAY=`date +"%Y%m%d_%H%M%S"` # todays date Y-M-D
MONGODUMP=/usr/bin/mongodump # Path to mongodump
[ -x "${MONGODUMP}" ] || (echo "${MONGODUMP}" not found or not executable; exit 1)
FIND=/usr/bin/find # Path to find
MONGO_BACKUP=/var/spool/mongobackup # Path to your mongo backup directory
MONGO_BACKUP_TODAY="${MONGO_BACKUP}"/"${TODAY}"/ # Path to the directory per day
DAYS_RETENTION=7 # How many days of backups do you wish to keep
MONGO_HOST='127.0.0.1' # Host
MONGO_PORT=27017 # Port
@kzap
kzap / gist:5819745
Last active July 14, 2024 16:13
If you want to give only Travis-CI access to a private key or secret file in your repository, you will need to encrypt it, but rather than storing the entire encrypted file in an environment variable, just store the a secret password in a secure environment variable that you will use to encrypt and decrypt your private key file. The encryption o…
# generate your private key, put the public key on the server you will be connecting to
ssh-keygen -t rsa -f ./my_key
# generate the password/secret you will store encrypted in the .travis.yml and use to encrypt your private key
cat /dev/urandom | head -c 10000 | openssl sha1 > ./secret
# encrypt your private key using your secret password
openssl aes-256-cbc -pass "file:./secret" -in ./my_key -out ./my_key.enc -a
# download your Travis-CI public key via the API. eg: https://api.travis-ci.org/repos/travis-ci/travis-ci/key
@kzap
kzap / addControllerMap.php
Created October 20, 2012 01:35
klein.php controller#action helper function
<?php
function addControllerMap($controllerMapCollection, $method = array('GET', 'POST'), $route = '*', $controllerMap = null) {
global $__controllerMaps;
// parse arguments
$args = func_get_args();
switch (count($args)) {
case 1:
$controllerMap = $controllerMapCollection;
@kzap
kzap / scan-php-exploits.sh
Last active October 11, 2015 16:47
Scan for a file with possible malicious PHP code in it
/usr/bin/find /DIRECTORY/TO/SCAN/ -type f -print0 | /usr/bin/xargs -0 grep 'eval(\$' | /usr/bin/mail -s 'Scan Report' [email protected]