View windows-advanced-power-settings-to-markdown.ps1
# 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}
View enable-all-advanced-power-settings.ps1
# 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
View rm_files_by_dir.py
#!/bin/env/python
# -*- encoding: utf8 -*-
# usage: script.py --file my_filelist.txt --directory /mnt/storage/
# (c) Pekka Järvinen 2017-
import logging
import os
import sys
from argparse import ArgumentParser
View mv_one_file_to_parent.py
#!/bin/env/python
# -*- encoding: utf8 -*-
# Move file to parent directory if it's the only one there including sub-directories.
# usage: script.py <directory>
# script.py /stuff/files/
import os
import sys
from shutil import move
View esxi_lldp_control.sh
#!/bin/sh
# Enable/Disable LLDP on vSwitch ports on VMWare ESXi
# Tested with ESXi 6.0.0 3620759
# Doesn't need vCenter, only SSH access to the ESXi machine
# (c) Pekka "raspi" Jarvinen 2016 http://raspi.fi/
SWITCH=$1
OPERATION=$2
if [ "$SWITCH" = "" ] || [ "$OPERATION" = "" ]; then
View RemoteMachineSetup.md

Environment

  • All machines are local
  • Multiple cheap "stupid" viewer client machines
  • One hypervisor which is used by these client machines

Techs

  • RDP
  • VNC
  • PCoIP
  • Direct video stream
View finnish_vatnum_check.py
def is_vatnum(num):
if len(num) > 9:
return False
if "-" not in num:
return False
n,check = num.split("-")
try:
View gettext_update.sh
#!/bin/bash -e
# generate file list
echo -e "" > files.txt
find ../application -type f \( -iname "*.php" -or -iname "*.phtml" \) -exec readlink -f "{}" \; > files.txt
# scan files
xgettext --force-po --add-comments --from-code=UTF-8 --language=php --package-name=app --package-version=1.0 --msgid-bugs-address=noreply@example.com -o base.pot -f files.txt
# base pot -> <lang>.po update
View rm_only_one_file.py
#!/bin/env/python
# -*- encoding: utf8 -*-
# Remove file from directory if it's the only one there including sub-directories.
# usage: script.py <file to find> <directory>
# script.py readme.txt /stuff/files/misc
import os
import sys
fn = None
View smb.conf.ini
# Samba 4 config example
# Connected to existing remote Samba 4 Active Directory Directory Controller
# ZFS pool @ /storage
# Network is 192.168.101.0/24
# Samba is installed with:
# pkg install samba42
# and then joined to existing AD with:
# samba-tool domain join <params>
# After this /usr/local/etc/smb4.conf is edited and restarted with /usr/local/etc/rc.d/samba_server restart