Skip to content

Instantly share code, notes, and snippets.

View aaronsnoswell's full-sized avatar

Aaron Snoswell aaronsnoswell

  • Australia
View GitHub Profile
@aaronsnoswell
aaronsnoswell / isdef.js
Created December 13, 2011 04:51
Easy js definition checking
/**
* Checks if the given object is defined
*/
function isdef(o) {
if(typeof(o)=="undefined") return false;
return true;
}
@aaronsnoswell
aaronsnoswell / ls.js
Created December 6, 2011 07:31
Easy localStorage caching
/**
* Stores the given key, value pair in localStorage, if it is available
*/
function setLocalStorageValue(key, value) {
if (window.localStorage) {
try {
localStorage.setItem(key, value);
} catch (e) {
// For some reason we couldn't save the value :(
console.log("ERROR | Unable to save to localStorage!", key, value, e);
@aaronsnoswell
aaronsnoswell / t.js
Created December 6, 2011 07:06
Tweet sized JS templating
// Via @thomasfuchs (http://mir.aculo.us/2011/03/09/little-helpers-a-tweet-sized-javascript-templating-engine/)
function t(s, d){
for(var p in d)
s = s.replace(new RegExp('{'+p+'}','g'), d[p]);
return s;
}
@aaronsnoswell
aaronsnoswell / addtopath.sh
Created December 6, 2011 06:08
Add to path
#!/bin/sh
# Adds the given parameter to the path
export PATH=$PATH:$1 && echo "export PATH=\$PATH:$1" >> ~/.bashrc
@aaronsnoswell
aaronsnoswell / LICENSE.txt
Created September 4, 2011 15:27 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Aaron Snoswell http://elucidatedbinary.com
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE