View mongo-backup.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
View gist:9437363
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. |
View gist:e26856adfcc73d8089d7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
umount /dev/xvdd1 (unmount the partition) | |
fsck -y /dev/xvdd1 (do an initial file system check) | |
tune2fs -O ^has_journal /dev/xvdd1 (remove the existing journal) | |
fsck -y /dev/xvdd1 (do a further file system check) | |
tune2fs -j /dev/xvdd1 (recreate the journal) |
View fealty_segmentio_tracking.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _optly = { | |
updateQueryString: function(key, value, url) { | |
if (!url) url = window.location.href; | |
var re = new RegExp("([?|&])" + key + "=.*?(&|#|$)(.*)", "gi"); | |
if (re.test(url)) { | |
if (typeof value !== 'undefined' && value !== null) | |
return url.replace(re, '$1' + key + "=" + value + '$2$3'); | |
else { | |
var hash = url.split('#'); |
View plupload-formsubmit.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Client side form validation | |
$("form").submit(function(e) { | |
var uploader = $("#uploader").pluploadQueue(); | |
// Validate number of uploaded files | |
if (uploader.total.uploaded == 0) { | |
// Files in queue upload them first | |
if (uploader.files.length > 0) { | |
// When all files are uploaded submit form | |
uploader.bind("StateChanged", function() { |
View useful
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#sql-restore-files | |
for SQL in *.sql.gz; do DB=${SQL/\.sql.gz/}; echo importing $DB; zcat $SQL | mysql -u root --password='{PASSWORD}' $DB; done | |
#backup all directories and compress them | |
find ./* -maxdepth 0 -type d -exec echo "Archiving {}" \; -exec tar -cjf "{BACKUP_DIR}/{}-{DATE}.tar.bz2" \; | |
#find and replace in files recursive without touching files that dont match | |
find ./ -type f -name '*.php' -print0 | xargs -0 grep 'FIND' -l | xargs sed -i 's/FIND/REPLACE/g' | |
#apache max clients recommendation |
View ubuntu-init-script.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
# DESCRIPTION: The following UserData script is created to configure a Rackspace Cloud server | |
# with all the necessary things you might want. | |
# Recommended flavor is a minimum 4-8GB as the disk partitions for /tmp and /var/log are 4-8GB | |
# | |
# Can be used from CLI with nova or supernova | |
# example: | |
# supernova lincusa boot --image "Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)" --flavor performance1-8 --key-name {YOUR_KEY} --user-data "ubuntu-init-script.sh" --config-drive true {YOUR_SERVER_NAME} | |
# |
View gist:34cc7659877f4692e14a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.) FIND: ' {AMANAME}: ' | |
REPLACE WITH: ' {AMANAME}! ' | |
2.) FIND: '\[[0-9]{1,2}:[0-9]{2} PM\] ([^:]+)\: ([^\[]+)' | |
REPLACE WITH: '**Q (\1) : \2** | |
' | |
3.) FIND: ' | |
** |
View scan-php-exploits.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/bin/find /DIRECTORY/TO/SCAN/ -type f -print0 | /usr/bin/xargs -0 grep 'eval(\$' | /usr/bin/mail -s 'Scan Report' yourname@email.com |
View addControllerMap.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
OlderNewer