Skip to content

Instantly share code, notes, and snippets.

@ikasty
ikasty / post-commit
Created May 10, 2019 06:40
Commit lotto
target=$(git rev-parse --short=7 HEAD 2>&1)
if [ "$?" -eq "0" ]; then
echo -n "Roll commit lotto... "
count=$(sed 's/^ *\([0-9]\+\).*$/\1/' <<< `echo "$target" | fold -w1 | sort | uniq -c | sort | tail -n1`)
if [[ "$target" =~ ^[0-9]+$ ]]; then
echo "You won numeric lotto! (3.725%)"
elif [[ "$target" =~ ^[a-f]+$ ]]; then
echo "You won alphabet lotto! (0.104%)"
elif [ "$count" -eq "4" ]; then
echo "You won 4 same lotto! (0.00586%)"
@ikasty
ikasty / index.js
Created October 19, 2017 14:53
print 1 to 9, with whitespace
for(i=0;8-i++;console.log(a[0]+' '+a[1]))a='123456789'.split(i)
@ikasty
ikasty / README.md
Last active June 18, 2024 06:46
'Cat' solution for colorized logs in docker-compose

When you use docker-compose, logs are not colorized like: before

However, you can get colorized logs using really-cute-'cat' solution. Instead of

docker-compose up

using

docker-compose up | cat
@ikasty
ikasty / sample.c
Last active August 29, 2015 14:06
make sample input file for deterministic selection
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#ifdef _WIN32
#define fileopen(fp, filename, type) fopen_s(&fp, filename, type)
#define fscanf fscanf_s
#else
#define fileopen(fp, filename, type) fp = fopen(filename, type)
#endif