Skip to content

Instantly share code, notes, and snippets.

Avatar

Tamlyn Rhodes tamlyn

View GitHub Profile
View openapi-callback-example.yaml
openapi: 3.0.0
info:
title: Test case
version: "1"
paths:
/users:
get:
responses:
"200":
View percy-dom-transformation.js
function removeOrigin(dom) {
let origin = window.location.origin;
let $internalElements = dom.querySelectorAll(`[href^="${origin}"],[src^="${origin}"]`);
for (let $el of $internalElements) {
const attr = $el.hasAttribute('href') ? 'href' : 'src';
const value = $el.getAttribute(attr);
$el.setAttribute(attr, value.replace(origin, ''));
}
return dom
@tamlyn
tamlyn / cartpole.ipynb
Last active Jul 15, 2020
OpenAI Gym CartPole-v1 with Pytorch 1.0
View cartpole.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tamlyn
tamlyn / Barknet.ipynb
Created Nov 23, 2018
Error when training
View Barknet.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View example.es5.js
'use strict';
var fact = function () {
var _ref = _asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var response, data;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
View example.es2015.js
'use strict';
let fact = (() => {
var _ref = _asyncToGenerator(function* () {
const response = yield fetch('https://catfact.ninja/fact');
const data = yield response.json();
return data.fact;
});
return function fact() {
View example.es2017.js
async function fact() {
const response = await fetch('https://catfact.ninja/fact')
const data = await response.json()
return data.fact
}
@tamlyn
tamlyn / scrape.js
Last active Mar 23, 2018
Scrape statements from First Direct internet banking
View scrape.js
//////// CONFIG /////////
// your first direct user name
const username = ''
// your password (the one it asks for characters from)
const password = ''
// your memorable word
const memorable = ''
// set to false if you want to see the browser window as it runs
const headless = true
@tamlyn
tamlyn / cypress.test.js
Created Mar 8, 2018
Example Cypress test suite
View cypress.test.js
// a very short Cypress test suite
describe('Admin user', () => {
it('Create posts journey', () => {
const postTitle = 'Hello testing'
cy.get('input[id=title]').type(postTitle)
cy.get('button[title=Create]').click()
cy.get('table tr:last label').should('contain', postTitle)
})
})
@tamlyn
tamlyn / testcafe.test.js
Created Mar 8, 2018
Example TestCafe test suite
View testcafe.test.js
// a very short TestCafe test suite
fixture('Admin user')
test('Create posts journey', t => {
const postTitle = 'Hello testing'
return t
.typeText(ReactSelector('PostCreator FormControl'), postTitle)
.click(ReactSelector('PostCreator Button'))
.expect(ReactSelector('Post').first().find('label').innerText)
.eql(postTitle)
})
You can’t perform that action at this time.