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
@FOR /F %%t IN ('cscript //nologo //b %~dp0reset-env.vbs') DO @(
@CALL "%%t"
@DEL /F /Q "%%t"
)
@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"
)
@lboulard
lboulard / .gitattributes
Last active March 17, 2021 08:25
OpenSSH agent on windows
*.bat eol=crlf
*.ps1 eol=crlf
@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 / 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 / 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 / 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 / clang-format.aosp.txt
Created September 27, 2021 12:51
clang-format AOSP style
BasedOnStyle: Google
Standard: Cpp11
AccessModifierOffset: -2
AllowShortFunctionsOnASingleLine: Inline
ColumnLimit: 100
CommentPragmas: NOLINT:.*
DerivePointerAlignment: false
IncludeBlocks: Preserve
IndentWidth: 4
ContinuationIndentWidth: 8
@lboulard
lboulard / README.md
Created October 8, 2021 13:15
Add message to getty login screen on framebuffer

Add message to getty login screen on framebuffer

"man getty" to see option in file

sudo install -m 0755 /etc/issue.d
cat <<EOF | sudo tee /etc/issue.d/details.issue
\n.\o (\s \m \r) \t [\4]

EOF
@lboulard
lboulard / typescript-cleanup.sh
Created November 23, 2021 12:35
Cleanup typescript generated using script command
#!/bin/sed -rf
# Requires GNU sed
#
# Based on this response: https://stackoverflow.com/a/28269556
# ANSI Sequences: https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797
# Remove BEL and BACKSPACE from command line inputs
:again
s/\x07+//g
s/[^\x08]\x08(\x1b\[K)?//