Skip to content

Instantly share code, notes, and snippets.

View baldwindavid's full-sized avatar

David Baldwin baldwindavid

  • Indianapolis, IN
View GitHub Profile
module Movable
def is_movable
include InstanceMethods
end
module InstanceMethods
def whereami
"You are here."
end
{'.' => 1, 'a' => 1.73, 'b' => 1.8, 'c' => 1.51, 'd' => 1.8, 'e' => 1.73, 'f' => 1.05, 'g' => 1.8, 'h' => 1.82, 'i' => 0.78, 'j' => 0.93, 'k' => 1.64, 'l' => 0.78, 'ł' => 0.93, 'm' => 2.73, 'n' => 1.82, 'o' => 1.78, 'p' => 1.8, 'r' => 1.2, 's' => 1.45, 't' => 1.11, 'u' => 1.82, 'w' => 2.91, 'x' => 1.62, 'y' => 1.64, 'z' => 1.45, '0' => 1.78, '1' => 1.78, '2' => 1.78, '3' => 1.78, '4' => 1.78, '5' => 1.78, '6' => 1.78, '7' => 1.78, '8' => 1.78, '9' => 1.78, 'A' => 1.96, 'B' => 1.91, 'C' => 1.96, 'D' => 2.2, 'E' => 1.84, 'F' => 1.71, 'G' => 2.18, 'H' => 2.2, 'I' => 1.22, 'J' => 1.36, 'Ł' => 1.69, 'K' => 1.91, 'L' => 1.63, 'M' => 2.51, 'N' => 2.16, 'O' => 2.31, 'P' => 1.8, 'R' => 2.02, 'S' => 1.82, 'T' => 2.09, 'U' => 2.15, 'W' => 2.93, 'X' => 1.91, 'Y' => 1.89, 'Z' => 1.82, '(' => 1.2, ')' => 1.2, '-' => 1.2, '–' => 1.8, '—' => 2.93, 'nbsp' => 1.11}
$(function() {
$(".flash").livequery(function(){
$(this).delay(5000).fadeThenSlideToggle();
});
});
@baldwindavid
baldwindavid / personal-to-org-account.md
Created December 12, 2011 21:35
How to turn a personal account into an org account

You can turn your personal account into an organization by going to Account Settings > Organizations, clicking "Turn into an organization", and following the instructions in the pop up dialog.

The history of the account and the repositories will be preserved.

I'll explain each point of the warning you'll get:

You will no longer be able to log into YOURACCOUNT (all administrative privileges will be bestowed upon the organization owners you choose)

This just means that you need to choose a new personal account(s) to add as the owner(s) of your new organization. You need to do that anyway, because you can't log in as an organization. You need to create at least one new personal account for you.

class User < ActiveRecord::Base
belongs_to :plan # or however you get your plan - mine is actually not in an AR model
def can_do_cool_thing?
plan.can_do_cool_thing?
end
def can_do_other_cool_thing?
plan.can_do_other_cool_thing?
class Plan
PLANS = [
{
:id => 1,
:name => "Individual",
:can_send => true,
:amount => "???",
:interval => "month",
:trial_period_days => 30,
def plan
Plan.find(plan_id)
end
def plan=(_plan)
self.plan_id = _plan.id
end
@baldwindavid
baldwindavid / Gemfile
Created March 28, 2012 14:52
The guts of a page tree using slugs - acts_as_tree, friendly_id - Allows for routes like /about/our-people/developers
gem 'acts_as_tree'
gem "friendly_id", "~> 4.0.1"
@baldwindavid
baldwindavid / thes.rb
Created April 10, 2012 19:42
Simple script to query thesaurus entries - Get an api key and then point to the file via bash_profile (e.g. alias thes='ruby ~/whateverpath/thes.rb)
require 'rubygems'
require 'net/http'
require 'uri'
require 'json'
require 'cgi'
# 1) Get an api key - http://words.bighugelabs.com/api.php
# 2) Point to the file via bash_profile (e.g. alias thes='ruby ~/whateverpath/thes.rb)
# 3) From command line type... thes dog or thes cool
if ($.browser.msie && $.browser.version == 7) {
$(function() {
var zIndexNumber = 1000;
$("div").each(function() {
$(this).css('zIndex', zIndexNumber);
zIndexNumber -= 10;
});
});
}