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
jQuery(function() { | |
function follow() { | |
var self = $(this); | |
$.post(this.href + ".js", { "shortcode": this.id }, null, "script"); | |
self.removeAttr('href').unbind('click'); | |
return false; | |
} | |
function unfollow() { | |
var self = $(this); |
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
NameVirtualHost *:80 | |
<VirtualHost *:80> | |
ServerName build.evalcode.com | |
# ServerAlias build.evalcode.com | |
# ServerAlias build.evalcode.com | |
DocumentRoot /home/jsmestad/sites/build/public | |
# RackBaseURI / | |
</VirtualHost> |
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
Feature: Manage Snippets | |
Scenario: Submit New Snippet | |
Given I am logged in | |
And I visit the main page | |
When I click "Submit New" | |
And I fill in "Title" with "Rails 3 Commit" | |
And I fill in "Code" with "def hello(thing)" | |
And I press "Submit" | |
Then it should be successful |
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 display | |
result = open(gist_url).read | |
return result.scan(/document.write\('(.*|\s*)'\)/)[1][0] | |
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
named_scope :in_default_region, lambda{ { | |
:include => :region, | |
:conditions => ['regions.id = ?', Region.default] | |
}} | |
named_scope :regional_and_or_default, lambda{ |key| { | |
:include => [:region], | |
:conditions => ['association = ? AND ( region_id = ? OR region_id = ? )', key, self.current_region, Region.default], | |
:order => "FIELD(region_id, #{id_or_null( self.current_region )}, #{id_or_null( Region.default )})" | |
} } |
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 show | |
if params[:course_id] && permitted_to?(:browse, :videos) | |
@course = Course.find(params[:course_id]) | |
@video = @course.videos.find(:first) | |
add_crumb("Watching #{@video.title}", course_video_path(@course, @video)) | |
elsif params[:course_id] | |
@course = Course.find(params[:course_id]) | |
@video = @course.videos.find(params[:id]) |
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 link_to_project(name, project, options = {}, html_options = {}) | |
defaults = { | |
:action => 'show', | |
:method => :get | |
} | |
options = defaults.merge! options | |
case options[:action] | |
when 'show' | |
url = @company ? [@company, project] : project | |
when 'edit' |
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
#players = select distinct(player) from actions; | |
players = repository(:default).adapter.query('select distinct(player) from actions') | |
@players = [] | |
players.each do |name| | |
player = {} | |
player["name"] = name | |
player["won"] = Action.sum(:amount, :conditions => ["player = '#{name}' and amount != 'NULL' and (type = 'award' or type = 'return')"]) | |
player["lost"] = Action.sum(:amount, :conditions => ["player = '#{name}' and amount != 'NULL' and type != 'award' and type != 'return'"]) |
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
# Working example | |
def test &block | |
bind = yield 1, 2, 3 | |
p eval('local_variables', bind) | |
end | |
test do |just, some, params| | |
binding | |
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
before_filter :fetch_proper_params, :only => [:show] | |
def show | |
render | |
end | |
private | |
def fetch_proper_params | |
@course = Course.find(params[:course_id]) |