This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# Rails Controller to manage an NFL team's fans | |
# from a email signup form | |
### | |
class FansController < ActionController::Base | |
def create | |
@fan = Fan.new(fan_params) | |
respond_to do |format| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def combine_anagrams(words) | |
h = {} | |
words.map do |word| | |
sort_key = word.each_char.sort.join | |
h[sort_key] ||= [] | |
h[sort_key] << word | |
end | |
h.values | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ApplicationController | |
# perhaps in a mixin | |
def permanent_redirect_to(options) | |
url = case options | |
when String | |
options | |
else | |
url_for(options) | |
end | |
head :moved_permanently, :location => url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install with: | |
# bash < <(curl -L https://raw.github.com/gist/1621689) | |
# | |
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug | |
# | |
# > bundle -v | |
# > Bundler version 1.0.21 | |
echo "Installing ruby-debug with ruby-1.9.3-p0 and Bundler ..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
# wrap elements in blueprintcss-oriented div tags | |
# ex. results.to_blueprint_html('span', 2, 10, 4, 8) | |
def to_blueprint_html(css_class, *args) | |
raise ArgumentError, "args count doesn't match number of elements" if args.size != self.size | |
output = [] | |
each_with_index do |item, index| | |
output << "<div class='#{css_class}-#{args[index]}'>#{item}</div>" | |
end | |
output.last.gsub!(/'>/, " last'>") # last element should have 'last' class assigned |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--// | |
RubyRobot | |
Copyright (c) 2008 Fabio Zendhi Nagao <http://zend.lojcomm.com.br/> | |
Permission is hereby granted, free of charge, to any person | |
obtaining a copy of this software and associated documentation | |
files (the "Software"), to deal in the Software without | |
restriction, including without limitation the rights to use, | |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<settings> | |
<console change_refresh="10" refresh="100" rows="40" columns="120" buffer_rows="999" buffer_columns="120" shell="" init_dir="c:\applications" save_size="0"> | |
<colors> | |
<color id="0" r="0" g="0" b="0"/> | |
<color id="1" r="0" g="0" b="128"/> | |
<color id="2" r="0" g="150" b="0"/> | |
<color id="3" r="0" g="150" b="150"/> | |
<color id="4" r="170" g="25" b="25"/> | |
<color id="5" r="128" g="0" b="128"/> |
NewerOlder