Skip to content

Instantly share code, notes, and snippets.

View raspi's full-sized avatar

raspi

  • finland
  • 07:06 (UTC +03:00)
View GitHub Profile
@raspi
raspi / md5move.py
Last active October 1, 2018 21:19
Move files based on file list in a md5 checksum file
#!/bin/env/python
# -*- encoding: utf8 -*-
# Move files based on file list in a md5 checksum file
# (c) Pekka Järvinen 2017-
import logging
log = logging.getLogger(__name__)
import os
@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
#
takeown /f "$path"
icacls "$file" /grant administrators:F
@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

# 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 / 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 / gettext_update.sh
Created July 1, 2014 17:03
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.
#!/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 / 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"