Skip to content

Instantly share code, notes, and snippets.

View samvv's full-sized avatar

Sam Vervaeck samvv

View GitHub Profile
@samvv
samvv / fac.ts
Created March 5, 2020 08:31
Hypothetical Pattern Matching in TypeScript
function fac(n: number) {
return match (n) {
1 | 0 => 1,
_ => n * fac(n-1),
}
}
@samvv
samvv / tsconfig.json
Last active January 5, 2021 15:35
tsconfig.json for a project in a monorepo depending on another project
{
"compilerOptions": {
"target": "ES6",
"module": "CommonJS",
"outDir": "./lib",
"rootDir": "./src",
"composite": true,
"paths": {
"package-one": ["../package-one"]
},
@samvv
samvv / tsconfig.json
Created January 5, 2021 15:25
tsconfig.json for a monorepo containing different TypeScript projects
{
"references": [
{ "path": "./package-one" },
{ "path": "./package-two" }
],
"files": []
}
@samvv
samvv / package.json
Last active February 23, 2021 17:07
package.json sample without Bake
{
"name": "myapp",
"private": true,
"version": "0.0.1",
"scripts": {
"watch:compile-tests": "tsc -w",
"watch:tests": "ava --watch",
"test": "ava",
"lint": "tsc --noEmit",
"prepare": "npm run lint && webpack --mode production",
@samvv
samvv / package.json
Last active February 23, 2021 19:50
package.json with Bake integrated
{
"name": "myapp",
"private": true,
"version": "0.0.1",
"scripts": {
"watch:compile-tests": "tsc -w",
"watch:tests": "ava --watch",
"test": "ava",
"lint": "tsc --noEmit",
"prepare": "npm run lint && webpack --mode production",
@samvv
samvv / CtrlEscape.ahk
Last active December 23, 2023 17:23
Make control a secondary escape-key on Windows using AutoHotKey
; New version based on author fwompner gmail com in the Vim wiki
; https://vim.fandom.com/wiki/Map_caps_lock_to_escape_in_Windows#AutoHotkey
#Requires AutoHotkey v2.0
#SingleInstance
SetCapsLockState "AlwaysOff"
*Capslock::
{
@samvv
samvv / .Xmodmap
Last active April 4, 2023 17:13
Swap Ctrl and Caps Lock keys using Xmodmap
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L
@samvv
samvv / main.js
Created November 7, 2023 11:49
Configure Storybook to use Emotion
const path = require('path');
function toArray(value) {
return Array.isArray(value) ? value : [ value ];
}
const babelLoaderModulePath = require.resolve('babel-loader');
const emotionBabelPluginModulePath = require.resolve('@emotion/babel-plugin');
const babelPresetReactModulePath = require.resolve('@babel/preset-react');
@samvv
samvv / download.py
Last active February 10, 2025 18:39
Download a file in Python 3 with progress reporting
#!/usr/bin/env python3
from tarfile import TarFile
from typing import Callable, TypeVar, cast, Any
import math
import sys, os
import argparse
from urllib.parse import urlparse, urlunparse, ParseResult
import errno
@samvv
samvv / generate.py
Created August 5, 2024 10:16
Overloaded pipe() in Python
#!/usr/bin/env python3
out = ''
# Edit this variable
count = 25
for i in range(0, count):
out += f"_T{i} = TypeVar('_T{i}')\n"