Skip to content

Instantly share code, notes, and snippets.

View gmolveau's full-sized avatar

Grégoire MOLVEAU gmolveau

View GitHub Profile
@gmolveau
gmolveau / os.sh
Last active January 19, 2024 09:49
Bash/shell script detect/check OS and distribution (+WSL Windows Subsystem for Linux)
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
local DISTRIB=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
if [[ ${DISTRIB} = "Ubuntu"* ]]; then
if uname -a | grep -q '^Linux.*Microsoft'; then
# ubuntu via WSL Windows Subsystem for Linux
else
# native ubuntu
fi
elif [[ ${DISTRIB} = "Debian"* ]]; then
# debian
@gmolveau
gmolveau / usb-automount.sh
Last active January 7, 2024 17:56
ubuntu server automount usb hard drive exfat
sudo fdisk -l
sudo blkid
# note the UUID
# create the folder where you want the USB drive to be mounted
sudo mkdir -p /media/usb
# if your USB drive is in exfat
sudo apt install exfat-fuse exfat-utils
@gmolveau
gmolveau / 7z_bruteforce.py
Last active December 5, 2023 22:24
Python 7zip bruteforce
import subprocess
import sys
def main():
archive = sys.argv[1]
dictionary = sys.argv[2]
with open(dictionary, "r") as dic:
for line in dic:
word = line.rstrip('\n')
stdout = subprocess.call(
@gmolveau
gmolveau / install_dirb.sh
Created September 2, 2019 12:01
mac osx dirb install
cd ~/Applications
wget https://downloads.sourceforge.net/project/dirb/dirb/2.22/dirb222.tar.gz
tar -xvf dirb222.tar.gz
rm dirb222.tar.gz
brew install autoconf
chmod -R 755 dirb222
cd dirb222
./configure
make
make install
@gmolveau
gmolveau / argparse_global.py
Created February 8, 2019 15:43
Python argparse example of a global variable usage
import argparse
CONSOLE_ARGUMENTS = None
def test():
print(CONSOLE_ARGUMENTS.color_enabled)
def main():
parser = argparse.ArgumentParser(description='test script with global argparse')
#!/usr/bin/env bash
# Bash3 Boilerplate. Copyright (c) 2014, kvz.io
set -o errexit
set -o pipefail
set -o nounset
# set -o xtrace
# Set magic variables for current file & dir
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
{
"profiles": {
"__Default_Settings__": {
"removeHiddenElements": true,
"removeUnusedStyles": true,
"removeUnusedFonts": true,
"removeFrames": true,
"removeImports": true,
"compressHTML": true,
"compressCSS": true,
@gmolveau
gmolveau / dvd_logo_bouncing.html
Created October 7, 2023 06:02
DVD logo bouncing corners changing colors in responsive portable HTML
<html>
<head>
<title>Bouncing DVD Logo</title>
<style>
* {margin:0; padding: 0; color:red;}
</style>
</head>
<body>
<canvas id="tv-screen"></canvas>
@gmolveau
gmolveau / fsck_fix.sh
Last active September 11, 2023 21:50
fsck exited with status code 4 (initramfs)
#/dev/sda5: recovering journal
#/dev/sda5 contains a file system with errors, check forces.
#/dev/sda5:
#Inodes that were part of a corrupted system orphan linked list found.
#
#/dev/sda5: UNEXPECTED INCONSISTENCY: RUN fsck MANUALLY.
# (i.e., without -a or -p options)
#fsck exited with status code 4
#the root filesystem on /dev/sda5 requires a manual fsck
#Busybox v [...]
@gmolveau
gmolveau / finder_macos_new_text_file_automator.md
Last active September 11, 2023 18:56
Create a new text file in the finder with Automator and Quick Action
  • open automator
  • create new quick action
  • workflow received no input in Finder.app
  • search run apple script and double-click on it
  • replace code with :
tell application "Finder"
    set txt to make new file at (the target of the front window) as alias with properties {name:"newfile.txt"}
 select txt