Skip to content

Instantly share code, notes, and snippets.

Avatar

Pekka Järvinen raspi

View GitHub Profile
@raspi
raspi / dump.php
Created Oct 6, 2020
Dump MySQL SQL query to JSON
View dump.php
<?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
Created Sep 24, 2020
Mumble (murmur) server systemd user service
View murmur.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 Jun 23, 2020
IP Address range to CIDR
View ips2cidr.py
#!/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")
View WinLLDPService.config.example.ps1
# 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 / ffmpeg-cut.sh
Last active Jun 22, 2020
Cut a part of a video with FFMPEG
View ffmpeg-cut.sh
#!/bin/bash
# Cut a part of a video with FFMPEG
if [[ $# -eq 0 ]] ; then
echo "Usage:"
echo " $0 <filename> <start position timestamp> <duration>"
echo ""
echo "Example:"
echo " Cut 50 seconds starting from timestamp 01:23:45 from file myvid.mp4"
@raspi
raspi / uuid.go
Created Jan 26, 2020
Go UUID from kernel
View uuid.go
package main
import (
"fmt"
"io/ioutil"
"strings"
)
func main() {
b, _ := ioutil.ReadFile(`/proc/sys/kernel/random/uuid`)
View FreeBSD-pkg-git.PKGBUILD
# 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
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
You can’t perform that action at this time.