Turn off caps-lock without the key

I usually don’t have a keyboard key mapped to caps, since I have my caps mapped to escape instead. However, from time to time it still gets activated. So to save me googling-time, this is the easiest way to turn it off: Alternative 1 xmodmap -e "clear Lock" Alternative 2 #! /usr/bin/env python from ctypes import * import subprocess class Display(Structure): """ opaque struct """ X11 = cdll.LoadLibrary("libX11.so.6") X11.XOpenDisplay.restype = POINTER(Display) display = X11.XOpenDisplay(c_int(0)) X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)) X11.XCloseDisplay(display)

HTTPS/SSL/TLS Verify installed certificate

Verify cert is correct openssl s_client -connect domoticz.iix.se:443 -servername domoticz.iix.se </dev/null Verify date of expiry for installed cert # HTTPS openssl s_client -connect example.com:443 -servername example.com 2>/dev/null </dev/null | openssl x509 -noout -dates # SMTP % openssl s_client -starttls smtp -connect smtp.iix.se:25 </dev/null 2>/dev/null | openssl x509 -noout -dates

Java Regex Cheatsheet

Escaping strings in regex replace s.replaceFirst(Pattern.quote("text to replace"), Matcher.quoteReplacement("replacement text"));

March 14, 2019  |  🏷️Regex

Salt Cheatsheet

# List hosts sudo salt-key --list-all # Add host sudo salt-key -a hello-hostname # Apply one/several hosts sudo salt 'hello-hostname' state.apply sudo salt 'hello-*' state.apply sudo salt 'hello-hostname' test.ping sudo salt '*' state.apply users ## När något gick fel och man missade att lessa loggen sudo salt-run jobs.list_jobs sudo salt-run jobs.lookup_jid $jobid | less

March 5, 2019  |  🏷️Salt

Open port in fedora

Open port for a given zone sudo firewall-cmd --zone=FedoraServer --add-port=8080/tcp

OpenSSL / Certificate management

Working with certificates in Java This post contains a mix of java and certificate info. Note that you should definitely use the p12 format in Java. Using other types, like p8, usually end up causing issues in the end. One easy way is by creating a custom trust manager The easiest way of doing this is: (See this link for a code example on stackoverflow Create a custom trust manager with your special certs Create a trust manager with the default certs Create a custom trust manager, which takes the custom and the default trust manager and try them both Another way of doing it would be adding the certificate manually to the cacerts file. Note that you will either need the full certificate chain for it to work, or just the root cert might also work. Note that certs added to the java key store must be in DER-format. See below for converting between formats. When adding with the keytool, you will either need to specify the path manually, or add it with the -cacerts flag to add it to the main key store. The keystore will ask you for password, but the password usually is changeit ...

Docker: Start terminal in Docker without limited size

Sometimes when you exec into a docker container normally, the size of the containers terminal will be much smaller than your real screen, making it not work properly. To solve this you need to set COLUMNS and LINES in the containers env: sudo docker exec -e COLUMNS="$(tput cols)" -e LINES="$(tput lines)" -it docker-container bash

December 14, 2018  |  🏷️Docker

Merging git repositories to a monorepository

BFG-clean repository If you’ve had the bad habit of checking in binary data, this is your chance to clean it up. If so, then run these lines. Tweak the bfg command to your taste. cd git-repo # Optional. Will likely make you able to remove more files. You might want to remove remotes as well. git tag -d $(git tag -l) cd .. java -jar bfg-1.13.0.jar --strip-blobs-bigger-than 5M --delete-files "*.{class, jar, png, svg, ico, zip}" git-repo cd git-repo git reflog expire --expire=now --all && git gc --prune=now --aggressive Move the repository to a subfolder Replace subfolder below with the real subfolder name ...

November 8, 2018  |  🏷️Git 🏷️Bfg

Alternatives for a Grand Seiko

The Grand Seiko Snowflake One of my ideal watches to have would look be like a Grand Seiko Snowflake. The sweeping movement of Seiko’s Spring Drive, the snow-esque dial, dauphine hands, and the blued seconds hand look amazing to me. But since it will never be worth it for me to spend 50k SEK on a watch, I will have to find a cheaper alternative. Luckily, there are a lot of quite similar watches available. At the moment, this page only contains Seikos. Since there are Seiko alternatives in all price classes, there is not really any need to include other brand. ...

Wristwatch and stuff

Accessories Watches I am interested in Maen Hudson ~5k SEK Seiko SARX045 39.5x11.3mm x 48mm 6R15 / 100m WR / Sapphire / 20mm lugs / solid end-links ~5500 SEK Baltic MR01 ~6700 SEK Maen Skymaster 12k SEK Oris Divers Sixty-Five 01 733 7707 4354-07 8 20 18 40mm SW300? / 100 WR / Sapphire / 20mm lugs / solid end-link ~25k SEK MSRP ~17k SEK chrono24 Tag Heuer Carrera Calibre 17 CV2110 - White CV2111 - Black CV2113 - Black Silver Ring ~20-30k SEK chrono24 Tudor Black Bay 58 39mm ~37k SEK MSRP