Skip to content

Instantly share code, notes, and snippets.

View andrewkdouglas's full-sized avatar

Andrew Douglas andrewkdouglas

View GitHub Profile
@andrewkdouglas
andrewkdouglas / giratchive.sh
Created January 2, 2018 10:01 — forked from markrickert/giratchive.sh
Git Archive Bash Script
#!/bin/bash
# Takes one parameter: a remote git repository URL.
#
# This is the stuff this script does:
#
# 1. Clones the repository
# 2. Fetches all remote branches
# 3. Compresses the folder
# 4. Deletes the cloned folder.
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
@andrewkdouglas
andrewkdouglas / UniqueIndex.sql
Created April 18, 2013 20:31
Remove/prevent duplicate entries in MySQL
ALTER IGNORE TABLE `name` ADD UNIQUE INDEX(`a`,`b`);
@andrewkdouglas
andrewkdouglas / SharepointScroll.jQuery.js
Created April 13, 2013 07:46
Scrolling to an element in Sharepoint using jQuery.
$('#s4-workspace').animate({
scrollTop: $("#elementID").position().top + 80
}, 500);
@andrewkdouglas
andrewkdouglas / Last_insert_id.sql
Created March 28, 2013 22:25
Using LAST_INSERT_ID() to get the last inserted AUTO_INCREMENT value
CREATE TABLE `A` (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(45) NULL ,
`name` VARCHAR(45) NULL ,
PRIMARY KEY (`id`));
CREATE TABLE `B` (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT ,
`aId` BIGINT UNSIGNED NOT NULL ,
`info` VARCHAR(128) NULL ,
@andrewkdouglas
andrewkdouglas / jQuery.CloneCanvas.js
Created March 28, 2013 21:04
Clone a section of DOM with canvas elements using jQuery
// Clone DOM
var originalContent = $('#content');
var newLocation = $('#new-location');
var newContent = originalContent.clone();
newContent.appendTo(newLocation);
// Clone the canvas across
var originalCanvas = originalContent.find('canvas');
var cloneCanvas = newContent.find("canvas");
@andrewkdouglas
andrewkdouglas / RandomStringGenerator.sql
Last active December 15, 2015 07:59
Generate random strings using SQL.
SELECT SUBSTRING(MD5(RAND()) FROM 1 FOR 32) AS `key`;
@andrewkdouglas
andrewkdouglas / IPControl.php
Created March 12, 2013 19:02
A simple IP filter for detecting robots by IP address range.
<?php
class IPControl {
public static $ROBOT_IP_RANGES = array(
array(
'name'=>'Monitoring Server',
'min'=>'173.203.5.0',
'max'=>'173.203.5.127',
),
array(
'name'=>'Search Server',