Instantly share code, notes, and snippets.

View list_user_directories.ps1
$items = Get-ItemProperty -Path 'Registry::HKey_Local_Machine\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\*'
Foreach ($item in $items) {
$objUser = New-Object System.Security.Principal.SecurityIdentifier($item.PSChildName)
$objName = $objUser.Translate([System.Security.Principal.NTAccount])
$item.PSChildName = $objName.value
}
Write-Output $items | Select-Object -Property PSChildName, ProfileImagePath
View own_path.ps1
takeown /f "$path"
icacls "$file" /grant administrators:F
View dir_match_move.py
#!/bin/env/python
# -*- encoding: utf8 -*-
#
# Move files based on directory match list
#
# Example:
# /sorted directory has following directories:
# - foo
# - bar
#
View md5move.py
#!/bin/env/python
# -*- encoding: utf8 -*-
# Move files based on file list in a md5 checksum file
# (c) Pekka Järvinen 2017-
import logging
log = logging.getLogger(__name__)
import os
View freebsd_dump_sysctl.sh
#!/bin/sh
# Function for printing
p()
{
KEY=$1
TYPE=$2
DESCR=$3
# last character is '.'
View freebsd_sysctl.md

Settable via /etc/sysctl.conf:

integer kern.maxvnodes

Target for maximum number of vnodes

integer kern.maxfiles

Maximum number of files

integer kern.securelevel

Current secure level

View Microsoft.PowerShell_profile.ps1
$Shell=$Host.UI.RawUI
$size=$Shell.WindowSize
$size.width=120
$size.height=35
$Shell.WindowSize=$size
# buffer
$size = $Shell.BufferSize
$size.width=[system.console]::BufferWidth
View freebsd_zfs_scrub_days.sh
#!/bin/sh
# Wait this many days since last scrub
DAYS=30
LANG=C
NOW=$(date -j +%s)
POOLS=$(zpool list -H -o name)
View freebsd_list_kernel_modules.sh
# 2> /dev/null skips manual pages which doesn't exist
# find /boot/kernel -type f -iname "*acpi*.ko" -exec sh -c 'whatis `basename "{}" ".ko"` 2> /dev/null' \;
acpi_toshiba(4) - Toshiba HCI interface
acpi_panasonic(4) - ACPI hotkey driver for Panasonic laptops
acpi_fujitsu(4) - Fujitsu Laptop Extras
acpi_wmi(4) - ACPI to WMI mapping driver
acpi_hp(4) - ACPI extras driver for HP laptops
acpi_dock(4) - Laptop Docking Station device driver
acpi_sony(4) - ACPI notebook controller driver for Sony laptops
View freebsd_rc.md

accept_sourceroute (default: NO)

accept source routed packets to us

accounting_enable (default: NO)

Turn on process accounting (or NO).

allscreens_flags (default: empty)

Set this vidcontrol mode for all virtual screens

allscreens_kbdflags (default: empty)