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 to wait for the Stripe elements to load, depending on your implementation.
Read More
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();}
Read More
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 deploy_to is the deploy_to capistrano configuration setting. This way the configuration parameters are not stored [...]
Read More
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” option near the bottom of the “Player Settings” dialog. - Check the “Vuforia Augmented Reality” [...]
Read More
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 prize = prizes[available_selections[1]] else prize = prizes[available_selections[0]] end results[:wins] += 1 if prize == 1 [...]
Read More
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: The program 'bundle' is currently not installed. You can install it by typing: sudo apt-get [...]
Read More