Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / install_latest_fusion_inventory.sh
Created March 9, 2022 19:01
Automatic installation of the latest version of fusioninventory in GLPI plugins directory
#!/bin/bash
githubproject="https://github.com/fusioninventory/fusioninventory-for-glpi/releases/latest/"
url=$(curl -Ls -o /dev/null -w %{url_effective} $githubproject)
version=${url##*/}
tag=${version:4}
wget https://github.com/fusioninventory/fusioninventory-for-glpi/releases/download/$version/fusioninventory-$tag.tar.bz2
glpi_install=$(find /var -type f -name glpicrypt.key | sed -E 's/\/config\/glpicrypt\.key//')
tar xvf fusioninventory-$tag.tar.bz2 -C "$glpi_install/plugins/"
chown -R www-data:www-data "$glpi_install/plugins/fusioninventory"
rm fusioninventory-$tag.tar.bz2
@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 / nodejs.yml
Last active February 19, 2022 17:04
Ansible playbook to install nodejs 14
---
- name: ilovenode
hosts: dev
become: yes
gather_facts: no
tasks:
- name: Run the equivalent of "apt-get update" as a separate step
apt:
update_cache: yes
@brahimmachkouri
brahimmachkouri / add_ssh_config_entry.sh
Last active September 9, 2024 09:56
Inject ssh public key into multipass vm
#!/bin/bash
# Ajoute une config SSH pour une connexion simplifiée :
# ssh <NOM_VM_MULTIPASS>
# Vérifie si un argument a été passé au script (le nom de l'instance)
if [ $# -eq 0 ]; then
echo "I need the instance name :"
multipass ls # Liste toutes les instances disponibles pour aider l'utilisateur à choisir
exit 1 # Sort du script si aucun nom d'instance n'est fourni
fi
@brahimmachkouri
brahimmachkouri / gen_autosigned_certificate.sh
Created February 14, 2022 13:30
Generate a self signed certificate without asking a passphrase for the private key
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 5000 -nodes
@brahimmachkouri
brahimmachkouri / install_node.sh
Created February 13, 2022 18:00
Node.js installation
#!/bin/bash
# Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash -
sudo apt-get install -y nodejs