Skip to content

Instantly share code, notes, and snippets.

View raspi's full-sized avatar

raspi

  • finland
  • 11:28 (UTC +03:00)
View GitHub Profile
@raspi
raspi / ffmpeg-cut.sh
Last active March 24, 2021 13:52
Cut a part of a video with FFMPEG
#!/bin/bash
# Cut a part of a video with FFMPEG
if [[ $# -eq 0 ]] ; then
echo "Usage:"
echo " $0 <filename> <start position timestamp> <duration> [additional params]"
echo ""
echo "Example:"
echo " Cut 50 seconds starting from timestamp 01:23:45 from file myvid.mp4"
@raspi
raspi / uuid.go
Created January 26, 2020 13:35
Go UUID from kernel
package main
import (
"fmt"
"io/ioutil"
"strings"
)
func main() {
b, _ := ioutil.ReadFile(`/proc/sys/kernel/random/uuid`)
# Maintainer: Pekka Järvinen
# FreeBSD's pkg git (source) version
# Intended use is for building FreeBSD binary packages on Arch Linux with:
# % pkg create --format txz --root-dir $(PWD) --manifest manifest.sh
pkgname=freebsd-pkg-git
pkgver=1
pkgrel=1
pkgdesc="FreeBSD pkg from source (for building FreeBSD packages on Linux)"
url="https://github.com/freebsd/pkg"
@raspi
raspi / generate-systemd-network.sh
Created May 26, 2019 10:45
Generate SystemD .network files for network interface automatically
#!/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
@raspi
raspi / XCP-NG.md
Created February 17, 2019 00:34
XCP-NG

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 July 20, 2022 17:13
Quick NAT with GNU/Linux iptables firewall

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 November 29, 2018 13:10
List established IPs and ports with DNS resolved names and program names
# 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)
$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
takeown /f "$path"
icacls "$file" /grant administrators:F
@raspi
raspi / dir_match_move.py
Last active October 1, 2018 21:19
Move files based on directory match list to matching directories
#!/bin/env/python
# -*- encoding: utf8 -*-
#
# Move files based on directory match list
#
# Example:
# /sorted directory has following directories:
# - foo
# - bar
#