Skip to content

Instantly share code, notes, and snippets.

View mkrasowski's full-sized avatar

Matt Krasowski mkrasowski

  • Boston, MA, USA
  • 14:22 (UTC -04:00)
View GitHub Profile
@mkrasowski
mkrasowski / .bashrc_mpw.sh
Created February 17, 2017 01:42
MasterPassword command line wrapper
# mpw
export MP_FULLNAME="Your Full Name"
function cmpw() {
mpw $* | tee >(tr -d '\n' | xclip -l 1 -selection clipboard) 1>/dev/null && echo
}
@mkrasowski
mkrasowski / DNSCrypt.README
Last active October 9, 2015 10:23
DNS Crypt setup with systemd
1. Install dnscrypt-proxy (https://dnscrypt.org) and Unbound (https://unbound.net)
2. Set up dnscrypt to listen on 127.0.0.1 port 40
# VISUAL=vim systemctl edit dnscrypt-proxy.socket -> paste override.conf
3. "Enable" DNS Crypt socket for autostart and start it now
# systemctl enable dnscrypt-proxy.socket
# systemctl start dnscrypt-proxy.socket
4. Edit /etc/unbound/unbound.conf -> paste unbound.conf (adjust to your needs)
5. Download root.hints
# wget ftp://FTP.INTERNIC.NET/domain/named.cache -O /etc/unbound/root.hints
6. "Enable" Unbound service for autostart and start it now
@mkrasowski
mkrasowski / lessencfix.pl
Last active December 17, 2015 19:39
Convert special characters `less' pager displays as their hexadecimal representation into their binary form.
Example:
"ma<B3>gorzata posz<B3>a do domu"
`<B3>' which stands for `ł' character in cp1250 encoding
which gets decoded to "małgorzata poszła do domu"
Example application in vim editor
Place the script in your $PATH
@mkrasowski
mkrasowski / gist:5656970
Created May 27, 2013 13:06
sed: Filter out control and unprintable characters from input stream
s/[\x00-\x08]//g
s/[\x0A-\x0C]//g
s/[\x0E-\x1F]//g
@mkrasowski
mkrasowski / split.sh
Created May 27, 2013 13:03
Split file into parts containing at most given number of lines.
#!/bin/bash
file=$1
lines=$2
sumLines=$(wc -l $file | cut -f1 -d' ')
processed=0
part=1
@mkrasowski
mkrasowski / setup_tunnel.sh
Last active December 22, 2019 18:11
Persistent reverse SSH tunnel. Connect to internal network from outside.
#!/bin/bash
listenport_on_remote=5500
identity_key=/home/me/.ssh/tunnel
#############################
REMOTE=$1
if [ ! "$REMOTE" ]; then
@mkrasowski
mkrasowski / hex2bin.pl
Created May 27, 2013 10:42
Converts a text file containing hexadecimal representation of a binary file content into a binary file.
use strict;
use warnings;
use 5.014;
use autodie;
do {
say "Usage: hex2bin <input> <output>";
exit(1);
} unless @ARGV == 2;