Skip to content

Instantly share code, notes, and snippets.

@VKen
VKen / lcm.js
Created November 25, 2019 17:02
Get Lowest/Smallest Common Multiple From a Sequential Range of Numbers
/* get the lowest common multiple from a sequential range of numbers
expect arr = [a, b], where `a` and `b` are the (inclusive) edge range of natural numbers
*/
function smallestCommons(arr) {
let min = Math.min(...arr), max = Math.max(...arr),
numList = Array.from(Array(max - min +1).keys(), (val) => val + min),
factorMap = {};
numList.forEach((val) => { // generate the prime factors count mapping
for (let [key, value] of Object.entries(primeFactor(val))) {
@VKen
VKen / docker-start-celery-multi-worker-entrypoint
Created September 19, 2019 03:57
Running celery multi in docker container with running logs, signal trap, and graceful shutdown & restart
#!/bin/sh
# safety switch, exit script if there's error. Full command of shortcut `set -e`
set -o errexit
# safety switch, uninitialized variables will stop script. Full command of shortcut `set -u`
set -o nounset
# tear down function
teardown()
{
@VKen
VKen / .gitconfig
Created December 21, 2018 07:33
Fix for vimdiff vim-plugins clashes between minibufexpl.vim and splice.vim when using as git mergetool in git config
[diff]
tool = gvimdiff
[merge]
# Note: `sjl/splice.vim` is unmaintained and has a bug with one
# of the views. Use fork from `albfan/splice.vim` instead
tool = splice
[mergetool "splice"]
# minibufexpl.vim uses some window space, splice's default calculation
# and resizing did not take that into account therefore, switch off
# minibufexpl.vim's window auto start, so splice can control window space fully