Skip to content

Instantly share code, notes, and snippets.

View jarfil's full-sized avatar

Jaroslaw Filiochowski jarfil

View GitHub Profile
@jarfil
jarfil / grep-block.awk
Last active February 20, 2022 23:25
Find blocks of text, separated by newline, with occurring regexp
#!/usr/bin/awk -E
BEGIN {
if ( ARGV[1] == "" ) {
print "Usage: grep-block <regexp> [file1 file2 ...]"
exit
}
search = ARGV[1]
print "-" search "-"
ARGV[1]=""
@jarfil
jarfil / start_menu-move_entries.sh
Last active August 28, 2021 09:20
Clean up Start Menu entries in Windows, Cygwin
#!/bin/bash
# generic processing (DEPRECTED)
#rm -f "*/Uninstall.lnk"
#rm -f "*/Uninstall *.lnk"
# ===
# Start Menu
function do_move_1 {
@jarfil
jarfil / setaliases.sh
Last active August 28, 2021 08:59
Common personalized dircolors and aliases
# to be called from ~/.bashrc or similar
# don't apply changes if not logging in from given IP
### IP restriction
#if [ "${SSH_CLIENT//`dig +short fractal.jarfil.net`/}" != "$SSH_CLIENT" ] ; then
export PS1='[$(
if [ "a${USER:-${USERNAME:-$(whoami)}}" == aroot ] ; then
echo "\[\e[01;31m\]"
elif [[ "${GROUPS[@]}" =~ (^| )(114|544)( |$) ]] ; then
@jarfil
jarfil / java-update-links.sh
Last active May 8, 2019 14:57
Auto-recreate Java links for latest versions. Windows, Cygwin as admin
@jarfil
jarfil / ca.md
Created October 17, 2018 09:04 — forked from soarez/ca.md
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@jarfil
jarfil / vpn_psk_bingo.md
Created October 9, 2017 08:24 — forked from kennwhite/vpn_psk_bingo.md
Most VPN Services are Terrible

Most VPN Services are Terrible

Short version: I strongly do not recommend using any of these providers. You are, of course, free to use whatever you like. My TL;DR advice: Roll your own and use Algo or Streisand. For messaging & voice, use Signal. For increased anonymity, use Tor for desktop (though recognize that doing so may actually put you at greater risk), and Onion Browser for mobile.

This mini-rant came on the heels of an interesting twitter discussion: https://twitter.com/kennwhite/status/591074055018582016

@jarfil
jarfil / docker-update-prune.sh
Last active October 7, 2015 20:00
Docker: update + remove old unused images
#!/bin/bash
# for every named image
docker images | sed "1d" | cut -d " " -f1 | sort -n | uniq | grep -v '^<none>$' |
while read f ; do
# pull latest image, skip pruning if can't pull
if ! docker pull "$f" ; then continue ; fi
# get latest image id
IMAGE_ID=`docker images "$f" | sed "1d;2q" | sed 's/^[^ ]* *[^ ]* *//;s/ .*$//'`
if [ "x$IMAGE_ID" == "x" ] ; then continue ; fi
@jarfil
jarfil / auto-apt-get.sh
Created May 2, 2015 06:09
Automate apt-get avoiding major damage, suitable for cron
#!/bin/bash
EMAIL="example@example.com"
DEVEL=false
# clean downloaded packages if none pending for dist-upgrade
if ! $DEVEL ; then apt-get --assume-no dist-upgrade && apt-get clean ; fi
# update, upgrade, autoremove
apt-get --assume-yes update
@jarfil
jarfil / apt-pkg-releases.sh
Created April 26, 2015 00:26
Check version of a package in available releases
#!/bin/bash
PKG="$1"
for f in stable testing unstable experimental ; do
echo -n "$f - "
apt-cache show $PKG/$f 2>/dev/null | grep "Version:" || echo
done
#!/bin/bash
# painting2sprites - A simple script to read an ORA, resize and trim output PNGs.
INPUT_FILE="$1"
OUTPUT_DIR="$2"
RESIZE_SCALE="25%"
if [ "$2" == "" ]; then