Skip to content

Instantly share code, notes, and snippets.

View aamaanaa's full-sized avatar
πŸ’»
πš†πšŠπšπšŒπš‘πš’πš—πš πšŠπš—πš’πš–πšŽ

Not Darkness aamaanaa

πŸ’»
πš†πšŠπšπšŒπš‘πš’πš—πš πšŠπš—πš’πš–πšŽ
View GitHub Profile
@alexedwards
alexedwards / cache.go
Last active March 17, 2025 22:35
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.
@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
@vwbusguy
vwbusguy / auto_profile
Last active March 25, 2025 18:09
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=$(tuned-adm list | grep -q throughput-performance && echo "throughput-performance" || echo "balanced")
elif [ $BATT_STAT -eq 5 ]; then
LEVEL="balanced"