Skip to content

Instantly share code, notes, and snippets.

View namlet's full-sized avatar

Nathan Loyer namlet

View GitHub Profile
@namlet
namlet / gist:4332119
Created December 18, 2012 21:21
Get query string parameters from any URI or path.
function getUrlVars(path) {
var vars = {};
var parts = path.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
@namlet
namlet / gist:4112326
Created November 19, 2012 17:56
Twilio connection parameters example
var params = {
'name' : name,
'direction' : 'inbound'
};
connection = Twilio.Device.connect( params );
console.log(connection.parameters);
connection.error(function(error){
console.log("connection error!");
@namlet
namlet / array.remove.js
Created March 29, 2012 19:52
Remove an item from an array by value
Array.prototype.remove = function(itemToRemove) {
var i = 0;
while (i < this.length) {
if (this[i] == itemToRemove) {
this.splice(i,1)
} else {
i++;
}
}
return this;
@namlet
namlet / rightAlign.js
Created June 20, 2011 19:12
Align labels right-justified by making them all the same width as the largest one.
var max = 0;
jQuery("label").each(function(){
if ($(this).width() > max) max = $(this).width();
});
jQuery("label").width(max);
@namlet
namlet / Box Coordinates
Created February 9, 2011 23:37
Maintain selection coordinates using a closure. This example using jQuery.
var boxCoord = function(endCoord) {
var coord = endCoord;
return function(anotherCoord) {
return [anotherCoord, coord];
}
}
$('body').mousedown(function(e){
var thate = e;
$(this).mouseup(function(e){
set nocompatible
syntax on
filetype plugin indent on
set tabstop=4
set shiftwidth=4
set expandtab
set number
set sts=4
set smarttab
set autoindent
alias savehistory="history | cut -c7- >> ~/history.save; sort -u ~/history.save >> ~/history.save.tmp; rm ~/history.save; mv ~/history.save.tmp ~/history.save"
alias remember="cat ~/history.save | grep"
namlet@odin:~$ ssh -vvv -A fapestniegd.xen.prgmr.com
OpenSSH_5.1p1 Debian-5, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to fapestniegd.xen.prgmr.com [173.245.73.171] port 22.
debug1: Connection established.
debug1: identity file /home/namlet/.ssh/identity type -1
debug1: identity file /home/namlet/.ssh/id_rsa type -1
debug1: identity file /home/namlet/.ssh/id_dsa type -1
@namlet
namlet / gist:638577
Created October 21, 2010 14:27
Fix to ApiServlet Class in Shindig PHP Port. Should honor Accept header before Content-Type.
if (isset($_SERVER['HTTP_ACCEPT'])) {
// normalize things like "application/json; charset=utf-8" to application/json
foreach ($acceptedContentTypes as $contentType) {
if (strpos(strtolower($_SERVER['HTTP_ACCEPT']), $contentType) !== false) {
$_SERVER['HTTP_ACCEPT'] = $contentType;
$this->setContentType($contentType);
break;
}
}
}
brahma:shindig nathanloyer$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: content/sampledata/canonicaldb.json
#
# Unmerged paths:
# (use "git reset HEAD <file>..." to unstage)
# (use "git add/rm <file>..." as appropriate to mark resolution)