Skip to content

Instantly share code, notes, and snippets.

View tomeustace's full-sized avatar

Tom Eustace tomeustace

View GitHub Profile
console.assert(true === true, "This won't appear in console as is always true");
console.assert(true === false, "true does not equal false");
const sp = $('nonexistentelement');
console.assert(sp === undefined, "element not found");
@tomeustace
tomeustace / commands.ts
Created March 11, 2022 10:00
Cypress commands for populating Firebase Auth and Firestore emulators with data during test
// support/commands.ts
import { getAuth, connectAuthEmulator, signInWithEmailAndPassword } from "firebase/auth";
import firebase = require("firebase/compat");
const firebaseConfig = {<your-config}
firebase.default.initializeApp(firebaseConfig);
const auth = getAuth();
connectAuthEmulator(auth, "http://localhost:9099");
@tomeustace
tomeustace / unsubscribe.ts
Last active November 24, 2020 14:17
Typescript method decorator with args
/**
* Decorator to ensure widgets unsubscribe and clean up subscriptions on each new subscription.
*/
export function Unsubscribe<T>(): Function {
return function(targetClass, functionName: string, descriptor): Function {
const source = descriptor.value;
descriptor.value = function(...args): void {
@tomeustace
tomeustace / Angular Singleton decorator
Created November 12, 2019 15:40
Angular decorator for overriding ngoninit, maybe extended to avoid multiple component instances
export function Singleton() {
return function(target, key, decorator) {
const method = decorator.value;
const myOverride = () => {
// do stuff
method.call();
}
decorator.value = myOverride;
return decorator;
}
@tomeustace
tomeustace / SketchSystems.spec
Created September 5, 2018 09:12
My Awesome Sketch
My Awesome Sketch
First State
some event -> Second State
Second State
some event -> Third State
Third State
@tomeustace
tomeustace / index.html
Created January 5, 2017 16:28
d3 v4 translateBy, scaleBy and scaleTo example usage
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.view {
fill: blue;
stroke: #000;
}
</style>
@tomeustace
tomeustace / index.html
Created January 5, 2017 16:25
d3 v4 zoom transform
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.view {
fill: blue;
stroke: #000;
}
</style>
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.axis path {
display: none;
}
.axis line {
stroke-opacity: 0.3;
@tomeustace
tomeustace / index.html
Last active December 7, 2016 21:07
Demonstrates updating bar chart in d3 using interval
<!DOCTYPE html>
<head> <meta charset="utf-8"> </head>
<body>
<div class="flex-container">
<h2>D3 Bar Chart Updates</h2>
<div id="target" class="row"></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.js"></script>
@tomeustace
tomeustace / index.html
Last active October 6, 2016 21:45
d3 Move grouped elements
<!DOCTYPE html>
<head>
<meta charset="utf-8">
</head>
<body>
<div class="flex-container">