Skip to content

Instantly share code, notes, and snippets.

Alexandre L. Alex131089

Block or report user

Report or block Alex131089

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Alex131089
Alex131089 / channel.py.diff
Last active Jan 14, 2020
Patch Paramiko channel.py to add channel logging (to debug SCP for example)
View channel.py.diff
diff --git a/channel.py b/channel.patched.py
index 41b1895..2766b94 100644
--- a/channel.py
+++ b/channel.patched.py
@@ -187,6 +187,9 @@ class Channel(ClosingContextManager):
`.SSHException` -- if the request was rejected or the channel was
closed
"""
+ self._log(DEBUG, 'Requesting PTY (termtype={}, width={}, heigth={}, width_pixel={}, heigth_pixel={})'.format(
+ term, width, height, width_pixels, height_pixels
@Alex131089
Alex131089 / extract-android-tabs.bat
Created Jan 5, 2020
Script to extract opened tabs from Android (Chromium-based browsers)
View extract-android-tabs.bat
@echo off
:: https://android.stackexchange.com/questions/56635/how-can-i-export-the-list-of-open-chrome-tabs
echo Waiting for device ..
Z:\Dev\Android\adb.exe wait-for-device
echo Connected to device, open Chrome and wait a bit
pause
Z:\Dev\Android\adb.exe forward tcp:9222 localabstract:chrome_devtools_remote
chcp 65001 > nul
Z:\Utils\curl.exe -s http://127.0.0.1:9222/json/list | Z:\Utils\jq.exe -r "sort_by(.id) | .[] | ""-" [\(if (.title ^| length) ^> 0 then .title ^| gsub(""^'""";"""'""")" else .url end)](\(.url))"""
Z:\Dev\Android\adb.exe kill-server
@Alex131089
Alex131089 / 01-php-fpm_source_handler.conf
Created Nov 28, 2019
Apache 2.4 conf to display .phps (or any file type marked with handler `application/x-httpd-php-source`) as highlighted, like with mod_php. Thanks VBart for the original nginx idea (Apache is a bit more tricky ..). There's 2 files.
View 01-php-fpm_source_handler.conf
### PHP-FPM Source (.phps) type handler ; conditions are taken from CentOS8 php.conf
# https://stackoverflow.com/questions/11085086/php-fpm-is-parsing-phps-instead-of-showing-code-hilighted
<IfModule !mod_php5.c>
<IfModule !mod_php7.c>
<Directory "/real/path/to/">
Require all granted
# https://httpd.apache.org/docs/2.4/en/expr.html
<If "%{REQUEST_URI} == '/php-fpm/highlight.php'">
Redirect 404
</If>
@Alex131089
Alex131089 / borg_chroot.sh
Last active Oct 20, 2019
Workaround to convert simple tar backup to borg backup, without leading path, using ratarmount (should works with archivemount too) and mergerfs
View borg_chroot.sh
mkdir -p /chroot_tmp/{logs,mnt,archive_mnt,bins_mnt/dev,bins_mnt/lib,bins_mnt/lib64,bins_mnt/tmp/repo}
cd /chroot_tmp
wget https://github.com/borgbackup/borg/releases/download/1.1.10/borg-linux64 -O /bins_mnt/tmp/borg
chmod +x /chroot_tmp/bins_mnt/tmp/borg
wget https://www.busybox.net/downloads/binaries/1.31.0-defconfig-multiarch-musl/busybox-x86_64 -O /bins_mnt/tmp/busybox
chmod +x /chroot_tmp/bins_mnt/tmp/busybox
wget https://github.com/mxmlnkn/ratarmount/raw/master/ratarmount.py -O ratarmount.py
wget https://github.com/fusepy/fusepy/raw/master/fuse.py -o fuse.py
@Alex131089
Alex131089 / open_chardet.py
Created Sep 18, 2019
Chardet (https://github.com/chardet/chardet) automatic open (from CLI example)
View open_chardet.py
from chardet.universaldetector import UniversalDetector
def open_chardet(file, *args, **kwargs):
detector = UniversalDetector()
with open(file, mode='rb') as fh:
for line in fh:
line = bytearray(line)
detector.feed(line)
if detector.done:
@Alex131089
Alex131089 / Vagrantfile
Last active Nov 4, 2019
CentOS + Cockpit + Docker + Portainer
View Vagrantfile
Vagrant.configure("2") do |config|
# https://www.vagrantup.com/docs/other/environmental-variables.html#vagrant_checkpoint_disable
# rundll32 sysdm.cpl,EditEnvironmentVariables
# set CHECKPOINT_DISABLE=1
#config.vm.box_check_update = false
config.vm.box = "centos/7"
config.vm.provider "virtualbox" do |vb|
#vb.cpus = 2
vb.memory = "768"
vb.default_nic_type = "virtio"
@Alex131089
Alex131089 / keybindings.json
Last active Jul 11, 2019
VS Code: move line to the right buffer / editor / group
View keybindings.json
[
{
"key": "ctrl+alt+right",
"command": "-workbench.action.moveEditorToNextGroup"
},
{
"key": "ctrl+alt+right",
"command": "multiCommand.moveLineRightGroup"
}
]
View rabbitmq_rename_cluster.sh
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
@Alex131089
Alex131089 / python_cheatsheets.txt
Created May 16, 2019
Collection of Python cheatsheet
View python_cheatsheets.txt
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
@Alex131089
Alex131089 / edit_path.py
Created Apr 24, 2019
Abandoned Python PATH editor script ; `rundll32 sysdm.cpl,EditEnvironmentVariables` is simpler to use and takes care of the ENV refresh
View edit_path.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import argparse
from collections import OrderedDict
import configparser
import pathlib
import json
import requests
You can’t perform that action at this time.