Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am andyjbas on github.
* I am andyjbas (https://keybase.io/andyjbas) on keybase.
* I have a public key whose fingerprint is 19BC E9F2 DD9B 539E 74DF B057 9D97 AC59 EA27 12EC
To claim this, I am signing this object:
http://www.testflightapp.com/install/da6b118ced23896df5cf2bfbef91706f-MTIwNTI2OTU/
@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