Skip to content

Instantly share code, notes, and snippets.

View iki's full-sized avatar

Jan Killian iki

View GitHub Profile
@iki
iki / docker-compose.yml
Created September 15, 2019 20:12
Docker-compose nginx CORS proxy
version: '3.7'
services:
whoami:
image: jwilder/whoami
ports:
- 127.0.0.1:7000:8000
cors:
# Edit this file as you like and merge with $HOME/.gitconfig (global) or .git/config (given repo only)
#
# See https://help.github.com/articles/set-up-git
#
# See http://git-scm.com/docs/git-config
# or http://www.kernel.org/pub/software/scm/git/docs/git-config.html
#
# See http://git-scm.com/book/en/Customizing-Git-Git-Configuration
# or http://progit.org/book/ch7-1.html
#
@iki
iki / README.md
Last active November 7, 2023 08:50
Simple DevOps shell library for Linux/Mac/Windows

Simple DevOps shell library for Linux/Mac/Windows

Usage: devops [options] <command> [args]

Sourcing:
  Sourcing script defines functions and passes entrypoint function to init.

  Samples when devops is located in the same/relative/absolute path:
    . "`dirname "${BASH_SOURCE[0]}"`/devops" && init <entrypoint> "$@"
@iki
iki / README.md
Last active April 26, 2023 10:08
Select list items in React
@iki
iki / curry.ts
Last active August 24, 2022 12:39
Dynamic function arguments currying in TypeScript
// 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]
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(
@iki
iki / README.md
Last active December 12, 2021 08:50 — forked from othiym23/npm-upgrade-bleeding.sh
Update global top level npm packages

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.
@iki
iki / .gitignore
Last active May 13, 2021 17:41
Example of using GraphQL API from Micropython with ported Prisma python-graphql-client
# See https://help.github.com/ignore-files/ for more about ignoring files.
# logs
*.log*
# tools settings and other hidden directories
/.*/
@iki
iki / Dockerfile
Last active April 20, 2020 09:20
Test volume mount in docker
FROM alpine
WORKDIR /data
COPY . .
CMD ls -l /data
# Format: https://git-scm.com/docs/gitignore#_pattern_format
*.json
*.yaml
.DS_Store
*.log
*.log.*
/.*/