Skip to content

Instantly share code, notes, and snippets.

View basbloemsaat's full-sized avatar

Bas Bloemsaat basbloemsaat

View GitHub Profile
@rochacbruno
rochacbruno / validate_dataclass.py
Created September 30, 2021 11:13
Validate Dataclass Python
from typing import Union, List
from dataclasses import dataclass
class Validations:
def __post_init__(self):
"""Run validation methods if declared.
The validation method can be a simple check
that raises ValueError or a transformation to
/**
* Export all data from an IndexedDB database
*
* @param {IDBDatabase} idbDatabase The database to export from
* @return {Promise<string>}
*/
export function exportToJson(idbDatabase) {
return new Promise((resolve, reject) => {
const exportObject = {}
if (idbDatabase.objectStoreNames.length === 0) {
@up1
up1 / HelloWorld.ts
Last active October 8, 2025 11:28
TDD with TypeScript
export class HelloWorld {
public sayHi(name: string): string {
return "Hi, " + name;
}
}
@dwtkns
dwtkns / README.md
Last active May 28, 2019 06:59
Sun and Earth

Experiments faking 3d rotation of a globe and sun in SVG. Illusion is helped by dynamic gradients, two nested orthographic projections, scaling the sun circle's radius based on distance from the 'camera', and toggling a clipping mask that makes the sun appear to move "behind" the earth.

Based on Mike Bostock's Solar Terminator and this past experiment.

This example stems from drafts of maps for Norway the Slow Way. Also see Mike's Pencil Sketch example.

@jmduke
jmduke / gist:8382405
Created January 12, 2014 08:51
Fun with NFL scores.
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import vincent
# source: http://www.pro-football-reference.com/boxscores/game_scores.cgi
SOURCE_FILE = "./nflscores.csv"
data = pd.read_csv(SOURCE_FILE, header=0)
@basbloemsaat
basbloemsaat / kiglow.pl
Created January 27, 2013 17:25
Raspberry Pi "glow" gpio output. See http://youtu.be/99Sbynu1zqY for the output.
#!/usr/bin/env perl
use 5.014;
my $pins = [ 17,27,22 ]; # red, green and blue leds
use constant STEPS => 50;
initpins($pins);
foreach my $pin (@$pins) {
glowon($pin);