Skip to content

Instantly share code, notes, and snippets.

View jsmestad's full-sized avatar
👾

Justin Smestad jsmestad

👾
View GitHub Profile
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);
NameVirtualHost *:80
<VirtualHost *:80>
ServerName build.evalcode.com
# ServerAlias build.evalcode.com
# ServerAlias build.evalcode.com
DocumentRoot /home/jsmestad/sites/build/public
# RackBaseURI /
</VirtualHost>
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
def display
result = open(gist_url).read
return result.scan(/document.write\('(.*|\s*)'\)/)[1][0]
end
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 )})"
} }
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])
#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'"])
# Working example
def test &block
bind = yield 1, 2, 3
p eval('local_variables', bind)
end
test do |just, some, params|
binding
end
before_filter :fetch_proper_params, :only => [:show]
def show
render
end
private
def fetch_proper_params
@course = Course.find(params[:course_id])