Skip to content

Instantly share code, notes, and snippets.

View marcbelmont's full-sized avatar
🐧

Marc Belmont marcbelmont

🐧
View GitHub Profile
@marcbelmont
marcbelmont / fzf_launcher.sh
Last active January 29, 2025 02:16
This Bash script acts as an interactive command launcher using `fzf`, a command-line fuzzy finder. Let's break down its functionality and features:
#!/bin/bash
set -e
history_file="$HOME/.fzf/history"
commands_file="$HOME/.fzf/commands"
cache_expiration=43200 # 12 hours
# Function to regenerate the commands cache if it's missing or outdated
regenerate_commands_cache() {
if [[ ! -f "$commands_file" || $(( $(date +%s) - $(stat -c %Y "$commands_file") )) -gt "$cache_expiration" ]]; then
@marcbelmont
marcbelmont / firefox-apparmor-fix.md
Created December 31, 2024 16:26
The AppArmor profile for Firefox is too restrictiv

The AppArmor profile for Firefox is too restrictive and does not allow certain operations. It can result in the following error message:

kernel: audit: type=1400 audit(1735660893.908:4139): apparmor="DENIED" operation="file_mmap" class="file" profile="firefox" name="/opt/amdgpu/lib/x86_64-linux-gnu/libdrm_radeon.so.1.123.0" pid=53603 comm="glxtest" requested_mask="m" denied_mask="m" fsuid=1000 ouid=0
kernel: audit: type=1400 audit(1735660614.942:4117): apparmor="DENIED" operation="file_mmap" class="file" profile="firefox" name="/opt/amdgpu/lib/x86_64-linux-gnu/libdrm.so.2.123.0" pid=51946 comm=5244442050726F63657373 requested_mask="m" denied_mask="m" fsuid=1000 ouid=0
kernel: audit: type=1400 audit(1735660318.232:4073): apparmor="DENIED" operation="open" class="file" profile="firefox" name="/sys/fs/cgroup/user.slice/user-1000.slice/session-2.scope/cpu.max" pid=49380 comm=57656220436F6E74656E74 requested_mask="r" denied_mask="r" fsuid=1000 ouid=0

To resolve this issue, you can take the foll

@marcbelmont
marcbelmont / Jetson-Orbitty-Platerec.md
Last active February 23, 2022 16:20
Jetson TX2 Packages for Plate Recognizer Stream

After running those commands, you should have the following packages (output from dpkg --list).

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
@marcbelmont
marcbelmont / rofi_notes.py
Last active September 19, 2024 13:19
Manage notes stored in a text file using Rofi. Bonus: tiny calculator using Python's eval. For details, see first comment.
#! /usr/bin/python3
import os
import sys
from pathlib import Path
NOTES = Path('~/Documents/notes.txt').expanduser()
def to_clipboard(text):
os.system('echo "%s"|xclip -f -r -sel c > /dev/null' % str(text).strip())
@marcbelmont
marcbelmont / image_viewer.py
Last active November 13, 2020 09:20
Browser based image viewer. Display all the images from a directory as thumbnails on a webpage.
#! /usr/bin/python3
import argparse
import imghdr
import webbrowser
from http.server import HTTPServer, SimpleHTTPRequestHandler
from os import chdir
from pathlib import Path
from urllib.parse import parse_qs, urlparse
@marcbelmont
marcbelmont / platerec_lookup_memory.py
Last active March 16, 2022 04:51
Use in-memory image in Plate Recognizer and other speed tricks.
import io
import json
import requests
from PIL import Image
def main():
im = Image.new('RGB', (300, 300))
# or
@marcbelmont
marcbelmont / tornado_rollbar.py
Created July 7, 2020 09:06
Use Rollbar with Tornado Web
import tornado.ioloop
import tornado.web
class MyRequestHandler(tornado.web.RequestHandler):
def log_exception(self, typ, value, tb):
rollbar.report_exc_info((typ, value, tb))
super().log_exception(typ, value, tb)
@marcbelmont
marcbelmont / spotify-ad-muter.user.js
Last active April 22, 2024 10:28
Spotify Ad Muter. Automatically mute (block) Spotify ads. Turn sound on again after the ad.
// ==UserScript==
// @name Spotify Ad Muter
// @version 1.2
// @namespace http://tampermonkey.net/
// @description Detects and blocks ads on Spotify. Automatically mute Spotify ads. Turn sound on again after the ad.
// @match https://*.spotify.com/*
// @grant none
// @run-at document-start
// @downloadURL https://gist.github.com/marcbelmont/1ea63270867a4e8786dd5f172d8d4489/raw
// @updateURL https://gist.github.com/marcbelmont/1ea63270867a4e8786dd5f172d8d4489/raw
@marcbelmont
marcbelmont / unicode_icons.py
Last active April 23, 2025 20:49
Add Unicode Icons to Ranger File Manager (see first comment for details). 🖼️ 📂 🎵 🥳
# Unicode Icons in Ranger File Manager
#
# How to install?
# https://gist.github.com/marcbelmont/c12d2fd2519a372d3b347f665b37e74a#gistcomment-3240106
from __future__ import absolute_import, division, print_function
from itertools import repeat
import ranger.api