Skip to content

Instantly share code, notes, and snippets.

Andrew Douglas adouglas

View GitHub Profile
@adouglas
adouglas / giratchive.sh
Created Jan 2, 2018 — forked from markrickert/giratchive.sh
Git Archive Bash Script
View giratchive.sh
#!/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.
View .bashrc
# ---------------------------------------------------------------------------
#
# 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
View osx-for-hackers.sh
#!/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'
@adouglas
adouglas / UniqueIndex.sql
Created Apr 18, 2013
Remove/prevent duplicate entries in MySQL
View UniqueIndex.sql
ALTER IGNORE TABLE `name` ADD UNIQUE INDEX(`a`,`b`);
@adouglas
adouglas / SharepointScroll.jQuery.js
Created Apr 13, 2013
Scrolling to an element in Sharepoint using jQuery.
View SharepointScroll.jQuery.js
$('#s4-workspace').animate({
scrollTop: $("#elementID").position().top + 80
}, 500);
@adouglas
adouglas / Last_insert_id.sql
Created Mar 28, 2013
Using LAST_INSERT_ID() to get the last inserted AUTO_INCREMENT value
View Last_insert_id.sql
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 ,
@adouglas
adouglas / jQuery.CloneCanvas.js
Created Mar 28, 2013
Clone a section of DOM with canvas elements using jQuery
View jQuery.CloneCanvas.js
// 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");
@adouglas
adouglas / RandomStringGenerator.sql
Last active Dec 15, 2015
Generate random strings using SQL.
View RandomStringGenerator.sql
SELECT SUBSTRING(MD5(RAND()) FROM 1 FOR 32) AS `key`;
@adouglas
adouglas / IPControl.php
Created Mar 12, 2013
A simple IP filter for detecting robots by IP address range.
View IPControl.php
<?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',
You can’t perform that action at this time.