Skip to content

Instantly share code, notes, and snippets.

Pekka Järvinen raspi

Block or report user

Report or block raspi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@raspi
raspi / generate-systemd-network.sh
Created May 26, 2019
Generate SystemD .network files for network interface automatically
View generate-systemd-network.sh
#!/bin/bash -e
# Generate SystemD .network files for network interface automatically
# (c) Pekka Järvinen 2019-
# Check that there are arguments given
if [ "$#" -eq 0 ]; then
echo "No arguments were given. See $0 --help or $0 -h for usage instructions." 1>&2
exit 1
fi
View XCP-NG.md

Local ISOs:

xe sr-create name-label="iso" type=iso device-config:location=/mnt/zfs/iso device-config:legacy_mode=true content-type=iso
@raspi
raspi / Quick Linux iptables NAT.md
Last active Feb 12, 2019
Quick NAT with GNU/Linux iptables firewall
View Quick Linux iptables NAT.md

Quick NAT with GNU/Linux iptables firewall.

First set static IP for LAN adapter:

ip address add 192.168.99.1/24 dev LANeth0

Enable packet forwarding:

echo 1 > /proc/sys/net/ipv4/ip_forward
@raspi
raspi / list_established_ports.ps1
Created Nov 29, 2018
List established IPs and ports with DNS resolved names and program names
View list_established_ports.ps1
# List established IPs and ports with DNS resolved names and program names
$nfo = @()
ForEach ($c in Get-NetTCPConnection -State Established) {
if ($c.LocalAddress -eq $c.RemoteAddress) {
# skip same IP's
Continue
}
$prog = (Get-Process -Id $c.OwningProcess)
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
@raspi
raspi / dir_match_move.py
Last active Oct 1, 2018
Move files based on directory match list to matching directories
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 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)
@raspi
raspi / freebsd_dump_sysctl.sh
Last active Sep 28, 2018
Dump FreeBSD sysctl descriptions as markdown
View freebsd_dump_sysctl.sh
#!/bin/sh
# Function for printing
p()
{
KEY=$1
TYPE=$2
DESCR=$3
# last character is '.'
You can’t perform that action at this time.