Skip to content

Instantly share code, notes, and snippets.

View brianpeiris's full-sized avatar

Brian Peiris brianpeiris

View GitHub Profile
@brianpeiris
brianpeiris / gist:203735
Created October 7, 2009 04:05
Fix for minor bug in the autogrow jQuery plugin
/*
* Auto Expanding Text Area (1.2.2)
* by Chrys Bader (www.chrysbader.com)
* chrysb@gmail.com
*
* Special thanks to:
* Jake Chapa - jake@hybridstudio.com
* John Resig - jeresig@gmail.com
*
* Copyright (c) 2008 Chrys Bader (www.chrysbader.com)
@brianpeiris
brianpeiris / gist:211909
Created October 16, 2009 17:41 — forked from danwrong/gist:175591
A serializeHash plugin for jQuery that allows you to submit a form using jQuery's ajax functions.
/***
The serializeHash method can be used to submit forms with an ajax request.
The result of serializeHash can be used as the 'data' option for jQuery's
built-in ajax methods and functions.
***/
(function($){
$.fn.serializeHash = function() {
var hash = {};
/***
Use serializeArray() to get an array of JSON objects for
@brianpeiris
brianpeiris / dynamicMultiSelect.html
Created November 1, 2009 09:57
Prototype dynamic multi-select
<!doctype html>
<html lang="en">
<head>
<title>dynamicMultiSelect</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type='text/javascript' src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
<style>
button {
display: block;
@brianpeiris
brianpeiris / radioCheckboxHybrid.html
Created November 1, 2009 18:15
Prototype hybrid checkbox/radio control
<!doctype html>
<html lang="en">
<head>
<title>radioCheckboxHybrid</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<style type="text/css">
label{display:block;}
</style>
</head>
@brianpeiris
brianpeiris / gist:236045
Created November 16, 2009 15:07
jQuery disabled plugin
<!doctype html>
<html lang="en">
<head>
<title>jQuery.fn.disabled()</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type='text/javascript' src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
<style>
[disabled] {
border: 1px dashed blue; outline: 1px dashed red; background-color: green;
@brianpeiris
brianpeiris / gist:248791
Created December 4, 2009 02:42
String RegExp matches function
/***
The matches function, similar to String.match(),
returns an array of sub-groups captured by the given RegExp.
***/
function matches(string, regexp, position, result) {
position = position || 0;
result = result || [];
var match = string.slice(position).match(regexp);
@brianpeiris
brianpeiris / filterJSON.js
Created January 30, 2010 04:50
filterJSON by Jeffrey Way (edited to allow more complex JSON hierarchies)
/*
* filterJSON v.9.2 - http://www.jeffrey-way.com
* Last Updated: January 29, 2009
* When you attach a JSON file, it will parse it with getJSON, and then allow you to filter through and display the items on the page according to
* a specified limit, delay, transition, etc.
* Developed by Jeffrey Way
* http://jeffrey-way.com/filterjson-a-jquery-plugin/
* jeffrey@effrey-way.com
REM ########################################################################
REM # 2010-07-03T15:52Z
REM # brianpeiris
REM # Andrew Lipsky's original code. From http://bit.ly/aPDYvN
REM #
REM # 2010-07-03T15:54Z
REM # brianpeiris
REM # Removed empty lines
REM ########################################################################
@brianpeiris
brianpeiris / gist:3668357
Created September 7, 2012 18:23
Powershell script for dealing with running applications
function list-windows () {
ps | ?{$_.mainwindowtitle} | select processname, mainwindowtitle | ft -a
}
set-alias lw list-windows
function levdis ($strA, $strB) {
$n = $strA.Length;
$m = $strB.Length;
$d = @();
param ([string] $Path = (Get-Location))
function Get-MD5 (
[System.IO.FileInfo]
$file = $(throw 'Usage: Get-MD5 [System.IO.FileInfo]')
) {
# This Get-MD5 function sourced from:
# http://blogs.msdn.com/powershell/archive/2006/04/25/583225.aspx
$stream = $null
$hashAlgorithm = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider