Skip to content

Instantly share code, notes, and snippets.

Avatar

Felix Schlitter felixSchl

  • DN3010
  • Auckland, New Zealand
View GitHub Profile
@felixSchl
felixSchl / gist:8721943
Created Jan 30, 2014
Working directory per tab
View gist:8721943
" There is no way to set the cwd per tab by default.
" :cd changes the cwd for all of vim
" :lcd changes the cwd for the active window
" These two lines remedy this:
au TabEnter * if exists("t:wd") | exe "cd" . '"' t:wd . '"' | endif
au TabLeave * let t:wd=getcwd()
View gist:d38b455df8bf83a78d3d
# Original:
# http://stackoverflow.com/a/6078528
#
# Call `zipit` with the path to either a directory or a file.
# All paths packed into the zip are relative to the directory
# or the directory of the file.
def zipit(path, archname):
archive = zipfile.ZipFile(archname, "w", zipfile.ZIP_DEFLATED)
if os.path.isdir(path):
View gist:8955008908385033e369
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)
View git-du.sh
# 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 / run.sh
Last active Nov 15, 2016
Typescript 2 -> ES6 -> Babel -> ES5 (+ watchable / NO gulpfile! - just unix pipes) https://asciinema.org/a/20h1t61ky43xvszkrcl8h24jo
View run.sh
#!/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 / .bashrc
Last active Dec 14, 2017
Interactive TMUX session selection / killing / creation
View .bashrc
#!/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 / install-vim-from-sources-ubuntu.sh
Last active May 12, 2018
Installing Vim 8 on Ubuntu 16.04 LTS
View install-vim-from-sources-ubuntu.sh
# 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 &&
View genesis_public_key
044c089823ed2816cf0902a5840e237dcb046b602e58f7e2029784d504777a3f1e8cd8d071351195dd19822ad290f7c60e655c233b75d0089effb069ffb81e4fe3;stwiname
@felixSchl
felixSchl / gist:ce6143c06d3a6ff360d6397c8f71349a
Last active Jan 26, 2019
Simple netcat HTTP server (without -c/-e)
View gist:ce6143c06d3a6ff360d6397c8f71349a
#!/bin/bash
set -e
function run_handler {
: # whatever
}
while :; do
rm -f pipe
mkfifo pipe
View docker-ufw-cf.sh
#!/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" '