Skip to content

Instantly share code, notes, and snippets.

View euangoddard's full-sized avatar

Euan Goddard euangoddard

View GitHub Profile
@euangoddard
euangoddard / alias.directive.spec.ts
Last active September 20, 2018 13:56
Alias directive for Angular
import { Component } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { AliasDirective } from './alias.directive';
describe('Alias directive', () => {
beforeEach(() =>
TestBed.configureTestingModule({
declarations: [AliasDirective, DoubleComponent, TripleComponent],
}));
while true; do sleep $((1 + RANDOM % 10)); osascript -e 'display notification "keep up the good work!" with title "Chuck says…"'; done;
@euangoddard
euangoddard / pivot.py
Last active March 15, 2018 08:51
Pivotting in Python
from collections import defaultdict
def pivot(rows, x_getter, y_getter, z_getter, empty_value=''):
pivotted_data = defaultdict(dict)
seen_y_values = set()
for row in rows:
x_value = x_getter(row)
y_value = y_getter(row)
z_value = z_getter(row)
@euangoddard
euangoddard / debug-log.ts
Created October 20, 2017 13:51
Colour-coded prefixed logging for the console
const COLOURS = [
'#ff1744', '#f50057', '#d500f9', '#651fff', '#3d5afe', '#2979ff', '#00b0ff', '#00e5ff', '#1de9b6', '#00e676',
'#76ff03', '#c6ff00', '#ffea00', '#ffc400', '#ff9100', '#ff3d00', '#8d6e63', '#bdbdbd', '#78909c',
];
export function debugLog(prefix: string, ...args) {
let number = 0;
for (let i = 0; i < prefix.length; i++) {
number += prefix.charCodeAt(i);
}
@euangoddard
euangoddard / material-color.scss
Last active April 7, 2017 15:41
SCSS function to address Material colors by palette and identifier
// Material Design Color Palette
// -----------------------------
// http://www.google.com/design/spec/style/color.html
$material-color-divider: rgba(0, 0, 0, .12);
$material-colors: (
red: (
50: #ffebee,
100: #ffcdd2,