Skip to content

Instantly share code, notes, and snippets.

View Badgerati's full-sized avatar
👶
Responses/releases might be delayed

Matthew Kelly Badgerati

👶
Responses/releases might be delayed
View GitHub Profile
@Badgerati
Badgerati / MultiMSBuild.ps1
Last active August 29, 2015 14:21
PowerShell script for cleaning and building multiple projects/solutions in one command line via MSBuild
###########################################################################
# Author: Matthew Kelly (@Badgerati)
# Date: May 14 2015
#
# MSBuildPath: Path to where your MSBuild.exe file resides
# Options: Array of typical MSBuild options such as /p:Configuration or /t:, etc
# Projects: Array of Project/Solution files
# CleanDebug: Switch to clean build in debug mode
# CleanRelease: Switch to clean build int release mode
#
@Badgerati
Badgerati / toDateString.js
Last active March 4, 2016 12:44
Converts the date passed into a string of the format passed.
/**
* Converts the date passed into a string of the format passed.
*
* If the date is null, then today's date is used.
* If the format is null, then a default format of 'dd/MM/yyyy hh:mm:ss' is used.
*
* Possible format attributes are:
*
* - dd - 2 digit date (01, 12, 30).
* - ddd - Ordinal date (1st, 12th, 23rd).
@Badgerati
Badgerati / move-control.js
Created April 4, 2013 21:23
This JavaScript will automatically focus another control depending on the length of the current control's content. This should be called in a control's onkeyup event.
function move(current, next, previous, length) {
if (next != null && current.value.length >= length) {
document.getElementById(next).focus();
}
else if (previous != null && current.value.length <= 0) {
document.getElementById(previous).focus();
}
}
@Badgerati
Badgerati / ie-placeholders.js
Created April 4, 2013 21:15
JavaScript to allow text input fields in IE browsers to have placeholders. Note: the control itself must have the placehoder attribute field present, and jQuery is required.
$(document).ready(
function () {
var ie = navigator.userAgent.match(/msie/i);
if (ie != null) {
//fetch all input elements
var elements = document.getElementsByTagName('input');
var element;
//loop through each, giving appropriates ones placeholders
for (var i = 0; i < elements.length; i++) {
@Badgerati
Badgerati / levenshtein_algorithm.lua
Created August 5, 2012 02:09
An implementation of the Levenshtein distance algorithm in LUA.
-- Returns the Levenshtein distance between the two given strings
function string.levenshtein(str1, str2)
local len1 = string.len(str1)
local len2 = string.len(str2)
local matrix = {}
local cost = 0
-- quick cut-offs to save time
if (len1 == 0) then
return len2