Skip to content

Instantly share code, notes, and snippets.

View kaimallea's full-sized avatar
:octocat:

Kai Mallea kaimallea

:octocat:
View GitHub Profile
@kaimallea
kaimallea / bitly.js
Created October 5, 2010 06:32
JSONP implementation of the bit.ly API for dynamic URL shortening
/**
* JSONP implementation of the bit.ly API for dynamic
* URL shortening
*
* @author = "Kai Mallea ([email protected])"
*
* TODO: Add domain param to choose between bit.ly and j.mp
*/
@kaimallea
kaimallea / gist:712602
Created November 23, 2010 21:48
Citrix Query User
##################################################################
## Citrix User Query ##
## ##
## Usage: Invoke on a Citrix server with path to a text file ##
## containing server names, delimited by new line chars ##
##################################################################
# Only required parameter is a list of servers
param([string]$serverlist = $(Throw "No server list specified."))
@kaimallea
kaimallea / Find Manual Drive Mappings
Created March 22, 2011 15:29
A PowerShell (v2) script to iterate through a list of computers and identify manual mappings for each user profile. Hopefully, you've followed best practices and won't need to run this in your environment. ;)
<#
Find Manual Drive Mappings
Created Mar. 19 2011 by Kai Mallea ([email protected])
License: http://www.opensource.org/licenses/mit-license.php
#>
@kaimallea
kaimallea / ircbot.go
Created August 3, 2011 14:59
Useless IRC bot
package main
import (
"fmt"
"net/textproto"
"regexp"
)
var (
ping = regexp.MustCompile("^PING :([a-zA-Z0-9\\.]+)$")
@kaimallea
kaimallea / gobot.go
Created August 3, 2011 18:09
GoBot, a useless IRC bot in Go
package main
import (
"fmt"
"net/textproto"
"regexp"
"strings"
"os"
)
@kaimallea
kaimallea / getHighIndex.js
Created August 19, 2011 21:42
Return the highest z-Index used across all elements
/**
* Return the highest z-Index used across all elements
**/
function getHighIndex (selector) {
// No granularity by default; look at everything
if (!selector) { selector = '*' };
var elements = document.querySelectorAll(selector) ||
oXmlDom.documentElement.selectNodes(selector),
i = 0,
@kaimallea
kaimallea / gist:1405745
Created November 29, 2011 18:03
Add commas (or your own separator) to numbers
function separateNumbers (n, sep) {
n = n.toString().split('');
var i = n.length - 3;
for (; i > 0; i-=3) {
n.splice(i, 0, (sep ? sep : ','));
}
return n.join('');
}
@kaimallea
kaimallea / extend.js
Last active September 28, 2015 11:48
Deep copy (recursively) properties from one object into another
/*
* Extend an object
*
* Deep copies (recursively) properties from source into target
*/
function extend (target, source) {
var prop;
for (prop in source) {
if (Object.prototype.hasOwnProperty.call(source, prop)) {
if (typeof source[prop] === 'object') {
@kaimallea
kaimallea / titlecase.js
Created December 6, 2011 17:26
Convert a string to Title Case
function titleCase (str) {
var array = str.split(' '),
len = array.length,
i = 0;
for (; i < len; i+=1) {
array[i] = array[i][0].toUpperCase() + array[i].slice(1);
}
return array.join(' ');
@kaimallea
kaimallea / khan.js
Created February 15, 2012 20:52
Khan Academy API JS Wrapper
var khan = (function (document) {
var _head = document.getElementsByTagName('head')[0],
_reusable_script_ele = document.createElement('script'),
_default_host = 'http://www.khanacademy.org/api/v1/';
var _jsonp = function (url) {
var script = _reusable_script_ele.cloneNode(false);
script.src = url;
_head.appendChild(script);
};