Skip to content

Instantly share code, notes, and snippets.

View karfau's full-sized avatar
🎯
Focusing

Christian Bewernitz karfau

🎯
Focusing
  • bettermarks GmbH
  • Saxony / Germany
  • 11:50 (UTC +02:00)
View GitHub Profile
@karfau
karfau / npm-ls-ratio.sh
Created May 3, 2020 10:10
npm-ls-ratio
git pull
nvm i
npm ci
npm ls --parseable --depth 0 | wc -l
npm ls --parseable | wc -l
npm ls --parseable --depth 0 --production | wc -l
npm ls --parseable --production | wc -l
@karfau
karfau / ormconfig.register.js
Last active December 8, 2019 20:04
workaround for typeorm no longer loading ormconfig.env by default
// Source: https://gist.github.com/karfau/b6d0927628f6662ca6d892153562522f
// 1. copy this file to your root directory alongside ormconfig.env
// in your package.json scripts/mocha.opts, etc add
// --reqister ./ormconfig.register.js
// or
// -r ./ormconfig.register.js
const {config} = require('dotenv');
const path = require('path');
config({path: path.join(__dirname, 'ormconfig.env')});
@karfau
karfau / .extend.docker.bashrc
Last active June 19, 2020 13:08
Aliases for docker and docker-compose alongside podman
# With my local setup in Manjaro I'm using https://podman.io/ as a rootless docker replacement:
# https://podman.io/getting-started/installation#arch-linux--manjaro-linux
# To be able to still run the real docker when required, but use podman by default I added this link:
# /usr/local/bin/docker -> /usr/bin/podman
# I wanted to have an easy way to switch to real docker and back so I created the following aliases:
# <name>su switches on <name>, un<name> switches off <name>
# since the tools all require docker daemon to run and calling 'sudo <name>',
# but most scripts assume it works wihtout sudo
# docker
@karfau
karfau / multiplication.js
Last active November 15, 2019 18:19
math exercises
// requires lodash being present as _, e.g. in the dev console on https://lodash.com/docs
// random
var result = []; for (i=0;i<50;i++) {let a = `${_.sample.call(null, _.range(2, 21))} * ${_.sample.call(null, _.range(2, 16))}`; result.push(`${a} = ${eval(a)}`);} console.log(result.join('\n'))
// all ordered
var result = []; for (i=1;i<21;i++) { for (j=1;j<11;j++) { let a = `${i} * ${j}`; result.push(`${a} = ${eval(a)}`);}} console.log(result.join('\n'))
@karfau
karfau / stackexchange-flair.md
Created November 14, 2019 21:43
stackexchange flair

karfau @ stackexchange.com

@karfau
karfau / .gitignore
Last active February 20, 2018 19:28
executes the parameters, checks the exit code, prints log file to stderr in case exit code is not 0, helpful for running crontab
/logs
type Neighbors = {neighbors: number};
type State = Neighbors & {alive: boolean};
function deadCell({neighbors}: Neighbors): State {
return {alive: false, neighbors};
}
function livingCell({neighbors}: Neighbors): State {
return {alive: true, neighbors};
}
@karfau
karfau / README.md
Last active June 4, 2017 19:17
Grav CMS Solution #X for localized date parts.
@karfau
karfau / Code.gs
Last active August 23, 2016 21:17
Google App Script to merge all documents from a GDrive Folder into a single GDocs document using an intermediate GSpreadsheet
var C_TYPE = 'Type',
C_TITLE = 'Title',
C_ID = 'ID',
C_URL = 'URL',
C_MIME_TYPE = 'file type',
C_ELEMENTS = 'elements in document';
var HEADERS = [C_TYPE, C_TITLE, C_ID, C_URL, C_MIME_TYPE, C_ELEMENTS];
function onOpen(){