Skip to content

Instantly share code, notes, and snippets.

@dlai0001
dlai0001 / useState.js
Created April 2, 2022 11:42
A crude use state implementation
// For Reference
const states = []
let calls = -1
function useState(value) {
const call = ++calls
if (states[call]) {
return states[call]
#!/bin/bash
############################################################
##### Easy setup script for Mac OSX Yosemite or Higher #####
##### Sets up apps and tools useful to SDETs on Mac. #####
##### #####
##### Note: you may be prompted to enter your password #####
##### At certain times during the install #####
############################################################
@dlai0001
dlai0001 / monitorlocust.js
Created July 1, 2016 18:27
Monitor peak requests per second and average rps in locust.io
ax_peak = 0;
ax_avg = 0;
ax_count = 0;
setInterval(function() {
rps = parseFloat($("#total_rps").text())
ax_avg = (ax_avg * ax_count + rps) / (++ax_count);
if(rps > ax_peak) {
ax_peak = rps;
@dlai0001
dlai0001 / GridHubInstall.ps1
Last active March 22, 2016 14:07
Boxstarter formula for settings up Selenium Grid
##############################################################################################
# Powershell script for installing Selenium Grid Extras in Hub Mode
# Navigate with internet explorer to:
# http://boxstarter.org/package/nr/url? + raw gist url
#
##############################################################################################
# Boxstarter options
$Boxstarter.RebootOk=$true # Allow reboots?
$Boxstarter.NoPassword=$false # Is this a machine with no login password?
@dlai0001
dlai0001 / Tester Setup
Last active August 29, 2015 14:01
selenium server
cinst GoogleChrome
cinst Firefox
cinst SeleniumServer
cinst SeleniumChromeDriver2
cinst SeleniumIEDriver
cinst fiddler4
cinst phantomjs
'''
Created on Nov 15, 2013
@author: "David Lai"
'''
import shlex, subprocess
if __name__ == '__main__':
@dlai0001
dlai0001 / app.js
Last active December 22, 2015 09:38
# Product model
App.Product = DS.Model.extend(
descripton: DS.attr('string')
expirationDate: DS.attr('date')
imageUrl: DS.attr('string')
location: DS.attr('string')
quantity: DS.attr('number')
quantityUnit: DS.attr('string')
type: DS.attr('string')
profile: DS.belongsTo('profile')
YAHOO.util.Connect.asyncRequest("GET",
"/services/library/json/?action=getLibraryFiles&status=P",
{ success: function(o) {
var response = JSON.parse( o.responseText);
var fileList = response.list.filter( function(item) {
return item.batch == "N";
});
var fileEntry = fileList.filter( function(item) {
return item.fileName == "2013-08-06_11.50.39_testfile_vuPk.txt";
})[0];
@dlai0001
dlai0001 / show_clapper.py
Created July 18, 2013 07:13
Here's a fun script to overlay a clapper board on top of your web page in a selenium test. This is very helpful when you have video recordings of your test and want figure out which tests correspond to which minutes in the recording.
def show_clapper(text, webdriver=None):
"""
Place a visibile line of logging text into the sauce logs.
@param driver: Selenium webdriver (should be a instance of Remote webdriver.
@param text: Text to log.
"""
print "Logging in remote webdriver: ", text
if webdriver is None:
App = Ember.Application.create();
App.Router.map(function() {
// put your routes here
});
App.Store = DS.Store.extend({
adapter: DS.FixtureAdapter.create()
});