Skip to content

Instantly share code, notes, and snippets.


Ivan Tanev VanTanev

View GitHub Profile
View App.tsx
import { XstateInspectLoader } from 'shared/util/XstateInspectLoader'
const App = () => {
// rest of app goes here
VanTanev / preact.config.js
Created Nov 7, 2020
Enable CRA-like environment variable passing in preact-cli
View preact.config.js
import webpack from 'webpack'
export default {
* Function that mutates the original webpack config.
* Supports asynchronous changes when a promise is returned (or it's an async function).
* @param {object} config - original webpack config.
* @param {object} env - options passed to the CLI.
* @param {WebpackConfigHelpers} helpers - object with useful helpers for working with the webpack config.
VanTanev / io-ts-stringify.ts
Last active Jun 29, 2020
Extract static type strings from io-ts definitions
View io-ts-stringify.ts
import * as t from 'io-ts'
import * as gen from 'io-ts-codegen'
import { NullableType } from 'codecs/util/nullable'
export function stringifyNaive(identifier: string, codec: t.Any): string {
return `type ${identifier} = ${}`
export function stringifyFull(identifier: string, codec: t.Any): string {
return `type ${identifier} = ${gen.printStatic(getType(codec))}`
VanTanev / .eslintrc.json
Last active Aug 22, 2019
base husky + prettier + eslintconfig
View .eslintrc.json
"extends": [
"plugins": ["jest"]
View safeFormik.ts
import fromPairs from 'lodash/fromPairs'
export type SafeForFormik<T extends { [key in string]: any }> = {
safe: { [keyWithoutDots in string]: T['key in string'] }
originalToSafeKeyDict: { [key in string]: string }
safeToOriginalKeyDict: { [keyWithoutDots in string]: string }
getBySafeKey: (data: T, keyWithoutDots: string) => T['key in string']
VanTanev /
Last active May 21, 2019
A script to convert filenames with Japanese characters to romanized versions
#!/usr/bin/env bash
set -eu -o pipefail
# set -x
mkdir -p "$ROMANIZED_DIR"
MIT License
Copyright (c) 2017 Ivan Tanev <>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
#!/usr/bin/env bash
# required stuff
yum -y groupinstall "Development Tools"
yum -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison
# maybe?
# yum -y install libxslt-devel libyaml-devel libxml2-devel gdbm-devel libffi-devel zlib-devel openssl-devel libyaml-devel readline-devel curl-devel openssl-devel pcre-devel git memcached-devel valgrind-devel mysql-devel ImageMagick-devel ImageMagick
# ruby p353
VanTanev / grab.rb
Last active Dec 22, 2015
Grab some pony gifs
View grab.rb
#!/usr/bin/env ruby
require "optparse"
require "ostruct"
require "nokogiri"
require "uri"
require "open-uri"
require "net/http"
options =
View LSA_03_homework_all_open_files_from_proc
# List all opened files using only the /proc fs.
main() {
pids | file_descriptor_folder | xargs ls -l | remove_ls_total_lines | remove_ls_file_attributes | remove_non_files | less
pids() {
# we try all pids from 1 to the pid max and echo out the valid ones
for P in $(seq 1 $(cat /proc/sys/kernel/pid_max)); do