Skip to content

Instantly share code, notes, and snippets.

@brahimmachkouri
brahimmachkouri / .bashrc
Last active September 5, 2023 15:18
To Download : wget bit.ly/my-bashrc
alias ll='ls -laFhGH'
alias h='history'
alias cd..='cd ..'
alias df='df -h'
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
bleu="\[\e[0m\]\[\e[00;34m\]"
@brahimmachkouri
brahimmachkouri / inject-pubkey.sh
Last active September 3, 2023 14:53
Inject ssh public key into multipass vm
#!/bin/bash
if [ $# -eq 0 ]
then
echo "I need the instance name :"
multipass ls
exit
fi
INSTANCE_NAME=$1
multipass copy-files $INSTANCE_NAME:/home/ubuntu/.ssh/authorized_keys .
cat ~/.ssh/id_rsa.pub >> authorized_keys
@brahimmachkouri
brahimmachkouri / sources.list
Created September 2, 2023 14:25
Ubuntu Jammy repositories
deb http://fr.archive.ubuntu.com/ubuntu/ jammy main restricted
deb http://security.ubuntu.com/ubuntu jammy-security main restricted
deb http://fr.archive.ubuntu.com/ubuntu/ jammy-updates main restricted
deb http://fr.archive.ubuntu.com/ubuntu/ jammy universe multiverse
deb http://security.ubuntu.com/ubuntu jammy-security universe multiverse
deb http://fr.archive.ubuntu.com/ubuntu/ jammy-updates universe multiverse
deb http://fr.archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
@brahimmachkouri
brahimmachkouri / show_leases.py
Last active August 18, 2023 08:25
Show actual dhcp leases
#!/usr/bin/python
import datetime, bisect
def parse_timestamp(raw_str):
tokens = raw_str.split()
if len(tokens) == 1:
if tokens[0].lower() == 'never':
return 'never';
@brahimmachkouri
brahimmachkouri / uqload.sh
Last active December 31, 2022 20:53
Download uqload video with youtube-dl
#!/bin/bash
# usage : uqload.sh "direct_url"
youtube-dl --referer "https://uqload.com" --user-agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Firefox/91.0" $1
@brahimmachkouri
brahimmachkouri / fabricjs_draw_rectangle.html
Last active November 25, 2022 13:56
Fabric.js : how to draw a rectangle with the mouse
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>fabric Creating rect with a mouse</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">
@brahimmachkouri
brahimmachkouri / front_matter_block_github_blog.js
Created March 9, 2022 15:56
Tampermonkey usercript for pasting the "front matter" block in a github post
// ==UserScript==
// @name front_matter_block_github_blog
// @namespace brahimmachkouri
// @version 0.1
// @description Paste the "Front Matter" block for Github blogs : go in the edit post and CTRL-V
// @author Brahim Machkouri
// @include https://github.com/*/new/main/_posts
// @grant GM_setClipboard
// @match none
// ==/UserScript==
@brahimmachkouri
brahimmachkouri / pmx-shutdown.sh
Created November 1, 2022 17:47
Proxmox shutdown
#!/bin/bash
# get list of VMs on the node
VMIDs=$(/usr/sbin/qm list| awk '/[0-9]/ {print $1}')
# ask them to shutdown
for VM in $VMIDs
do
/usr/sbin/qm shutdown $VM
done
@brahimmachkouri
brahimmachkouri / bytes2str.sh
Last active August 26, 2022 08:33
Hexdump to string (oneliner version)
#!/bin/bash
xxd -ps -c 1 $1 | awk '{ print "0x" $0 }' ORS=',' | sed s/.$// && echo
@brahimmachkouri
brahimmachkouri / uninstall_ajenti.sh
Last active August 2, 2022 19:34
Uninstall Ajenti
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
DISTRO=
OS=
if grep 'Debian' /etc/issue > /dev/null 2>&1 ; then