Skip to content

Instantly share code, notes, and snippets.

View raspi's full-sized avatar

raspi

  • finland
  • 07:32 (UTC +03:00)
View GitHub Profile
@raspi
raspi / ffmpeg-crop.sh
Last active March 24, 2021 13:52
Crop video with FFMPEG
#!/bin/bash
# Crop a part of a video with FFMPEG
if [[ $# -eq 0 ]] ; then
echo "Usage:"
echo " $0 <filename> <left> <right> <top> <bottom>"
echo ""
echo "Example:"
echo " $0 myvid.mp4 700 600 200 400"
var nativeEndian binary.ByteOrder
func init() {
buf := [2]byte{}
*(*uint16)(unsafe.Pointer(&buf[0])) = uint16(0xABCD)
switch buf {
case [2]byte{0xCD, 0xAB}:
nativeEndian = binary.LittleEndian
case [2]byte{0xAB, 0xCD}:
@raspi
raspi / mac_list_vendors.sh
Created March 16, 2021 22:18
Get vendors from `/proc/net/arp` with systemd's OUI vendor database
#!/bin/bash
# Get vendors from /proc/net/arp with systemd's OUI vendor database
set -eu
set -o pipefail
OUIDB=/usr/lib/udev/hwdb.d/20-OUI.hwdb
while IFS=$' ' read -r ipaddr htype flags mac mask iface;
do
@raspi
raspi / imagemagick_identify_json.sh
Last active March 21, 2023 23:43
Output JSON from ImageMagick magick identify command
#!/bin/bash -e
# Output JSON from ImageMagick magick identify command
if [[ $# -eq 0 ]] ; then
echo "Usage:"
echo " $0 <filename>"
echo ""
exit 0
fi
#!/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 {} \;
@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"
@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 / 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 / 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")
# 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"