Skip to content

Instantly share code, notes, and snippets.

View brianswisher's full-sized avatar

Brian Swisher brianswisher

View GitHub Profile
@brianswisher
brianswisher / localeDk.js
Created May 1, 2012 21:24
Change locale to dk
var re = /\/..\//gi;
var url = document.location.href;
var pDelim = (url.split('?').length>1) ? '&' : '?';
url = url.replace(re, '/').split('/mobile/').join('/mobile/dk/') + pDelim + 'currencyCode=DKK';
document.location.replace(url);
@brianswisher
brianswisher / localeSe.js
Created May 1, 2012 21:25
Change locale to se
var re = /\/..\//gi;
var url = document.location.href;
var pDelim = (url.split('?').length>1) ? '&' : '?';
url = url.replace(re, '/').split('/mobile/').join('/mobile/se/') + pDelim + 'currencyCode=SEK';
document.location.replace(url);
@brianswisher
brianswisher / localeNo.js
Created May 1, 2012 21:26
Change locale to no
var re = /\/..\//gi;
var url = document.location.href;
var pDelim = (url.split('?').length>1) ? '&' : '?';
url = url.replace(re, '/').split('/mobile/').join('/mobile/no/') + pDelim + 'currencyCode=NOK';
document.location.replace(url);
@brianswisher
brianswisher / localeUa.js
Created May 1, 2012 21:28
Change locale to au
var re = /\/..\//gi;
var url = document.location.href;
var pDelim = (url.split('?').length>1) ? '&' : '?';
url = url.replace(re, '/').split('/mobile/').join('/mobile/au/') + pDelim + 'currencyCode=AUD';
document.location.replace(url);
var util = (function(){
var id,
_target,
content,
css,
style,
format,
container,
html,
insert,
@brianswisher
brianswisher / functionalProgramming.js
Created May 24, 2012 19:00
Functional Javascript Programming
var util = (function( getElementById,
createElement,
argumentsToArray,
innerHTML,
style,
inside,
after,
undefined ){
var cache = function( key, value ){
var rtn, func = arguments.callee;
@brianswisher
brianswisher / queue.js
Created June 15, 2012 05:31
Queue pattern in JavaScript
(function(){
var util = (function(){
var Queue = function Queue(){
var methods = [],
flushed = false,
add = function( fn ){
if( flushed ) {
fn( response );
} else {
methods.push( fn );
@brianswisher
brianswisher / tmp.css
Created June 29, 2012 02:47
temp css
img { margin: 4px; }
@brianswisher
brianswisher / server.js
Last active December 10, 2015 07:48
Zero dependency static node server w/ form post handler. Form posts to "/" will echo submitted values in JSON.
var http = require('http'),
querystring = require('querystring'),
url = require( "url" ),
path = require( "path" ),
fs = require( "fs" );
module.exports = http.createServer(function (req, res) {
var code = 404,
uri = url.parse( req.url ).pathname,
filename = path.join(process.cwd(), uri),
@brianswisher
brianswisher / getIPA.sh
Created January 8, 2013 19:19
Get IP address on OSX Mountain Lion
IP_ADDRESS=`ifconfig en0 | grep inet | grep -v inet6 | awk '{print $2}'`
echo $IP_ADDRESS