Skip to content

Instantly share code, notes, and snippets.

View deivinsontejeda's full-sized avatar
🎯

Deivinson Tejeda deivinsontejeda

🎯
  • Santiago of Chile
View GitHub Profile
@deivinsontejeda
deivinsontejeda / index.js.erb
Created December 19, 2011 01:31 — forked from ryanb/index.js.erb
Infinite scrolling solution covered in revised episode #114: http://railscasts.com/episodes/114-endless-page-revised
$('#products').append('<%= j render(@products) %>');
<% if @products.next_page %>
$('.pagination').replaceWith('<%= j will_paginate(@products) %>');
<% else %>
$('.pagination').remove();
<% end %>
@deivinsontejeda
deivinsontejeda / gist:1495058
Created December 19, 2011 01:33 — forked from mattmanning/gist:1165497
bundler unicode
-----> 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...
@deivinsontejeda
deivinsontejeda / resque.rb
Created April 18, 2012 17:30 — forked from aeden/resque.rb
Place in features/support to make Resque workers execute immediately
Before do
module Resque
def self.enqueue(klass, *args)
klass.perform(*args)
end
end
end
gem 'resque', '>= 1.10.0'
gem 'heroku' # You will need the heroku gem for this too.
#!/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
@deivinsontejeda
deivinsontejeda / rspec-syntax-cheat-sheet.rb
Created September 3, 2012 01:09 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# 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")
# delay the GC - usage as below
# Spec::Runner.configure do |config|
.....
# config.before(:each) do
# begin_gc_deferment
# end
# config.after(:each) do
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
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))