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
$('#products').append('<%= j render(@products) %>'); | |
<% if @products.next_page %> | |
$('.pagination').replaceWith('<%= j will_paginate(@products) %>'); | |
<% else %> | |
$('.pagination').remove(); | |
<% 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
-----> Heroku receiving push | |
-----> Ruby/Rails app detected | |
-----> Detected Rails is not set to serve static_assets | |
Installing rails3_serve_static_assets... done | |
-----> Configure Rails 3 to disable x-sendfile | |
Installing rails3_disable_x_sendfile... done | |
-----> Configure Rails to log to stdout | |
Installing rails_log_stdout... done | |
-----> Gemfile detected, running Bundler version 1.0.7 | |
Unresolved dependencies detected; Installing... |
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 do | |
module Resque | |
def self.enqueue(klass, *args) | |
klass.perform(*args) | |
end | |
end | |
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
gem 'resque', '>= 1.10.0' | |
gem 'heroku' # You will need the heroku gem for this too. |
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
#!/usr/bin/env ruby | |
param = ARGV.first | |
class Fixnum | |
def is_cachipulis? | |
length = self.to_s.length | |
digits = self.to_s.split('').map(&:to_i) | |
return false if digits.inject(&:+) != length |
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
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
module Player | |
describe MovieList, "with optional description" do | |
it "is pending example, so that you can write ones quickly" | |
it "is already working example that we want to suspend from failing temporarily" do | |
pending("working on another feature that temporarily breaks this one") |
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
# delay the GC - usage as below | |
# Spec::Runner.configure do |config| | |
..... | |
# config.before(:each) do | |
# begin_gc_deferment | |
# end | |
# config.after(:each) do |
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 'json' | |
class JsonFormatter | |
METHODS = %w[start close stop start_dump dump_pending dump_failures dump_summary] | |
METHODS.each { |m| define_method(m) { |*a| } } | |
def initialize(out) | |
@output = out | |
@event_id = 0 | |
@passed = true |
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 SimpleLinearRegression | |
def initialize(xs, ys) | |
@xs, @ys = xs, ys | |
if @xs.length != @ys.length | |
raise "Unbalanced data. xs need to be same length as ys" | |
end | |
end | |
def y_intercept | |
mean(@ys) - (slope * mean(@xs)) |
OlderNewer