Skip to content

Instantly share code, notes, and snippets.

View amiel's full-sized avatar

Amiel Martin amiel

View GitHub Profile
if (!$.isFunction(Array.prototype.rand)) {
Array.prototype.rand = function() {
function rand(n) { return Math.floor(Math.random() * n); }
return this[rand(this.length)];
};
}
$.konamiRand = (function() {
var fns = [], konami = function() { fns.rand()(); };
$.konami(konami);
new snow leopard install process for homebrew and rvm:
textmate, chrome
ssh-keygen -t rsa
homebrew
Xcode
brew install git
install rvm (http://rvm.beginrescueend.com/rvm/install/)
rvm install ruby-1.8.7
rvm use ruby
var this_will_only_run_once = (function() {
var has_been_run = false; // this private variable will be kept between runs, but doesn't pollute the global namespace
return function() {
if (has_been_run) return; has_been_run = true;
// do stuff here, it will only be run once
};
})();
var mousewheel_handler = (function() {
var threshold = 0.75,
scrolled_amount = 0;
return function(e, delta, deltaX, deltaY) {
scrolled_amount += deltaY;
if (scrolled_amount > threshold) {
move.up();
scrolled_amount = 0;
<%= highlight(t(:'.confirm', :resource => resource, :default => :'delete.confirm'), resource.to_s) %>
<%= semantic_form_for resource, :html => { :method => :delete } do |form| %>
<%= form.buttons do %>
<%= form.commit_button :delete %>
<% end %>
<% end %>
def indefinitize(string)
vowels = "aeiou".split(//)
vowels.include?(string.first.downcase) ? "an #{string}" : "a #{string}"
end
@amiel
amiel / .gitignore
Created November 15, 2010 18:38 — forked from redoPop/.gitignore
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
@amiel
amiel / validation.js
Created November 29, 2010 22:28
very simple custom form validator
var validate = (function() {
var c = { log: function() {} };
// var c = console;
var f = function() {
$(this).each(function() {
var t = $(this);
@amiel
amiel / caveatPatchor.js
Created February 22, 2011 01:31 — forked from protocool/caveatPatchor.js
fork of caveatPatch.js for propane that supports gravatars
/*
As of version 1.1.2, Propane will load and execute the contents of
~Library/Application Support/Propane/unsupported/caveatPatchor.js
immediately following the execution of its own enhancer.js file.
You can use this mechanism to add your own customizations to Campfire
in Propane.
Below you'll find two customization examples.
@amiel
amiel / gist:853544
Created March 3, 2011 20:57
inspect the rack env without seeing too much
env.each do |key, value|
Rails.logger.error("#{key.inspect} => #{value.inspect}"[0..150])
end