Skip to content

Instantly share code, notes, and snippets.

@jwhb
jwhb / .bashrc
Created July 26, 2020 17:07
WSL: init gpg-agent in Bash
export GPG_TTY=$(tty)
pgrep -U $UID gpg-agent > /dev/null || gpg-connect-agent /bye > /dev/null 2>&1
@jwhb
jwhb / keepalive.sh
Last active February 10, 2020 13:41
Bash KeepAlive script. This is useful to avoid freezing of Eclipse Che terminals.
#!/bin/sh
while true; do >&2 printf '\x00'; sleep 20; done &
@jwhb
jwhb / search_pdf.sh
Last active April 29, 2019 08:11
Search all PDF files in directory, show all matches for specified search text.
#!/bin/sh
if [ ! "$#" -eq "2" ]; then
echo "Usage: $0 <path> <search_text>"
exit 1
fi
find "$1" -name '*.pdf' -exec sh -c "pdftotext -q '{}' - | grep --with-filename --label='{}' --color -i '$2'" \;
@jwhb
jwhb / ansible.sh
Created October 7, 2018 11:55
Run Ansible via Docker
#!/bin/sh
# start ansible container with working directory mounted as /ansible
# then run ping on targets from inventory file
docker run --rm -v $(pwd):/ansible -it webdevops/ansible:alpine ansible -m ping -i /ansible/inventory all
@jwhb
jwhb / ip-regex.js
Last active October 2, 2018 13:14
IP address octet manipulation with regex
// manipulate octets of IP address with Javascript regular expressions
var regex = /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.)(\d{1,3})(\/[1-3]?\d)$/;
var ip = '169.254.0.17/30';
var octet4 = ip.match(regex)[2] - 1; // match and manipulate octet
var ip2 = ip.replace(regex, '$1' + octet4 + '$3'); // reassemble IP
console.log(ip2); //169.254.0.16/30
@jwhb
jwhb / epk-preview.png
Last active March 20, 2019 14:25
GraphML shapes for EPC/EPK process modeling in yED
epk-preview.png
@jwhb
jwhb / tipp10-solarized-dark.css
Last active January 25, 2021 16:55
Solarized Dark style for TIPP10 online touch typing trainer (https://online.tipp10.com)
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("online.tipp10.com") {
#training, .lightsel0 {
background-color: #002b36;
}
#ticker, #status {
background-color: #073642;
}
#fingers {
@jwhb
jwhb / asadmin-jdbcrealm.sh
Last active January 20, 2017 08:56
Creating a JDBC Security Realm with Asadmin and Derby
# The following asadmin command creates a JDBC Security Realm. It was created with a Derby database in mind, thus all table and column names are in uppercase. For non-Derby databases you might need to respect the actual cases.
asadmin create-auth-realm --classname com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm --property user-name-column=USERNAME:password-column=PASSWORD:digestrealm-password-enc-algorithm=none:group-name-column=GROUPNAME:group-table=USERS_GROUPS:user-table=USERS:datasource-jndi=jdbc/myapp-ds:jaas-context=jdbcRealm:db-user=admin:db-password=admin:digest-algorithm=none:group-table-user-name-column=USERNAME jdbcRealm
@jwhb
jwhb / keybase.md
Last active November 22, 2020 22:45

Keybase proof

I hereby claim:

  • I am jwhb on github.
  • I am jwhy (https://keybase.io/jwhy) on keybase.
  • I have a public key whose fingerprint is 0A90 2DEE 61AD 62B8 6970 5333 8300 84A3 9E8E 3A97

To claim this, I am signing this object:

@jwhb
jwhb / README.md
Last active March 1, 2021 20:49
MSC1937 16-Digit Segment Display Arduino Sketch

Pin connections: Fritzing Circuit