Skip to content

Instantly share code, notes, and snippets.

@TomCan
TomCan / gist:2183514c0b0d24500a506aa380ce4f48
Created July 19, 2017 10:13
Java settings for Dell iDrac 6
If you're having problems connecting to a Dell iDrac remote console due to Java not trusting the certificate although it's in the exception list, try this.
The certificate is probably signed by a MD5 intermedia certificate, and that's disabled by default. To enable, this, you need to edit your java.security file.
On Windows, this is located at C:\Program Files (x86)\Java\jre_<version-here>\lib\security\java.security
You need to run your editor as Administrator to be able to modify the file.
Find the line that says:
# jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024
If the line starts with a #, remove the # to uncomment it.
@TomCan
TomCan / gist:5af6e3623572bc88d245f4c9eebe51c6
Created June 5, 2018 12:25
Routing traffic out over the interface the connection was received on in a setup where multiple NICs are present.
# If you're using multiple NICs/IPs on AWS, traffic might be sent out over one of the 2 NICs only.
# And the other IP will not be usable.
#
# /etc/network/interfaces
iface eth0 inet dhcp
post-up ip route add default via <ip-of-default-gateway-of-eth0> dev eth0 tab 1
post-up ip rule add from <ip-of-eth0> tab 1
pre-down ip rule del from <ip-of-eth0> tab 1
pre-down ip route del default via <ip-of-default-gateway-of-eth0> dev eth0 tab 1
@TomCan
TomCan / list_large_tables.sql
Created June 12, 2018 08:58
List large tables in MySQL
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 20;
@TomCan
TomCan / gist:8c5976d62523b57ddeb13705af54c45d
Created October 2, 2018 07:06
Remove and re-add a user from MacOS FileVault full disk encryption
When a users' password has been changed on the Active Directory, you can use this procedure to remove the user from FileVault and re-add it with his new password.
sudo fdesetup remove -user username
sudo fdesetup add -usertoadd username
Enter the user name: adminusername
Enter the password for user 'adminusername':
Enter the password for the added user 'username':
Where username is the username of the user you want to remove and re-add.
And adminusername is the username of an administrative user.
@TomCan
TomCan / gist:c77a71742d37643f51d0ee8a63b12947
Created February 4, 2019 13:31
Use curl to test URL's before Go-Live
# show only response headers
# -I
# use 1.2.3.4 as the IP address when connecting to www.tom.be on port 443
# --resolve www.tom.be:443:1.2.3.4 \
# actual URL to test
# https://www.tom.be/this-is-a-test/
curl -I --resolve www.tom.be:443:1.2.3.4 https://www.tom.be/this-is-a-test/
@TomCan
TomCan / ssh-association.sh
Created November 22, 2019 08:10
xdg-open ssh://
xdg-mime default ssh.desktop x-scheme-handler/ssh
cat << EOF > ~/.local/share/applications/ssh.desktop
[Desktop Entry]
Version=1.0
Name=SSH Launcher
Exec=bash -c '(URL="%U" HOST="\${URL:6}"; ssh \$HOST); bash'
Terminal=true
Type=Application
Icon=utilities-terminal
EOF
@TomCan
TomCan / websocket.sh
Last active October 9, 2020 10:57
Check websocket connection (eg. from monitoring software)
#!/bin/bash
#
# Check a websocket connection with curl. Pass URL to check as parameter.
# In normal conditions, this should return a 101 (Switching protocol).
#
CODE=$(timeout 3 curl -s --http1.1 \
--include \
--no-buffer \
--header "Connection: Upgrade" \
@TomCan
TomCan / listsites.ps1
Last active June 11, 2021 10:46
Powershell: list IIS websites with state and bindings
Foreach ($Site in get-website) {
Foreach ($Bind in $Site.bindings.collection) {
Write-Host $Site.name ":" $Site.state ":" $Bind.Protocol ":" $Bind.BindingInformation
}
}
@TomCan
TomCan / lowercase.conf
Created June 16, 2021 11:21
Rewrite to lowercase
# Apache Rewrite all requests to lowercase URLs
RewriteEngine On
RewriteMap lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]
@TomCan
TomCan / reverse-proxy-rewrite-content
Created September 2, 2021 07:13
Apache reverse proxy with content rewrite
#
# use case: Reverse proxy for system that returns fully-qualified URLS in the content (eg. wsdl file)
#
# Requires: mod_proxy, mod_proxy_http and mod_substitute
#
ProxyPass / http://backend-server/Some/API/On/Some/Path/
ProxyPassReverse / http://backend-server/Some/API/On/Some/Path/
# Rewrite URLs in wsdl