Skip to content

Instantly share code, notes, and snippets.

Dallas Reedy dallas

Block or report user

Report or block dallas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dallas
dallas / fun with Fib.rb
Created Aug 13, 2009
having fun with Hash initializer and the Fibonacci Sequence
View fun with Fib.rb
# Having some fun with a simple Fibonacci sequence Hash!
fibonacci = Hash.new {|hash, key| hash[key] = hash[key - 1] + hash[key - 2]}
#=> {}
# Gotta get things started here…
fibonacci[1] = 1
#=> 1
@dallas
dallas / aliases.zsh
Created Dec 19, 2012
zshell aliases
View aliases.zsh
# Shell commands
alias @='pwd'
# Bundler
alias brake='bundle exec rake'
alias be='bundle exec'
# Rails 2
alias sc='script/console'
alias sg='script/generate'
@dallas
dallas / rails31init.md
Created Sep 11, 2011 — forked from docwhat/rails31init.md
Rails 3.1 with Rspec, Factory Girl, Haml, Simple Form, Database Cleaner, Spork, and Guard
View rails31init.md

Install Rails 3.1

gem install rails

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

@dallas
dallas / _smart_enumerator.rb
Created Jun 13, 2011
Smart enumerator with smart enumerable items
View _smart_enumerator.rb
class SmartEnumerator < Enumerator
attr_reader :length
def initialize(enumerable)
super
@length = enumerable.length
end
def each
self.each_with_index do |item, index|
View base.css
body, table, td, th, p, a, img { margin:0 auto; padding:0; }
thead, tbody, tr { margin:0; padding:0; }
body, table.body-table, table.body-table td.body-td {
background-color:#ffffff;
color:#333333;
font-family:"Lucida Grande", Arial, Helvetica, sans-serif;
font-size:16px;
line-height:24px;
margin:0;
@dallas
dallas / sum.js
Created May 13, 2010
creating sum functions as an exercise
View sum.js
// Sums all "number" arguments given. This includes floats by default.
//
// sum(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); //=> 55
// sum(1, "hey", 2, "3", 4, "five", 6, 'hi!', 7, 8.2, 9, 10); //=> 47.2
function sum() {
var sum = 0;
for (i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if (typeof arg === 'number') sum += arg;
}
@dallas
dallas / string.rb
Created Feb 16, 2010
add single-word boolean methods to String
View string.rb
class String
# alias the method_missing method chain so that we can use single-word booleans
# for example, we can do things like "standard".standard? which will give us true
# obviously this is most suited for cases where you have a variable with a value from a known set of values
def method_missing_with_single_word_booleans(method_name, *args, &block)
return method_missing_without_single_word_booleans(method_name, *args, &block) unless method_name.to_s =~ /^(\w+)\?$/
self == $1
end
alias_method_chain :method_missing, :single_word_booleans
end
@dallas
dallas / flash_message.rb
Created Dec 3, 2009
The beginnings of Flashtastic!
View flash_message.rb
# Create a ViewHelper class or module (whatever) for dealing with flash messages in an easy-to-use format
# the current way:
<%- if flash[:error] -%>
<p class="error"><%= flash[:error] %></p>
<%- end -%>
<%- if flash[:notice] -%>
<p class="notice success">
<%= flash[:notice] %> <%= link_to('View Now', view_post_path) if post_created %>
</p>
@dallas
dallas / gist:178685
Created Aug 31, 2009
IRb enhancements & settings
We couldn’t find that file to show.
@dallas
dallas / gist:176414
Created Aug 27, 2009 — forked from laserlemon/gist:175993
software install directions by laserlemon
View gist:176414
# Leopard Development Environment (from clean installation)
# Replace USERNAME with your OS X short name.
# Replace PASSWORD with your MySQL root password.
# Install XCode Tools
# Install MacPorts
# Install Textmate
# Generate an SSH key
ssh-keygen
You can’t perform that action at this time.