Skip to content

Instantly share code, notes, and snippets.

Avatar

Brahim Machkouri brahimmachkouri

View GitHub Profile
@brahimmachkouri
brahimmachkouri / bytes2str.sh
Last active Aug 26, 2022
Hexdump to string (oneliner version)
View bytes2str.sh
#!/bin/bash
xxd -ps -c 1 $1 | awk '{ print "0x" $0 }' ORS=',' | sed s/.$// && echo
@brahimmachkouri
brahimmachkouri / GZLP01.txt
Last active Jun 12, 2022
Cheats Zelda The Wind Waker [PAL] (Gamecube WiiRD Code)
View GZLP01.txt
Maximum Health
003CC531 00000050
Infinite Health
003CC533 00000050
Never Lose Health
041F4A90 60000000
Never Drown
@brahimmachkouri
brahimmachkouri / install_latest_fusion_inventory.sh
Created Mar 9, 2022
Automatic installation of the latest version of fusioninventory in GLPI plugins directory
View install_latest_fusion_inventory.sh
#!/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 Mar 9, 2022
Tampermonkey usercript for pasting the "front matter" block in a github post
View front_matter_block_github_blog.js
// ==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==
View portainerv2-template.json
{
"version": "2",
"templates": [
{
"categories": [
"Music"
],
"description": "Airsonic is a free, web-based media streamer, providing ubiqutious access to your music. Use it to share your music with friends, or to listen to your own music while at work. You can stream to multiple players simultaneously, for instance to one player in your kitchen and another in your living room.",
"env": [
{
View tampermonkey_hm_xmlhttp_request_promise.js
// GM_xmlhttpRequest GET
function getData(url, type = "document", usermethod = "GET") {
return new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: usermethod,
url: url,
responseType: type,
onload: function (response) {
if (response.status == 200) {
resolve(response.response);
View app.py
from tkinter import *
import webbrowser
class MyApp:
def __init__(self):
self.window = Tk()
self.window.title("My Application")
self.window.geometry("720x480")
@brahimmachkouri
brahimmachkouri / nodejs.yml
Last active Feb 19, 2022
Ansible playbook to install nodejs 14
View nodejs.yml
---
- 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 / inject-pubkey.sh
Created Feb 18, 2022
Inject ssh public key into multipass vm
View inject-pubkey.sh
#!/bin/bash
if [ $# -eq 0 ]
then
echo "I need the instance name."
exit
fi
INSTANCE_NAME=$1
multipass copy-files $INSTANCE_NAME:/home/ubuntu/.ssh/authorized_keys .
cat ~/.ssh/id_rsa.pub >> authorized_keys
multipass copy-files authorized_keys $INSTANCE_NAME:/home/ubuntu/.ssh/authorized_keys
@brahimmachkouri
brahimmachkouri / gen_autosigned_certificate.sh
Created Feb 14, 2022
Generate a self signed certificate without asking a passphrase for the private key
View gen_autosigned_certificate.sh
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 5000 -nodes