Skip to content

Instantly share code, notes, and snippets.

@agmm
agmm / obsidian-ios-sync.md
Last active April 22, 2024 09:33
How to sync Obsidian Notes on iOS

⚠️ To prevent data loss make sure you understand how rclone sync and rclone copy work.

How to sync Obsidian Notes on iOS

  1. Download iSH from the AppStore

  2. Open iSH and install rclone and nano with the following command:

apk add rclone nano
@agmm
agmm / lightsensor.mm
Last active April 16, 2024 13:56
Ambient light sensor reader (macOS)
// References:
// https://stackoverflow.com/questions/17625495/how-do-you-programmatically-access-the-ambient-light-sensor-on-mac-os-x-10-5
// https://stackoverflow.com/a/73955907
// Build command:
// clang -o lightsensor lightsensor.mm -F /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/PrivateFrameworks -framework Foundation -framework IOKit -framework CoreFoundation -framework BezelServices
#include <mach/mach.h>
#import <Foundation/Foundation.h>
#import <IOKit/IOKitLib.h>
@agmm
agmm / youtube-ublock-filter.txt
Created April 12, 2024 16:44
uBlock filter to disable YouTube's new UI
! uBlock filter to disable YouTube's new UI
youtube.com##+js(set, yt.config_.EXPERIMENT_FLAGS.kevlar_watch_grid, false)
@agmm
agmm / nextjs-file-upload-api.js
Created January 31, 2020 23:03
Simple Nextjs File Upload — Backend API
// Backend
import formidable from 'formidable';
export const config = {
api: {
bodyParser: false,
},
};
export default async (req, res) => {
@agmm
agmm / setpam.sh
Last active January 1, 2024 13:45
Script to enable Touch ID authentication for sudo commands
#!/bin/bash
# Script to enable Touch ID authentication for sudo
echo "Current config:"
cat /etc/pam.d/sudo
echo "Press ENTER to continue"
read
@agmm
agmm / raspi-leds.sh
Created September 9, 2023 12:10
Script to control the onboard LEDs of the Raspberry Pi
#!/bin/bash
# Usage: leds <state>, where state can be 0 or 1
sudo sh -c "echo $1 > /sys/class/leds/PWR/brightness"
sudo sh -c "echo $1 > /sys/class/leds/ACT/brightness"
@agmm
agmm / yt-mp3.sh
Created March 24, 2023 15:29
Download Youtube video as MP3 using Podman
podman run -i --rm -v "$(pwd)":/data w33ble/youtube-dl -x --audio-format mp3 "$1"
@agmm
agmm / bt-scan-1.sh
Created January 21, 2023 20:01
Bluetooth Scan Method 1
sudo hcitool lescan --duplicates
@agmm
agmm / enable-gpio-shutdown-raspberry-pi.md
Created September 11, 2022 14:01
enable-gpio-shutdown-raspberry-pi.md

Edit /boot/config.txt and add the following line:

dtoverlay=gpio-shutdown,gpio_pin=3
@agmm
agmm / pi-temperature-fahrenheit.md
Created August 24, 2022 17:25
pi-temperature-fahrenheit
/usr/bin/vcgencmd measure_temp | awk -F "[=']" '{print($2 * 1.8)+32}'