Skip to content

Instantly share code, notes, and snippets.

View u1735067's full-sized avatar

Alexandre L. u1735067

View GitHub Profile
@u1735067
u1735067 / keybindings.json
Last active July 11, 2019 22:00
VS Code: move line to the right buffer / editor / group
[
{
"key": "ctrl+alt+right",
"command": "-workbench.action.moveEditorToNextGroup"
},
{
"key": "ctrl+alt+right",
"command": "multiCommand.moveLineRightGroup"
}
]
rename_node() {
RABBITMQ_NODENAME=$1 rabbitmqctl rename_cluster_node $1 $2 && (
mv /var/lib/rabbitmq/mnesia/$1 /var/lib/rabbitmq/mnesia/$2
mv /var/lib/rabbitmq/mnesia/$1-plugins-expand /var/lib/rabbitmq/mnesia/$2-plugins-expand
mv /var/lib/rabbitmq/mnesia/$1-rename /var/lib/rabbitmq/mnesia/$2-rename
mv /var/lib/rabbitmq/mnesia/$1.pid /var/lib/rabbitmq/mnesia/$2.pid
)
}
rename_node old@node new@localhost
@u1735067
u1735067 / python_cheatsheets.txt
Created May 16, 2019 09:24
Collection of Python cheatsheet
https://docs.python.org/3/reference/index.html
https://docs.python.org/3/library/index.html
https://www.cs.put.poznan.pl/csobaniec/software/python/py-qrc.html
https://perso.limsi.fr/pointal/python:abrege
https://perso.limsi.fr/pointal/python:memento
https://perso.limsi.fr/pointal/_media/python:cours:abregepython.pdf
https://perso.limsi.fr/pointal/_media/python:cours:abregepython-english.pdf
https://perso.limsi.fr/pointal/_media/python:cours:mementopython3.pdf
@u1735067
u1735067 / edit_path.py
Created April 24, 2019 10:33
Abandoned Python PATH editor script ; `rundll32 sysdm.cpl,EditEnvironmentVariables` is simpler to use and takes care of the ENV refresh
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import argparse
from collections import OrderedDict
import configparser
import pathlib
import json
import requests
@u1735067
u1735067 / Excel Assoc new instance.ps1
Last active July 16, 2019 12:15
Powershell scriptlet to allow dedicated Excel instances
$ErrorActionPreference = "Stop"
# https://blogs.technet.microsoft.com/heyscriptingguy/2013/12/10/use-powershell-to-create-registry-keys/
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-itemproperty
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-item
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/remove-item
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-itempropertyvalue
# https://docs.microsoft.com/en-us/windows/desktop/shell/fa-verbs
# https://docs.microsoft.com/en-us/windows/desktop/shell/handlers
# https://docs.microsoft.com/en-us/windows/desktop/shell/fa-sample-scenarios
@u1735067
u1735067 / netcat-iptables.txt
Created December 30, 2018 16:15
netcat, netstat, iptables reject
https://unix.stackexchange.com/questions/457670/netcat-how-to-listen-on-a-tcp-port-using-ipv6-address
https://github.com/craSH/socat/blob/master/EXAMPLES
https://serverfault.com/questions/353985/socat-show-incoming-connections
socat -d -d -6 tcp6-listen:5555 stdio
socat -d -d -6 tcp-connect:[ipv6]:88 stdio
https://stackoverflow.com/questions/5106674/error-address-already-in-use-while-binding-socket-with-address-but-the-port-num
http://www.softlab.ntua.gr/facilities/documentation/unix/unix-socket-faq/unix-socket-faq-2.html#time_wait
netstat -Waptun |grep 5555
ss -aptun | grep 5555
@u1735067
u1735067 / ovh-dynhost.service
Last active November 13, 2019 19:22
OVH Dynhost updater Python daemon
[Unit]
Description=OVH Dynhost updater daemon
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/opt/ovh_dynhost.py --journald /etc/opt/ovh_dynhost.ini
Restart=on-abort
[Install]
@u1735067
u1735067 / imap_trash2inbox.py
Last active October 26, 2018 20:25
Little time-saver script, because Microsoft's Outlook.com UI is not able to cancel/rollback a "Delete all" action (no operation possible on Trash's Select all)
# https://imapclient.readthedocs.io/en/2.1.0/
# https://imapclient.readthedocs.io/en/2.1.0/api.html#module-imapclient.testable_imapclient
# py -m pip install imapclient
import imapclient
server = imapclient.IMAPClient('outlook.office365.com')
server.login('user', 'pass)
server.select_folder('Deleted')
messages = server.search()
total_move = len(messages)
@u1735067
u1735067 / .htaccess
Last active December 15, 2019 00:29
htaccess to display the resume PDF in the locale matching the requested subdomain
# Display the PDF when possible, instead of downloading it
<FilesMatch "My Name - CV (?<CV_LANG>[A-Z]{2})\.pdf">
# https://stackoverflow.com/questions/93551/how-to-encode-the-filename-parameter-of-content-disposition-header-in-http
# https://tools.ietf.org/html/rfc5987
Header set "Content-disposition" "inline; filename=\"My Name - CV %{MATCH_CV_LANG}e.pdf\"; filename*=UTF-8''My%%20Name%%20-%%20CV%%20%{MATCH_CV_LANG}e.pdf"
</FilesMatch>
# Finally, default to FR
SetEnvIf HOST "^resume\." CV_LANG=EN
SetEnvIf CV_LANG ^$ CV_LANG=FR
@u1735067
u1735067 / query.ps1
Last active April 30, 2018 14:25
First PowerShell script ; adaptation of query.sh (but with less redundant code)
# You might want Set-ExecutionPolicy -Scope Process RemoteSigned
if ($args.Count -eq 0) {
Write-Host "[*] Example: .\query.ps1 name[@[domain.com]] [..]"
exit 13
}
$dataDir=$PSScriptRoot+'\data'
# https://github.com/BurntSushi/ripgrep
$rg_bin=$PSScriptRoot+'\rg.exe'
$rg_args=@('-aiN')