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
@posts.paginate(:page => params[:page], | |
:per_page => 20, | |
:sort => [['added', :asc]]) |
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
match 'post/by_tag/:tag', | |
:to => 'posts#by_tag', | |
:as => 'posts_by_tag', | |
:tag => /[A-Za-z0-9\-_\.]*/ |
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
if last_vote_date.nil? || last_vote_date.utc < 1.day.ago | |
self.last_vote_date = Time.now | |
self.votes_per_day = 1 | |
else | |
self.votes_per_day += 1 | |
end | |
if self.votes_per_day <= 10 | |
self.reputation += 1 | |
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
require 'spec_helper' | |
describe User, ".add_reputation via voting" do | |
before(:each) do | |
@user = User.new | |
@user.reputation.should == 1 | |
end | |
it "adds one rep" do | |
@user.add_reputation(:voting) |
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
1) DestinationsController GET index assigns all destinations as @destinations | |
Failure/Error: get :index | |
bad argument(expected URI object or URI string) | |
# ./spec/requests/destinations_controller.spec:14:in `block (3 levels) in <top (required)>' |
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
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading; | |
using Dimebrain.TweetSharp.Extensions; | |
using Dimebrain.TweetSharp.Fluent; | |
using Dimebrain.TweetSharp.Model; | |
using NHibernate; | |
using NHibernate.Criterion; |
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
$(document).ready(function() { | |
$('.edit_area').editable('/fragments/1/save', { | |
loadurl : '/fragments/1/load_markup', | |
type : 'textarea', | |
cancel : 'Cancel', | |
submit : 'OK', | |
onblur : 'submit', | |
indicator : '<img src="/assets/rails.png">', | |
tooltip : 'Click to 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
public class Order | |
{ | |
public int OrderId {get; private set;} | |
public List<Orderlines> Orderlines {get; private set;} | |
} | |
public class Orderline | |
{ | |
public string Item {get; private set;} | |
public int Quantity {get;private set;} |
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
# How do I return 'data' as the result of save_it ? | |
save_it = (edited_value, s) -> | |
$.post(url_to_save_to, {value: edited_value}, (data) -> data) |
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
using (new TimeIt()) { command.Execute(); } | |
public class TimeIt : IDisposable | |
{ | |
private readonly TextWriter output; | |
private readonly Stopwatch watch; | |
public TimeIt() : this(Console.Out) {} | |
public TimeIt(TextWriter output) |