Skip to content

Instantly share code, notes, and snippets.

View craigmr's full-sized avatar

Craig Simpson craigmr

View GitHub Profile
@craigmr
craigmr / gist:c83320db1d230210b8b3
Last active August 29, 2015 14:20
Chained Async Calls to Prevent Race Conditions
/**
* calculateZChained() Chain the two aysnc calls together to fix the race condition.
*/
function calculateZChained() {
let x = 0, y = 0, z;
//Async call to get the true value of y
setTimeout(() => {
y = 2;
@craigmr
craigmr / gist:5e83e12fb2e102c7b43f
Last active August 29, 2015 14:20
Example of Race Condition
/**
* calculateZ() is a simplified version of a race conidtion. We have two ansync tasks
* that modifiy the state before each call is complete.
*/
function calculateZ() {
let x = 0, y = 0, z;
//Async call to get the true value of y
setTimeout(() => y = 2, Math.random() * 1000);
@craigmr
craigmr / user-exentsions.js
Created July 11, 2013 18:23
So at work we are setting up a selenium RC 1 grid. We decided to use RC1 and not web drivers since we can setup user-extensions to create locations and custom actions for our QA team. We’ve slowly got the grid running with our python test cases running the client drivers. Somewhere in the setup (we still don’t know the cause) our user extensions…
//This is a fix to get the user-extensions working for RC. The check is to prevent a runtime error in the IDE
//since the IDE does not contain command factory.
if(this['commandFactory']){
commandFactory.registerAll(selenium);
}