Skip to content

Instantly share code, notes, and snippets.

View raspi's full-sized avatar

raspi

  • finland
  • 15:29 (UTC +03:00)
View GitHub Profile
@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
# 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 / 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`)
@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"
# Fetch system specific information
# -- Get Operating system name such as "Win 10 Pro"
$replaceTable = @{
"Microsoft" = ""
"Windows" = "Win"
"Professional" = "Pro"
"Ultimate" = "Ult"
"Enterprise" = "Ent"
"Edition" = "Ed"
@raspi
raspi / ips2cidr.py
Last active June 23, 2020 17:37
IP Address range to CIDR
#!/usr/bin/env python3
# IP address range to CIDR
import sys
import ipaddress
if (len(sys.argv) - 1) != 2:
print("Usage: ")
print(f" {sys.argv[0]} <ip address> <ip address>")
print("Example: ")
print(f" {sys.argv[0]} 192.168.0.0 192.168.0.255")
@raspi
raspi / murmur.service
Last active September 16, 2023 16:22
Mumble (murmur) server systemd user service
# systemctl --user enable murmur
# systemctl --user start murmur
# .config/systemd/user/murmur.service :
[Unit]
Description=Mumble Daemon
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/murmurd -ini murmur.ini -fg
@raspi
raspi / dump.php
Created October 6, 2020 02:09
Dump MySQL SQL query to JSON
<?php
/*
Usage:
$ php dump.php "SELECT * FROM mytable" > mytable.json
*/
error_reporting(E_ALL | E_STRICT);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
@raspi
raspi / receiver.sh
Last active December 18, 2020 15:11
gstreamer RTP Sender and Receiver
#!/bin/bash
set -eu
set -o pipefail
DEST=127.0.0.1
# this adjusts the latency in the receiver
LATENCY=0
VIDEO_CAPS="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264"
#!/bin/bash
find . -maxdepth 1 -type f -iname "*.pdf" -exec gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dDownsampleColorImages=true -dColorImageResolution=150 -dNOPAUSE -dBATCH -sOutputFile={}.new.pdf {} \;