Skip to content

Instantly share code, notes, and snippets.

@andyjbas
andyjbas / gist:9962218
Last active June 23, 2020 13:33
Disable CSS Animations in Poltergeist & Phantomjs. Phantomjs does not like to wait for animations, and you can run in to nasty test flickers because of it. This pattern will disable animations in test env, and not touch any app code.
# env.rb or spec_helper.rb

Capybara.register_driver :poltergeist do |app|
  opts = {
    extensions: ["#{Rails.root}/features/support/phantomjs/disable_animations.js"] # or wherever
  }

  Capybara::Poltergeist::Driver.new(app, opts)
end
array = ["andy", "eric", "bloc"]
array.each_with_index do |element, index|
puts "The index of #{element} is #{index}"
end
# => The index of andy is 0
# => The index of eric is 1
# => The index of bloc is 2
class FutureValue
def initialze
end
def annual(rate, years, annual_contribution=0, initial_investment)
pv = self.pv(rate, annual_contribution, years, initial_investment)
pv * (1 + rate)**years
end
# where R is the periodic yield, A is the periodic payment,
// grab new items html
var newItems = "<%= j render(partial: 'endless_append', locals: { items: @feed_items }) %>";
// fetch the scroll position
// used to set the window location back after below hack
var scroll_position = $(window).scrollTop();
// append new items to isotope, as usual
$("#feed_list").append( newItems );
function Car( model, year, miles ) {
this.model = model;
this.year = year;
this.miles = miles;
}
// Note here that we are using Object.prototype.newMethod rather than
function Car( model, year, miles ) {
this.model = model;
this.year = year;
this.miles = miles;
}
// Note here that we are using Object.prototype.newMethod rather than
$("#feed").on("click", ".multicheck", function(e) {
$(this).toggleClass("checked");
toggleSorting(this);
return false;
});
class RPNCalculator
attr_accessor :stack
def initialize
self.stack = Array.new
end
def push(val)
self.stack.push(val.to_f)
end
class Book
def initialize
end
attr_reader :title
def title=(string)
@title = string.titlize
end
Place Div/Tot Div Guntime PerF 1sthalf 2ndhalf 100m Name Club Nettime
===== ======= ===== ======= ==== ======= ======= ====== ========================= ========================== =======
1 1/24 M3034 24:46 866 12:11 12:35 15.88 Andy Bas Prairie Inn Harriers 24:46
2 1/47 M4044 25:03* 856 12:22 12:41 17.52 Some Name Yo Prairie Inn Harriers Runni 25:03