Skip to content

Instantly share code, notes, and snippets.

View toadkicker's full-sized avatar
🏠
Let's fix some stuff

Todd Baur toadkicker

🏠
Let's fix some stuff
View GitHub Profile
@toadkicker
toadkicker / Capistrano-Deployment-Recipe.rb
Created June 6, 2012 04:18 — forked from gsohoni/Capistrano-Deployment-Recipe.rb
a "base" Capistrano Rails Deployment Recipe. Use it to deploy your Rails application. It is also easily expandable. So feel free to grab this Recipe and add your own tasks/customization!
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
@toadkicker
toadkicker / gist:3445740
Created August 24, 2012 05:17 — forked from egonelbre/gist:3437746
State Machine
function Machine(first, $){
var cur = {}, next = $[first];
var self = {
go : function(to){ next = next ? next : ($[to] || $.undefined); },
trigger : function(event){ self.go( cur.tx && cur.tx[event] ); }
};
return function(){
if(next){
cur.exit && cur.exit.call(self);
class KeyGenerator
require "digest/sha1"
def self.generate(length = 10)
Digest::SHA1.hexdigest(Time.now.to_s + rand(12341234).to_s)[1..length]
end
end
@toadkicker
toadkicker / gist:5689216
Created June 1, 2013 03:44
Useful aliases for git
#ignore file(s), add file(s), list file(s)
assume = update-index --assume-unchanged
unassume = update-index --no-assume-unchanged
assumed = "!git ls-files -v | grep ^h | cut -c 3-"
#call your last stash a snapshot
snapshot = !git stash save "snapshot: $(date)" && git stash apply "stash@{0}"
#merging
ours = "!f() { git checkout --ours $@ && git add $@; }; f"
@toadkicker
toadkicker / gist:5753359
Last active December 18, 2015 08:19
Helpful JS extensions
Storage.prototype.setObject = function(key, value) {
this.setItem(key, JSON.stringify(value));
}
Storage.prototype.getObject = function(key) {
return JSON.parse(this.getItem(key));
}
// Extend the default Number object with a formatMoney() method:
// usage: someVar.formatMoney(decimalPlaces, symbol, thousandsSeparator, decimalSeparator)
@toadkicker
toadkicker / gist:5768516
Created June 12, 2013 19:52
delay(function, time)
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
# Install Dependencies
# sudo apt-get install build-essential
# sudo apt-get build-dep php5
sudo apt-get install libmysqlclient-dev mysql-client libcurl4-openssl-dev libgd2-xpm-dev libjpeg-dev libpng3-dev libxpm-dev libfreetype6-dev libt1-dev libmcrypt-dev libxslt1-dev bzip2 libbz2-dev libxml2-dev libevent-dev libltdl-dev libmagickwand-dev libmagickcore-dev imagemagick libreadline-dev libc-client-dev libsnmp-dev snmpd snmp libvpx-dev libxpm-dev libgmp3-dev libicu-dev libpspell-dev libtidy-dev freetds-dev unixodbc-dev librecode-dev libglib2.0-dev libsasl2-dev libgeoip-dev imagemagick libmagickcore-dev libmagickwand-dev
# Stop Apache
sudo service apache2 stop
# Cleanup Packages
sudo apt-get autoremove
@toadkicker
toadkicker / gist:5822980
Last active December 18, 2015 17:59
jQuery vs native
//ajax
$.ajax({
url: '/endpoint'
}).done(function(data){
// do something awesome
}).fail(function(xhr){
// sad little dance
});
var xhr = new XMLHttpRequest();
@toadkicker
toadkicker / gist:5827724
Created June 20, 2013 23:37
I wanted a way to have an inner gradient in a button with CSS3, and started working on input type="button"
<!DOCTYPE html>
<html>
<head>
<title>Fun with Buttons</title>
<style>
/*structure*/
.button, input[type="button"] {
box-shadow: .1em .2em .5em #aaa;
height: 22px;
display: block;
// Example:
JavaScript.load("/javascripts/something.js");
// With callback (that’s the good thing):
JavaScript.load("http://www.someawesomedomain.com/api.js", function() {
API.use(); // or whatever api.js provides ...
});