Skip to content

Instantly share code, notes, and snippets.

@hossomi
hossomi / BatchSubscriber.java
Last active June 10, 2022 06:57
A custom Reactor buffer-timeout subscriber that also buffers elements overflowing from previous requests after timeout. The difference from onBackpressureBuffer() is that it doesn't request unbounded; instead it provides a request() method to keep it under your control.
import lombok.extern.slf4j.Slf4j;
import org.reactivestreams.Subscription;
import reactor.core.CoreSubscriber;
import reactor.core.Disposable;
import reactor.core.scheduler.Scheduler;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
@hossomi
hossomi / .bashrc
Last active April 10, 2019 13:45
Bash prompt with colored git branch
function contains {
echo -n "$1" 2> /dev/null | grep --color=auto "$2" &> /dev/null;
return $?
}
function git_status {
status=$(git status 2>&1 | tee)
contains "$status" 'modified:' \
|| contains "$status" 'Untracked files' \
|| contains "$status" 'Your branch is ahead of' \
@hossomi
hossomi / .bashrc-256
Created April 12, 2019 19:32
Bash prompt with 256-colored git status
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@hossomi
hossomi / .tmux.conf-256
Last active July 15, 2019 03:05
Tmux configuration with WASD-based navigation for 256-colored terminals.
# Change prefix to Ctrl+Space
unbind C-b
set -g prefix C-Space
bind C-Space send-prefix
# Reload on r
bind r source-file ~/.tmux.conf
# Panes and windows
unbind '"' # split window horizontally
@hossomi
hossomi / .luarc
Last active July 24, 2019 14:14
Lua project local tree setup. Source this file in .bashrc, then use "luarocks --tree .luarocks" to install dependencies inside your project.
# Setup LuaRocks Lua path
eval $(luarocks path)
# Get LuaRocks Lua version
LUA_VERSION=$([[ "$LUA_PATH" =~ /lua/([0-9]\.[0-9]) ]] && echo ${BASH_REMATCH[1]})
# Include project local tree in Lua path
# Remember to run 'luarocks --tree .luarocks'
LUA_TREE='.luarocks'
LUA_PATH="./$LUA_TREE/share/lua/$LUA_VERSION/?.lua;./$LUA_TREE/share/lua/$LUA_VERSION/?/init.lua;$LUA_PATH"