Skip to content

Instantly share code, notes, and snippets.

@rctay
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
(click)="onSaveChangesClicked()"
id="details__save-changes"
color="primary">save changes
</button>
</form>
@rctay
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 {
View prune-worker.sh
fly -t ci workers --json | jq '.[] | select(.state=="stalled").name'\
| xargs fly -t ci prune-worker -w
@rctay
rctay / docker-compose.yml
Last active Dec 5, 2018
Persist artifacts for concourse builds with minio
View docker-compose.yml
services:
# ...
minio:
image: minio/minio
ports: ["9000:9000"]
command: minio server /data
environment:
- MINIO_ACCESS_KEY=minio
- MINIO_SECRET_KEY=miniosecret
@rctay
rctay / foo.md
Last active Apr 6, 2018
soliloquy 20180406
View foo.md

Is this refactor warranted?

Before:

    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');
View sieve.py
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
rctay / SimpleHTTPServerWithUpload.py
Created Dec 19, 2015 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
View SimpleHTTPServerWithUpload.py
#!/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.
"""
View gist:d4c1e97aee49c5e2e946
var rows_all = document.getElementsByTagName("table")[4].children[0].children
var rows = Array.prototype.slice.call(rows_all, 2)
var rows_data = rows.map(function(row) { return Array.prototype.map.call(row.children, function(c, i) { var v = c.innerText; return i===2 ? v.replace("\n"," ") : v }) })
// poor man's csv - doesn't handle values with the delimiter itself!
console.log(rows_data.map(function(c) { return c.join(",") }).join("\n"))
@rctay
rctay / gist:6e583e956c37a310c2f7
Created Apr 11, 2015
append EXIF date taken to filename
View gist:6e583e956c37a310c2f7
# produce lines like
#
# mv "./IMG_8869.jpg" "2015-03-29_19-08-01_IMG_8869.jpg"
#
find \( -name 'DSC_*' -or -name 'IMG_*' -or -name 'GOPR*' \) -and -iname '*.jpg'\
| while read x; do\
echo mv \"$x\" \"$(exif --tag='Date and Time (Original)' -m "$x" | sed -e 's/:/-/g' -e 's/ /_/')_${x#./}\"; done >foo
# try one line first
awk NR==1 foo | sh -v
You can’t perform that action at this time.