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
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 / pacman-auto-update.service
Last active Feb 16, 2019
Arch Linux Pacman auto download updated packages
View pacman-auto-update.service
# 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 / enable-all-advanced-power-settings.ps1
Last active Feb 14, 2019
Enable all advanced power settings in Windows.
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
@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 / gettext_update.sh
Created Jul 1, 2014
Shell script for updating Gettext .po files in a PHP project. Create new languages simply by copying base.pot to <language code>.po. For example: cp base.pot fi.po. Then just edit fi.po with poedit or some other editor.
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
@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)
@raspi
raspi / esxi_lldp_control.sh
Last active Nov 28, 2018
Enable/Disable LLDP on VMWare ESXi. Requires SSH access to ESXi. Doesn't require vCenter.
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 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
#
You can’t perform that action at this time.