Skip to content

Instantly share code, notes, and snippets.

View markusfisch's full-sized avatar

Markus Fisch markusfisch

View GitHub Profile
@markusfisch
markusfisch / pullall.sh
Last active June 29, 2019 00:49
Run "git pull" in all subdirectories that contain a git repository
#!/usr/bin/env bash
# Pull all respositories in all direct subdirectories
#
# @param ... - directories to pull (optional)
pull_all()
{
local D
# don't quote @ because it will prevent globbing
@markusfisch
markusfisch / cleanimports.sh
Last active December 15, 2022 19:22
Shell script to remove unused java imports
#!/usr/bin/env bash
# Print unused import statements
#
# @param 1 - source file to check
find_unused_imports() {
grep '^import' "$1" | while read -r
do
NAME=${REPLY##*.}
NAME=${NAME%;*}
@markusfisch
markusfisch / xml.sh
Last active July 9, 2019 07:28
Basic XML parser in nothing but BASH
#!/usr/bin/env bash
# Read XML from STDIN
read_xml()
{
# concatenate lines
local XML
while read -r
do
@markusfisch
markusfisch / android.vim
Created April 24, 2015 16:24
VIM colorscheme, green and blue on a dark background
set background=dark
highlight clear
if exists( "syntax on" )
syntax reset
endif
let g:colors_name = "android"
hi Normal ctermfg=251 ctermbg=235
@markusfisch
markusfisch / README.md
Last active June 29, 2019 00:50
A lean approach to managing git subtrees manually

Manage subtrees manually

A lean approach to managing git subtrees [manually][mastering-subtrees]. Because git-subtree clutters the history graph and [git-stree][stree] still does too much for me.

I wanted the simplest possible solution that does not require anything special and that does not modify a repository beyond what's required for the most basic approach.

@markusfisch
markusfisch / README.md
Last active May 2, 2017 08:29
bash script to create new projects from project skeletons

Skeletons

Create new projects from project skeletons.

This script is for you if you create nontrivial projects that can be derived from a common base.

Sample

@markusfisch
markusfisch / depth.sh
Last active January 15, 2016 17:24
Count indent levels and echo lines that are indented over a given limit
#!/usr/bin/env bash
# Read lines from stdin and echo them if the indent is too deep
#
# @param 1 - levels of indent to consider too much (optional)
# @param 2 - indent character (optional)
check_indents()
{
local THRESHOLD=${1:-3}
local INDENT=${2:-$'\t'}
@markusfisch
markusfisch / cpdiff.sh
Created April 2, 2015 19:42
Isolate differences between two directories into a new directory
#!/usr/bin/env bash
# Copy difference only
#
# @param 1 - input path to base version
# @param 2 - input path to extended version
# @param 3 - output path of diff-only version
cpdiff()
{
(( $# < 3 )) && {
@markusfisch
markusfisch / README.md
Last active June 29, 2019 00:51
Generate Android drawables from SVGs

Generate Android drawables from SVGs

BASH script to generate and update Android drawable/mipmap resources from SVG sources.

Requires either [Inkscape][inkscape] or [Image Magick][im] for conversion.

Sample:

@markusfisch
markusfisch / README.md
Last active July 9, 2019 07:31
Perl script to deal with all the 0's in nanoseconds

Convert nanoseconds

A second is 1,000,000,000 nanoseconds which means you have a lot of 0's when translating between (milli)seconds and nanoseconds.

This perl script makes it easy:

$ perl nanos.pl 2
2 seconds are

2,000 milliseconds