Author: anthony

Test Stripe.js Elements with Capybara

To access and test Stripe.js Element objects with Capybara, try the following: card_frame = page.evaluate_script(“$(\”iframe[src*=’fieldName’]\”).attr(\”name\”)”) within_frame card_frame do   find(“.InputElement”).set(“value”) end Where fieldName is the name of the Stripe.js Element, for example ‘cardNumber’, and the value is whatever you would like to set the field value to (e.g. 4242 4242 4242 4242) Note, you may need […]

Github: Expand all collapsed files in PR diffs

GitHub will occasionally hide the Diff for various files in your pull requests (PRs). During a large review, this can get a little annoying. I wanted to avoid installing an extension to solve the problem, so this code will open each of the “Load Diff” areas automatically from the console: for(i=0; iā€¹document.getElementsByClassName(“js-button-text”).length; i++){ document.getElementsByClassName(“js-button-text”)[i].click();}

Rails, Capistrano, Database.yml

I’ve found the easiest way to manage the config/database.yml file in a Rails + Capistrano configuration is to add the following line to your capistrano config/deploy.rb configuration file: set :linked_files, %w{config/database.yml} Then add config/database.yml to your .gitignore file. After which, add your environment’s database.yml file to the appropriate location on the remote server(s): #{deploy_to}/appname/shared/config/database.yml Where […]

Activate Vuforia in Unity 2017.2+

To activate Vuforia in Unity 2017.2+ – Open the “File” menu in the main top menu of Unity. – Select “Build Settings” – In the lower left corner of the “Build Settings” dialog, click the “Player Settings” option – This will open the “Player Settings” dialog in your inspector panel. – Click the “XR Settings” […]

Monty Hall Problem in Ruby

Just for fun, the monty hall problem in ruby. Runs simulation one million times. def monty_hall(switch) results = {switching: switch, wins: 0, losses: 0, count: 0, win_percentage: 0} (10**6).times.each do |n| prizes = [0,0,1].shuffle initial_selection = (0..2).to_a.sample other_doors = (0..2).to_a – [initial_selection] goat = other_doors.select{|n| prizes[n]==0}.sample available_selections = [initial_selection, (0..2).to_a – [initial_selection, goat]].flatten if switch […]

Capistrano, Rbenv, bundle: command not found

After running cap production deploy:restart   Our remote Puma log would show the following: -su: bundle: command not found   However, this was an active production server, so the bundler gem existed. After logging in and attempting to run a simple command, such as: bundle exec rails console   The console would output the following: […]