Skip to content

Instantly share code, notes, and snippets.

View jdaily's full-sized avatar

John Daily Jr. jdaily

View GitHub Profile
@jdaily
jdaily / innobackupex-restore.sh
Last active December 19, 2015 08:49 — forked from dalecaru/innobackupex-restore.sh
Adding config option and step to sync backups to an Amazon S3 Bucket. Also added loggin capabilities.
#!/bin/sh
#
# Script to prepare and restore full and incremental backups created with innobackupex-runner.
#
# This script is provided as-is; no liability can be accepted for use.
#
INNOBACKUPEX=innobackupex-1.5.1
INNOBACKUPEXFULL=/usr/bin/$INNOBACKUPEX
TMPFILE="/tmp/innobackupex-restore.$$.tmp"
@jdaily
jdaily / pre-commit syntax check [PHP]
Last active December 25, 2015 17:09
Pre-Commit hook to check PHP for syntax error
#!/bin/sh
#
# A hook to disallow php syntax errors to be committed
# by running php -l (lint) on them. It requires php-cli
# to be installed.
#
# Credits to https://github.com/phpbb/phpbb, https://raw.github.com/phpbb/phpbb/develop-olympus/git-tools/hooks/pre-commit
#
# This is a pre-commit hook.
#
@jdaily
jdaily / IE console.log()
Last active December 28, 2015 22:09
IE fix for console.log
// Stupid IE Fixes
var alertFallback = true;
if (typeof console === "undefined" || typeof console.log === "undefined") {
console = {};
if (alertFallback) {
console.log = function(msg) {
alert(msg);
};
} else {
console.log = function() {};
@jdaily
jdaily / Brewing in the morning
Last active December 30, 2015 17:19 — forked from adamstac/TODO
Brewing my Dev Environment - PHP, Ruby, Scala, Nginx, Play Framework, Node
## Xcode
Install Xcode
Head to the Apple Developer Center to download a copy of the latest Xcode
* [Apple Developer Center](http://developer.apple.com/technologies/xcode.html)
xcode-select --install
@jdaily
jdaily / Decode_oAuth_redirect
Created December 10, 2013 00:41
Sample Javascript Parsing of oAuth Implicit Response
// Parse the query string
var params = {}, queryString = location.hash.substring(1),
regex = /([^&=]+)=([^&]*)/g, m;
while (m = regex.exec(queryString)) {
params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
}
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@jdaily
jdaily / better_than_truncate
Created April 3, 2014 03:00
Empty a mysql table FAST
TRUNCATE is usually a fast operation (much faster than DELETE FROM). But sometimes it just hangs;
TRUNCATE on tables with no FOREIGN KEYs should act fast: it translate to dropping the table and creating a new one (and it all depends on the MySQL version, see the manual).
Renaming a table (without Foreign Keys) is much faster if its large enough. Instead of:
```
TRUNCATE log_table
```
Do:
```
@jdaily
jdaily / dedup.sql
Last active August 29, 2015 14:00
mySQL dedup
/*********************************************************************************************
Remove duplicate entries / rows a mySQL database table
Credit To:
http://www.justin-cook.com/wp/2006/12/12/remove-duplicate-entries-rows-a-mysql-database-table/
**********************************************************************************************/
/**************************************************************************
Step 1: Move the non duplicates (unique tuples) into a temporary table
***************************************************************************/
CREATE TABLE new_table LIKE old_table;
@jdaily
jdaily / MongoGeoPoint
Created May 4, 2014 19:44
Play-Mongo GeoPoint implicit read/write
package jdaily
import play.api.Play
import play.api.Play.current
import play.api.libs.json._
import play.api.libs.json.Reads._
import play.api.libs.functional.syntax._
/**
* Created by jdaily on 1/27/14.
@jdaily
jdaily / MongoDateTime
Created May 4, 2014 19:47
Play-ReactiveMongo DateTime implicit read/write
package jdaily
import play.api.libs.json._
import org.joda.time.{DateTimeZone, DateTime, LocalDateTime}
/**
* Created by jdaily on 5/04/14.
*/
object MongoDateTime {