Skip to content

Instantly share code, notes, and snippets.

Benjamin Wheeler benjiwheeler

View GitHub Profile
@benjiwheeler
benjiwheeler / selenium_browse_back.js
Created Dec 19, 2018
Selenium test code for browsing back and confirming that page is gone
View selenium_browse_back.js
elementIsVisible (element) {
return this.driver.wait(until.elementIsVisible(element));
}
elementIsNotVisible (element) {
return this.driver.wait(until.elementIsNotVisible(element));
}
const abbyElement = await findByText('Abby'); // Should show editor for new costume
await elementIsVisible(abbyElement);
@benjiwheeler
benjiwheeler / selenium_wait_until_clickable.js
Last active Dec 19, 2018
selenium js 3.6 attempt to wait until element is clickable
View selenium_wait_until_clickable.js
const costumesTabElement = await findByText('Costumes');
await driver.wait(() => {
return costumesTabElement.isDisplayed().then(displayed => {
console.log('got here A');
if (!displayed) return false;
console.log('got here B');
// costumesTabElement.click();
return costumesTabElement.isEnabled();
});
@benjiwheeler
benjiwheeler / time_utils.py
Last active Feb 2, 2018
Python time utils
View time_utils.py
import datetime
import pytz
# careful, don't assume now() is nyc time! on ec2, it's utc time.
def datetime_from_tz_naive_nyc_to_tz_aware_utc(nyc_datetime_tz_naive):
nyc_datetime_tz_aware = pytz.timezone('US/Eastern').localize(nyc_datetime_tz_naive)
return nyc_datetime_tz_aware.astimezone(pytz.utc)
def utc_tz_aware(utc_datetime_tz_naive):
return pytz.timezone('UTC').localize(utc_datetime_tz_naive)
@benjiwheeler
benjiwheeler / angularJsonDataService.js
Last active May 18, 2016
Angular Service to share JSON data among controllers
View angularJsonDataService.js
// data.json could look like:
// {
// "menu": [{"name": "Contact Us"}, {"name": "About Us"}]
// }
// app.js could look like:
var app = angular.module('myApp');
app.factory('commonData', ['$http', '$q', function($http, $q){
View HTML redirect page
<html>
<head>
<!-- Pleace this snippet right after opening the head tag to make it work properly -->
<!-- This code is licensed under GNU GPL v3 -->
<!-- You are allowed to freely copy, distribute and use this code, but removing author credit is strictly prohibited -->
<!-- Generated by http://insider.zone/tools/client-side-url-redirect-generator/ -->
<!-- REDIRECTING STARTS -->
<link rel="canonical" href="http://destinationsitehere.com"/>
@benjiwheeler
benjiwheeler / navMenuCtrl.js
Created Nov 18, 2015
Angular navigation menu controller from Begin to Code
View navMenuCtrl.js
// see the very bottom of http://angular-rails.com/find_and_browse.html
// by omitting second parameter, we tell angular we're looking for existing module.
var controllers = angular.module('basicControllers');
controllers.controller('NavMenuCtrl', ['$scope', '$stateParams', '$state', 'ProgramCache',
function($scope, $stateParams, $state, ProgramCache) {
// variables
$scope.menuStates = []; // all of the menu items, each a complete state
// IMPORTANT: we are binding global program service to local program scope!
// this lets us update menu item content on the fly, since our template will be digested.
@benjiwheeler
benjiwheeler / route.js
Created Nov 18, 2015
Angular route/state file from Begin to Code
View route.js
app.config(['$stateProvider', '$urlRouterProvider', '$locationProvider',
function($stateProvider, $urlRouterProvider, $locationProvider) {
$stateProvider.state('root', {
url: '/',
templateUrl: 'root.html',
controller: 'RootCtrl'
})
.state('program', {
url: '/program/:program_id',
@benjiwheeler
benjiwheeler / txt
Created Sep 25, 2015
The one thing I'd most like to remind myself
View txt
"Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind."
--Bernard Baruch
View NSLayoutConstraint+Init.swift
//
// NSLayoutConstraint+Init.swift
// Created by Benjamin Wheeler starting 6/2013
//
//
import UIKit
// improves the clarity and flexibility of NSLayoutConstraint
extension NSLayoutConstraint {
@benjiwheeler
benjiwheeler / rect.html
Created Jun 10, 2015
Processing simple rectangle in javascript
View rect.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/processing.js/1.4.9/processing.js"></script>
</head>
<body>
<div>
<canvas id="canvas" width="600" height="600" />
</div>
The content of the body element is displayed in your browser.
You can’t perform that action at this time.