Skip to content

Instantly share code, notes, and snippets.

View lboulard's full-sized avatar
💭
Be patient. I enjoy real world.

Laurent Boulard lboulard

💭
Be patient. I enjoy real world.
  • Versailles, France
View GitHub Profile
@lboulard
lboulard / dearmor.bat
Created June 22, 2021 13:53
Dearmor PGP Public key using python3
0<0# : ^
"""
:: Keep a python script inside a bat file
:: Source https://stackoverflow.com/a/41651933
@SETLOCAL ENABLEEXTENSIONS
@py -3 -x -B "%~f0" %*
@SET ERR=%ERRORLEVEL%
@:: Pause if not interactive
@ECHO %cmdcmdline% | FIND /i "%~0" >NUL
@IF NOT ERRORLEVEL 1 PAUSE
@lboulard
lboulard / pp_size.py
Last active February 17, 2025 14:47
Pretty size defined in bytes #python #beautify
#!/usr/bin/env python3
# Based on this (incorrect) response <https://stackoverflow.com/a/43750422>
# Changed to always round up size and always display up to 3 decimals.
# Shall also work with now retired python 2 language.
import math
def pp_size(bytes, units=[' bytes','KB','MB','GB','TB', 'PB', 'EB', 'ZB', 'YB'], base=1000.0):
""" Returns a human readable string representation of bytes (decimal unit)"""
@lboulard
lboulard / mage.go
Created April 26, 2021 20:27
Use mage (https://magefile.org) to create all binaries from golang source
//+build mage
// https://magefile.org
package main
import (
"fmt"
"github.com/magefile/mage/sh"
"os"
"regexp"
@lboulard
lboulard / randpasswd.bat
Last active April 3, 2021 08:52
Generate random password shaped as XXXXXX-XXXXXX-XXXXXX
@busybox sh -c "dd if=/dev/urandom| tr -d -c 'a-zA-Z0-9' | head -c 18 | awk '{print substr($1,1,6)"""-"""substr($1,7,6)"""-"""substr($1,13,6)}'"
@lboulard
lboulard / .gitattributes
Last active March 17, 2021 08:25
OpenSSH agent on windows
*.bat eol=crlf
*.ps1 eol=crlf
@lboulard
lboulard / fetch.sh
Created March 3, 2021 16:21
Download images and firmware for Debian testing (Windows with bash from Git)
#!/bin/bash
set -eu
# DVD images
URLS=(
"https://cdimage.debian.org/cdimage/weekly-builds/amd64/iso-dvd/SHA256SUMS"
"https://cdimage.debian.org/cdimage/weekly-builds/amd64/iso-dvd/SHA256SUMS.sign"
"https://cdimage.debian.org/cdimage/weekly-builds/amd64/iso-dvd/debian-testing-amd64-DVD-1.iso"
)
@FOR /F %%t IN ('cscript //nologo //b %~dp0reset-env.vbs') DO @(
@CALL "%%t"
@DEL /F /Q "%%t"
)
@lboulard
lboulard / p.cmd
Created December 14, 2020 09:47
p command to manage path in cmd.exe
@ECHO OFF
VERIFY OTHER 2>nul
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
IF ERRORLEVEL 1 ECHO *** Unable to enable extensions
SET P=%PATH%
IF "%1"=="" GOTO :list
IF "%1"=="list" GOTO :list
@lboulard
lboulard / pipx-jupyter.md
Last active March 13, 2024 18:19
pipx and Jupyter Qt console

pipx version

pipx --version
0.16.3

First installation

pipx install --include-deps jupyterlab
pipx inject jupyterlab matplotlib numpy jupyter-console scipy simpy sympy

pipx inject jupyterlab arrow pandas tabulate isort black jupyterlab_code_formatter

@lboulard
lboulard / untargz.bat
Created September 10, 2020 14:24
untargz on windows using 7Zip command line
@SETLOCAL
@IF "%1" == "" @(
ECHO missing filename as argument
EXIT /B 1
)
@IF "%2" == "" (SET "OUTPUT=-o"%~dpn1"") ELSE (SET "OUTPUT=-o"%~2"")
7z x "%1" -so | 7z x -aoa -si -ttar %OUTPUT%