Skip to content

Instantly share code, notes, and snippets.

rctay / async-gotchas1.ts
Last active Jul 14, 2022
calling a promise in "fire-and-forget" fashion but surprisingly subsequent code wasn't called
View async-gotchas1.ts
// assume just this and you don't have access to its source code
let doAsyncThing: () => Promise<void>;
// another async fn - eg. logging, GA reporting
const doAsyncThingSafe = (): Promise<void> =>
new Promise((resolve, _reject) => {
console.log('🎉did <this> where <this = always needs to be done>🚀');
View gist:1ace7969993abcf99301e7172cee30d0
export default {
name: 'stretch',
title: 'Stretch',
type: 'document',
fields: [
name: 'name',
title: 'Name of stretching exercise',
type: 'string',
rctay / my-component.html
Last active Dec 19, 2018
Testing handlers and their bindings
View my-component.html
<form [formGroup]="teamFormGroup" id="team-details__form">
<input matInput placeholder="Team Name" name="teamName" formControlName="teamName">
<button type="submit" mat-raised-button
color="primary">save changes
rctay / settings-page.po.ts
Created Dec 19, 2018
Explicit typing for merging 2 objects/decorating in TypeScript with intersection types
View settings-page.po.ts
import { $ } from 'protractor';
export interface ChangePasswordDialog {
currentPasswordField: ElementFinder;
incorrectPasswordError: ElementFinder;
submitButton: ElementFinder;
export class SettingsPage extends AppPage {
get changePasswordDialog(): ElementFinder & ChangePasswordDialog {
fly -t ci workers --json | jq '.[] | select(.state=="stalled").name'\
| xargs fly -t ci prune-worker -w
rctay / docker-compose.yml
Last active Dec 5, 2018
Persist artifacts for concourse builds with minio
View docker-compose.yml
# ...
image: minio/minio
ports: ["9000:9000"]
command: minio server /data
- MINIO_SECRET_KEY=miniosecret
rctay /
Last active Apr 6, 2018
soliloquy 20180406

Is this refactor warranted?


    const ROLES = ['boss', 'big boss', 'major boss', 'super boss', 'the boss'];

    describe('with Alpha Team details but', () => {
        describe('without Big Boss', () => {
            const expected_roles = ROLES.filter(role => role !== 'big boss');
def allnumbers(i=1):
while True:
yield i
i += 1
def fastforward(it, till, it_head=None):
n = next(it) if it_head is None else it_head
while n < till:
n = next(it)
return n
View gist:281c45147defda285005ccb5bf9fc67a
function copy(o) {
var p = {};
for (var k in o)
p[k] = o[k];
return p;
function Mapper(source) {
this.source = source;
this.result = {};
rctay /
Created Dec 19, 2015 — forked from UniIsland/
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.