Skip to content

Instantly share code, notes, and snippets.

View wrzlbrmft's full-sized avatar

Matthias wrzlbrmft

  • Duesseldorf, Germany
  • 07:58 (UTC +02:00)
View GitHub Profile
@wrzlbrmft
wrzlbrmft / git-all.sh
Created March 29, 2016 11:43
Do a git pull and status in all direct subdirectories being Git repos.
#!/usr/bin/env sh
_IFS="$IFS"
IFS=$'\n'
for i in $(find . -mindepth 1 -maxdepth 1 -type d | sort); do
if [ -d "$i/.git" ]; then
printf "$i: "
cd "$i"
@wrzlbrmft
wrzlbrmft / list-files.txt
Last active May 23, 2017 17:16
List files and their sizes or md5 checksums.
# sizes
find . -type f -printf "%p %s\n" | sort
# md5 checksums
find . -type f -exec md5sum "{}" \; | awk '{ print $2,$1 }' | sort
@wrzlbrmft
wrzlbrmft / check-string.sh
Created March 29, 2016 11:50
Check a URL for a string and send an e-mail if found.
#!/bin/sh
CHECK_URL="https://store.google.com/"
CHECK_STRING="Nexus 5"
MAIL_TO="mail@example.org"
MAIL_SUBJECT="$CHECK_STRING"
MAIL_BODY="$CHECK_URL"
COUNT="$(curl -Ls "$CHECK_URL" | grep -c "$CHECK_STRING")"
@wrzlbrmft
wrzlbrmft / list-sshd-logins.txt
Created March 29, 2016 11:53
List IPs/encounters or hostnames of invalid/accepted logins to sshd.
### invalid logins
# journalctl (last 7 days)
journalctl --since -7d | grep 'sshd.*Invalid' | awk '{ print $10 }' | sort | uniq -c
journalctl --since -7d | grep 'sshd.*Invalid' | awk '{ print $10 }' | sort | uniq | xargs -n1 dig +short -x
# /var/log/auth.log
cat /var/log/auth.log | grep 'sshd.*Invalid' | awk '{ print $10 }' | sort | uniq -c
cat /var/log/auth.log | grep 'sshd.*Invalid' | awk '{ print $10 }' | sort | uniq | xargs -n1 dig +short -x
@wrzlbrmft
wrzlbrmft / zip4aws-eb-node.sh
Created March 29, 2016 13:52
Creates a zip file of a Node.js app to be deployed to AWS Elastic Beanstalk.
#!/usr/bin/env sh
PROJECT_ROOT="$(cd "$(dirname "$0")" && pwd)"
PROJECT_NAME="$(cat "$PROJECT_ROOT/src/package.json" | grep '"name"' | cut -d\" -f4)"
PROJECT_VERSION="$(cat "$PROJECT_ROOT/src/package.json" | grep '"version"' | cut -d\" -f4)"
rsync -vrLkpogt --delete-before --progress \
--exclude .DS_Store \
--exclude build \
@wrzlbrmft
wrzlbrmft / _enc-mount.sh
Last active June 17, 2016 14:11
Mounts and unmounts EncFS by taking folder name out of script's file name.
#!/usr/bin/env bash
# to be used as symlink, e.g. ./foobar-mount.sh -> ~/bin/_enc-mount.sh
# will mount encrypted dir ./.foobar to mount point ./foobar
SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SCRIPT_FILE="$(basename "${BASH_SOURCE[0]}")"
SCRIPT_NAME="${SCRIPT_FILE%.*}"
ENC="${SCRIPT_NAME%-*}"
gdk-pixbuf-query-loaders --update-cache