Skip to content

Instantly share code, notes, and snippets.

View adamrobbie's full-sized avatar

Adam Robbie adamrobbie

View GitHub Profile
@adamrobbie
adamrobbie / renameRailsProject
Created May 9, 2012 14:24
Rename a Ruby on Rails project with this command
grep -Ri 'oldprojectame' * | cut -f1 -d':' | sort | uniq
@adamrobbie
adamrobbie / Autosave
Created June 19, 2012 12:34
A javascript that can add autosave to any form
setInterval(function(){
var form = $('#my-form-id');
var method = form.attr('method').toLowerCase(); // "get" or "post"
var action = form.attr('action'); // url to submit to
$[method](action, form.serialize(), function(data){
// Do something with the server response data
// Or at least let the user know it saved
});
},10000);
@adamrobbie
adamrobbie / Restart Apple Bluetooth via commandline
Created June 19, 2012 20:42
Some 3rd party bluetooth devices will cause input lag when a Mac OSX is awoken from sleep. This snippet will unload and reload the bluetooth plist resolving the issue.
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.blued.plist && launchctl load /System/Library/LaunchDaemons/com.apple.blued.plist
@adamrobbie
adamrobbie / Example html
Created June 19, 2012 22:09 — forked from barryvdh/Example html
Sticky Footer (Less)
<div class="wrapper">
<div class="container">
<header>
</header>
<div id="content">
</div>
</div>
<div class="footer-push"></div>
@adamrobbie
adamrobbie / spinner screen script
Created June 22, 2012 17:30
set a cookie on the response of the download request and have JavaScript to poll for that cookie. Once the download is ready to be served, the cookie will be available in JavaScript. To ensure working across various browser windows/tabs in the same sessio
function download() {
var token = new Date().getTime();
var wait = document.getElementById("wait");
wait.style.display = "block";
var pollDownload = setInterval(function() {
if (document.cookie.indexOf("download=" + token) > -1) {
document.cookie = "download=" + token + "; expires=" + new Date(0).toGMTString() + "; path=/";
wait.style.display = "none";
clearInterval(pollDownload);
function PrefixInteger(num, length) {
return (Array(length).join('0') + num).slice(-length);
}
@adamrobbie
adamrobbie / guid.js
Created June 24, 2012 23:24
generate static guid via javascript
function S4() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}
function guid() {
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
}
var myID = "static" + guid();
@adamrobbie
adamrobbie / reset.css
Created June 26, 2012 16:25
The CSS Reset
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
@adamrobbie
adamrobbie / getClass.js
Created June 27, 2012 14:32
Utility method to get class of any JS object
function getClass(obj) {
if (typeof obj === "undefined")
return "undefined";
if (obj === null)
return "null";
return Object.prototype.toString.call(obj)
.match(/^\[object\s(.*)\]$/)[1];
}
getClass("") === "String";
@adamrobbie
adamrobbie / cookie.js
Created June 27, 2012 14:53
JS Cookie utility functions [get, set, delete]