Skip to content

Instantly share code, notes, and snippets.

View aamaanaa's full-sized avatar
💻
𝚆𝚊𝚝𝚌𝚑𝚒𝚗𝚐 𝚊𝚗𝚒𝚖𝚎

aamaanaa

💻
𝚆𝚊𝚝𝚌𝚑𝚒𝚗𝚐 𝚊𝚗𝚒𝚖𝚎
  • The multiverse
View GitHub Profile
@vwbusguy
vwbusguy / auto-profile-update.sh
Last active October 31, 2024 14:25
Auto Update for power-profiles-daemon
#!/bin/bash
dbus-monitor --system "type='signal',path='/org/freedesktop/UPower/devices/battery_BAT0',member='PropertiesChanged'" | while read LINE; do
echo ${LINE} | grep battery_BAT0 | grep -q PropertiesChanged
if [ $? -eq 0 ]; then
BATT_STAT=$(dbus-send --print-reply=literal --system --dest=org.freedesktop.UPower /org/freedesktop/UPower/devices/battery_BAT0 org.freedesktop.DBus.Properties.Get string:org.freedesktop.UPower.Device string:State | awk '{ print $3; }')
if [ $BATT_STAT -eq 1 ] || [ $BATT_STAT -eq 4 ]; then
LEVEL=$(powerprofilesctl list | grep -q performance && echo "performance" || echo "balanced")
elif [ $BATT_STAT -eq 5 ]; then
LEVEL="balanced"
@aamaanaa
aamaanaa / gist:20a55dcf98b094583196c662b03f7bbe
Created October 27, 2022 12:03
Linux write access to /var/www/html/project
You will need to add you user to the 'apache' group first. Log out afhter you have done that.
$ sudo mkdir /var/www/html/project
$ sudo chown -R $USER:apache /var/www/html/project
$ sudo chmod -R 775 /var/www/html/project
@alexedwards
alexedwards / cache.go
Last active June 4, 2024 08:01
Generic in-memory cache implementation in Go
package cache
import (
"sync"
"time"
)
// Cache is a basic in-memory key-value cache implementation.
type Cache[K comparable, V any] struct {
items map[K]V // The map storing key-value pairs.