Skip to content

Instantly share code, notes, and snippets.

View jtarleton's full-sized avatar

James Tarleton jtarleton

View GitHub Profile
@jtarleton
jtarleton / slavestatus.php
Created September 17, 2013 21:54
Simple batch job to write MySQL's slave status to a file
<?php
abstract class Base
{
//An array of DB config values
protected static $config;
//Path to configuration
protected static $iniPath = 'C:\Users\winuser\Desktop\dbconfig.ini';
}
@jtarleton
jtarleton / gist:6063129
Created July 23, 2013 15:09
Finds the intersection of two arrays in a simple fashion.
/**
* finds the intersection of
* two arrays in a simple fashion.
*
* PARAMS
* @param a - first array, must already be sorted
* @param b - second array, must already be sorted
*
* NOTES
*
@jtarleton
jtarleton / gitconfig
Created July 1, 2013 21:01
Good git config commands
git config --global core.editor vim
git config --global color.ui true
git config --global color.diff.meta "blue black bold"
<!doctype html>
<head>
<script src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.9.1.min.js"></script>
<script src="modal.js"></script>
<style type="text/css">
#mask{
position:absolute; /* important */
top:0px; /* start from top */
left:0px; /* start from left */
height:100%; /* cover the whole page */
@jtarleton
jtarleton / gist:5541318
Created May 8, 2013 15:40
jQuery "Check All" / "Uncheck All" for an array of checkbox inputs
<script type="text/javascript">
function listen_for_uncheck_all($checkboxes)
{
jQuery('#uncheckalllink').unbind('click').bind('click', function(){
$checkboxes.removeAttr("checked");
jQuery('#uncheckalllink').html('Check All');
listen_for_check_all($checkboxes);
@jtarleton
jtarleton / redirect_with_id.js
Created February 14, 2013 20:47
URL redirect after prompt for a GET parameter
<script type="text/javascript">
function getPage(id)
{
id = prompt('Enter ID: ');
window.location.href='http://domain.com/module/action?id=' + id;
return false;
}
</script>
@jtarleton
jtarleton / git.txt
Created January 31, 2013 21:03
Initialize a local git repo, push to master branch of the "origin" repo on a remote server
mkdir prj1
cd prj1
git init
touch README
git add .
git commit -m "Added blank readme"
git remote add origin git@server:prj1.git
git push origin master
@jtarleton
jtarleton / array_fns.js
Created January 29, 2013 17:26
Two high-level functions, "array_search" and "array_unique" for good old Javascript.
function arrayUnique(ar)
{
if(ar.length && typeof ar!=='string')
{
var sorter = {};
var out = [];
for(var i=0,j=ar.length;i<j;i++)
{
if(!sorter[ar[i]+typeof ar[i]])
{
@jtarleton
jtarleton / getmongobak.sh
Created January 25, 2013 10:52
Shell script to backup mongoDB to "/dump" in the current working directory
#!/bin/bash
cd /var/ && mongodump
@jtarleton
jtarleton / getmysqlbak.sh
Created January 25, 2013 10:50
Shell script to back up MySQL to a Gzipped file
#!/bin/bash
mysqldump -h localhost -u foouser --password=foopass foodb | gzip > /var/db_backup.sql.gz