Skip to content

Instantly share code, notes, and snippets.

View felixSchl's full-sized avatar

Felix Schlitter felixSchl

View GitHub Profile
@felixSchl
felixSchl / tmux-completions.sh
Created March 21, 2023 01:19
TMUX FZF integration
#!/bin/bash
#
# Author: Felix Schlitter
# Description:
# Manage sessions using FZF
#
# Place this into your .bashrc after installing FZF,
# Then update your .tmux.conf and create key-bindings. Example:
#
# unbind s
@felixSchl
felixSchl / spago-compile
Last active March 15, 2020 21:16
Emacs 'M-x compile' compatible 'purs compile' output (spago only)
#!/bin/bash
# compilation-mode compatible spago build output
set -eo pipefail
root=$(git rev-parse --show-toplevel)
PATH=$root/node_modules/.bin:$PATH
output=$(spago 3>&2 2>&1 1>&3 --quiet build -u --json-errors || { :; })
n_errors=$(jq <<< "$output" '.errors | length')
n_warnings=$(jq <<< "$output" '.warnings | length')
#!/bin/bash
#
# Disable public access to all exported ports on docker containers.
# Restrict access only to well-known cloudflare servers.
set -eo pipefail
function update_rules {
local target_file=$1
awk -v "rules=$2" '
@felixSchl
felixSchl / gist:ce6143c06d3a6ff360d6397c8f71349a
Last active January 26, 2019 19:11
Simple netcat HTTP server (without -c/-e)
#!/bin/bash
set -e
function run_handler {
: # whatever
}
while :; do
rm -f pipe
mkfifo pipe
044c089823ed2816cf0902a5840e237dcb046b602e58f7e2029784d504777a3f1e8cd8d071351195dd19822ad290f7c60e655c233b75d0089effb069ffb81e4fe3;stwiname
@felixSchl
felixSchl / install-vim-from-sources-ubuntu.sh
Last active May 12, 2018 11:41
Installing Vim 8 on Ubuntu 16.04 LTS
# This build vim from sources with lua, python and ruby enabled as well as support for
# the system clipboard.
#
# Preparation
#
# 1. Download vim tarball from vim.org, extract and cd
# 2. Enable "Source Code" in Software Center under "Software & Updates".
# This is required for `sudo apt-get build-dep` to work.
sudo apt-get build-dep vim &&
@felixSchl
felixSchl / .bashrc
Last active December 14, 2017 17:13
Interactive TMUX session selection / killing / creation
#!/bin/bash
#
# Place this into your .bashrc after installing FZF,
# Then update your .tmux.conf and create key-bindings. Example:
#
# unbind s
# bind s run "tmux new-window -n 'Switch Session' 'bash -ci tmux_select_session'"
# unbind K
# bind K run "tmux new-window -n 'Kill Session' 'bash -ci tmux_kill_session'"
# unbind C
@felixSchl
felixSchl / run.sh
Last active November 15, 2016 16:46
Typescript 2 -> ES6 -> Babel -> ES5 (+ watchable / NO gulpfile! - just unix pipes) https://asciinema.org/a/20h1t61ky43xvszkrcl8h24jo
#!/bin/bash
#
# Task wrapper. Runs various chores in a cross platform manner.
#
# Usage: run [-h] <command>
#
# Available commands are:
# build: Build the project
# <other>: Run any other command available in the NPM path
#
@felixSchl
felixSchl / git-du.sh
Last active September 21, 2016 21:45
git-du
# usage: git du [max-size]
function git-du {
local -r max_size="${1:-0}"
du | while read -r line; do
read -r s n <<< "$line"
if ((s > max_size)) && git ls-files "$n" --error-unmatch &> /dev/null; then
echo "$line"
fi
done
}
@felixSchl
felixSchl / gist:8955008908385033e369
Last active November 4, 2016 19:14
chunked promise
var Promise = require('bluebird')
, _ = require('lodash')
;
var xs = [ 1, 2, 3, 4 ];
var mapLimit = function(xs, limit, f) {
return Promise.all(_.foldl(
_.chunk(xs, limit)