Skip to content

Instantly share code, notes, and snippets.

View raspi's full-sized avatar

raspi

  • finland
  • 04:18 (UTC +03:00)
View GitHub Profile
@raspi
raspi / enable-all-advanced-power-settings.ps1
Last active October 11, 2024 00:36
Enable all advanced power settings in Windows.
# List all possible power config GUIDs in Windows
# Run: this-script.ps1 | Out-File powercfg.ps1
# Then edit and run powercfg.ps1
# (c) Pekka "raspi" Järvinen 2017
$powerSettingTable = Get-WmiObject -Namespace root\cimv2\power -Class Win32_PowerSetting
$powerSettingInSubgroubTable = Get-WmiObject -Namespace root\cimv2\power -Class Win32_PowerSettingInSubgroup
Get-WmiObject -Namespace root\cimv2\power -Class Win32_PowerSettingCapabilities | ForEach-Object {
$tmp = $_.ManagedElement
@raspi
raspi / windows-advanced-power-settings-to-markdown.ps1
Created June 14, 2017 22:10
List Windows advanced power settings as MarkDown
# List Windows advanced power settings as MarkDown
# Use:
# this-script.ps1 | Out-File power.md
# Use powercfg to show hidden settings:
# powercfg -attributes <Group GUID> <GUID> -ATTRIB_HIDE
# example:
# powercfg -attributes 54533251-82be-4824-96c1-47b60b740d00 06cadf0e-64ed-448a-8927-ce7bf90eb35d -ATTRIB_HIDE
# (c) Pekka "raspi" Järvinen 2017-
$powerSettingSubgroubTable = Get-WmiObject -Namespace root\cimv2\power -Class Win32_PowerSettingSubgroup | Where-Object {$_.ElementName -ne $null}
@raspi
raspi / pacman-auto-update.service
Last active June 2, 2024 03:19
Arch Linux Pacman auto download updated packages
# Download new packages but don't install them
# Save in /etc/systemd/system/
[Unit]
Description=Pacman Automatic Download (no install) service
After=network-online.target
[Service]
# Wait time if process hangs
TimeoutStopSec=5m
@raspi
raspi / murmur.service
Last active September 16, 2023 16:22
Mumble (murmur) server systemd user service
# systemctl --user enable murmur
# systemctl --user start murmur
# .config/systemd/user/murmur.service :
[Unit]
Description=Mumble Daemon
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/murmurd -ini murmur.ini -fg
#!/bin/bash
# source_*.png (source_1234.png) to mkv
find . -type f -iname "*.png" -printf "%f\n" | sort -n | xargs cat | ffmpeg -f image2pipe -i - output.mkv
@raspi
raspi / list_ff_open_handles.sh
Created August 3, 2023 00:07
List firefox open handles
pgrep -fi firefox | xargs -I{} find /proc/{}/fd -readable -type l -printf '%p%f: %l\n'
# Local chat with socat
# Server runs:
socat ABSTRACT-LISTEN:@chat,socktype=5,fork STDOUT
# Client:
socat ABSTRACT-CONNECT:@chat,socktype=5 -
from itertools import permutations
from typing import Generator, List
def gen(s: List[str]) -> Generator:
for i in permutations(s, len(s)):
yield list(i)
def acro(a:List[str]) -> Generator:
for i in gen(a):
firsts:List[str] = []
SELECT
d.datname db
FROM
pg_catalog.pg_database d
WHERE
d.datname NOT LIKE ALL (ARRAY ['template%', 'postgres'])
ORDER BY 1;
@raspi
raspi / network-ping-gateway.service
Created October 20, 2017 18:42
Systemd service for pinging default gateway
# Save in /etc/systemd/system/network-ping-gateway.service
[Unit]
Description=Ping default network gateway service
After=network-online.target
[Service]
# Wait time if process hangs
TimeoutStopSec=1m
# Command to run