Skip to content

Instantly share code, notes, and snippets.

View ohaiibuzzle's full-sized avatar

OHaiiBuzzle ohaiibuzzle

View GitHub Profile
@ohaiibuzzle
ohaiibuzzle / pkg_pl.py
Last active September 3, 2023 20:03
Script to calculate right values for MSR_PKG_POWER_LIMIT
import math
# Get this value by reading msr 0x606
rapl_power_unit_value = 0x330A0E08
# pkg_pl_value = 0x860000DD8600
# Extract the power unit values
# Power units are in bits 3:0
power_units = pow(0.5, (rapl_power_unit_value & 0xF))
time_units = pow(0.5, ((rapl_power_unit_value & 0xF0) >> 8))
@ohaiibuzzle
ohaiibuzzle / usb_notifier.py
Last active March 17, 2024 21:00
macOS USB Notifier
#!/usr/bin/env python3
import subprocess
import plistlib
import time
def send_notification(title, message, sound=None):
command = 'display notification "{}" with title "{}" sound name "{}"'\
.format(message, title, sound) \
#!/bin/bash
API="https://api.open-meteo.com/v1/forecast?latitude=35.6895&longitude=139.69171&current=temperature_2m,relative_humidity_2m,apparent_temperature,is_day,precipitation,cloud_cover,wind_speed_10m,wind_direction_10m,wind_gusts_10m&timezone=Asia%2FBangkok&forecast_days=1"
curl --max-time 2 -s $API |
jq -r '"It'"'"'s currently "
+ (.current.temperature_2m | tostring)
+ (.current_units.temperature_2m | tostring) +
" with "
+ (.current.relative_humidity_2m | tostring)