Skip to content

Instantly share code, notes, and snippets.

View tamlyn's full-sized avatar

Tamlyn Rhodes tamlyn

View GitHub Profile
async function fact() {
const response = await fetch('https://catfact.ninja/fact')
const data = await response.json()
return data.fact
}
'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() {
'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;
@tamlyn
tamlyn / Barknet.ipynb
Created November 23, 2018 21:02
Error when training
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 / .profile
Last active August 1, 2020 10:45
Configs for our command line tools
# Use nano instead of vim
EDITOR=nano
# always list in long format
alias ls='ls -la --color'
# set dynamic prompt and window/tab title
PS1='\[\e]0;${PWD##*/}\a\]\n' # set window title
#PS1="$PS1"'\u@\h ' # user@host<space>
PS1="$PS1"'\[\033[32m\]' # change color
openapi: 3.0.0
info:
title: Test case
version: "1"
paths:
/users:
get:
responses:
"200":
@tamlyn
tamlyn / cartpole.ipynb
Last active December 22, 2020 08:54
OpenAI Gym CartPole-v1 with Pytorch 1.0
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tamlyn
tamlyn / README.md
Last active July 7, 2022 09:48
Execution order of Jest/Jasmine test code

Execution order of Jest/Jasmine test code

While tests run in source order, surrounding code does not which can lead to hard to debug issues.

Compare the test file below with the sample output below that and note the order of the log messages.

Key points

  • Any code not inside of it, beforeAll, afterAll, beforeEach or afterEach runs immediately on initialisation.
  • This means code at the end of your file runs before even your before hooks.

How the Apollo Client cache works

Queries

A query is only served from cache if the same query path, with the same variables, was previously requested.

For example if you fetch all Fund objects: