Skip to content

Instantly share code, notes, and snippets.

Avatar

Jan Killian iki

View GitHub Profile
@iki
iki / curry.ts
Last active August 24, 2022 12:39
Dynamic function arguments currying in TypeScript
View curry.ts
// Dynamic function arguments currying in TypeScript
// - For functions with any fixed arguments it keeps currying the function
// until all fixed arguments are provided, then returns the result
// - For functions with dynamic arguments only it keeps currying the function
// as long as the call provides any spices, otherwise returns the result
// - Source: https://gist.github.com/iki/6472c0775cc0847fc667c01524cafa6b
type Args = readonly unknown[]
type Func<A extends Args = any[], R = any> = (...args: A) => R
type Slices<A extends Args, I extends Args = []> = A extends readonly [infer F, ...infer R]
View hideEmailName.ts
const hide = (s: string) => '*'.repeat(s.length);
const hideEachSecondMatch = (_match: string, ...matches: string[]) =>
matches
.slice(0, -2)
.map((m, i) => (i % 2 ? hide(m) : m))
.join('');
// Hide all characters in email name, except first and last character
// FIXME: Better hide at least one character for 1-2 character names
const hideEmail = (email: string, options?: { domain?: boolean }) =>
email.replace(
View .gitignore
# Format: https://git-scm.com/docs/gitignore#_pattern_format
*.json
*.yaml
.DS_Store
*.log
*.log.*
/.*/
@iki
iki / docker-compose.yml
Created September 15, 2019 20:12
Docker-compose nginx CORS proxy
View docker-compose.yml
version: '3.7'
services:
whoami:
image: jwilder/whoami
ports:
- 127.0.0.1:7000:8000
cors:
@iki
iki / Dockerfile
Last active April 20, 2020 09:20
Test volume mount in docker
View Dockerfile
FROM alpine
WORKDIR /data
COPY . .
CMD ls -l /data
@iki
iki / .gitignore
Last active May 13, 2021 17:41
Example of using GraphQL API from Micropython with ported Prisma python-graphql-client
View .gitignore
# See https://help.github.com/ignore-files/ for more about ignoring files.
# logs
*.log*
# tools settings and other hidden directories
/.*/
@iki
iki / Medium: remove location hash.user.js
Last active December 25, 2017 20:31 — forked from azu/Medium: remove location hash.user.js
Medium: remove location hash
View Medium: remove location hash.user.js
// ==UserScript==
// @name Medium: remove location hash
// @namespace http://efcl.info/
// @description Remove location hash from medium
// @include https://medium.com/*
// @include https://uxdesign.cc/*
// @version 1
// @grant none
// ==/UserScript==
@iki
iki / vc.bat
Last active November 19, 2015 12:40
Visual Studio 10/11/14 environment setup for python, or node.js/node-gyp. Determines VS version and architecture, calls respective vcVarsAll.bat and sets vcTargetsPath if needed.
View vc.bat
@echo off
setlocal enableextensions
::: echo === "%~f0" %* >&2
set vcArgs=%*
set vcVersions=14 11 10
call :poparg vcArgs vcVersions 10 10 %1 && shift
call :poparg vcArgs vcVersions 11 11 %1 && shift
@iki
iki / gulpfile.js
Last active January 18, 2019 16:38
generating API documentation from RAML specification using raml2html in gulp
View gulpfile.js
'use strict';
var gulp = require('gulp');
var path = require('path');
var CWD = path.resolve('.');
var API_SPEC = path.resolve(CWD, '../api/api.raml');
var API_DEST = path.resolve(CWD, '../server/static/docs/api');
var API_HTML = 'index.html';
@iki
iki / README.md
Last active December 12, 2021 08:50 — forked from othiym23/npm-upgrade-bleeding.sh
Update global top level npm packages
View README.md

Update global top level npm packages

Problem

npm update -g updates all global packages and their dependencies, see npm/npm#6247.

Solution

  1. Either use the shell script or windows batch here instead.