Skip to content

Instantly share code, notes, and snippets.

View fskale's full-sized avatar

Franz Skale fskale

View GitHub Profile
@fskale
fskale / translate_pot.sh
Last active April 17, 2024 07:48
Translate a .POT file using translate-shell (Shell script version)
#!/usr/bin/env bash
# Translate a POT file using BASH and the translate-shell utility
# homebrew users might install translate-shell by entering
# brew install translate-shell
# Linux user might try the default package manager (dnf/apt-get)
[[ ${BASH_VERSINFO[0]} -lt 4 ]] &&
echo "BASH VERSION MUST BE >= 4" &&
exit 1
@fskale
fskale / get_filebeat_packages.pl
Last active February 28, 2024 11:44
Filebeat package crawler using Mojolicious non-blocking async I/O and a demontration how queuing works
#!/usr/bin/env perl
package Filebeat::Package::Crawler;
use Mojo::Base -base, -signatures, -async_await;
use Mojo::Collection qw(c);
use Mojo::ByteStream qw(b);
use Mojo::Util qw(decode encode secure_compare dumper);
use Mojo::JSON qw(decode_json encode_json);
use Digest::SHA qw(sha512);
@fskale
fskale / check_ssl_cert_file.sh
Created February 28, 2024 11:40
Check-MK local Plugin for checking PEM encoded files for a given extension (defaults to .crt)
#!/bin/bash
OK=0
WARN=1
CRIT=2
UNKN=3
W_DAYS=15
C_DAYS=10
D_PATH="/etc/pki/tls/certs"
@fskale
fskale / async-dns.pl
Last active June 24, 2023 16:43
Async (using Mojolicious, and Future::AsyncAwait) DNS resolution demonstration !
#!/usr/bin/env perl
use 5.026;
use Mojo::Base -strict, -signatures, -async_await;
use Mojo::Promise;
use Socket qw(:addrinfo IPPROTO_UDP SOCK_DGRAM AF_INET AF_INET6);
use Mojo::Collection 'c';
use Net::DNS::Native;
sub _resolve_host ($host, $resolve, $reject) {
@fskale
fskale / hwg.wsdl
Last active January 15, 2021 15:07
Valid HWG-SMS-GW3 WSDL Definition File (Works for Firmware version 1.2.x !)
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:pos="poseidonService.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
targetNamespace="poseidonService.xsd"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
@fskale
fskale / gen-moref-op.pl
Last active March 24, 2020 10:27
async/await/non-blocking I/O demo (Vmware MOREF -> operations JSON mapper - concurrency via recursive queuing - live fetching)
#!/usr/bin/env perl
package Vmware::Moref::Operations;
use Mojo::Base -base, -signatures, -async_await;
use Mojo::Collection 'c';
use Mojo::DOM;
use Mojo::JSON 'j';
use Mojo::Promise;
use Mojo::URL;
use Mojo::UserAgent;
@fskale
fskale / s3-backup.pl
Last active September 4, 2019 10:18
S3 incremental Backup using Mojolicious Non-Blocking I/O (concurrent) (Check Script for required modules) supports Amazon and Hitachi S3 storages (no warranty !)
#!/usr/bin/env perl
package S3::Backup;
use Mojo::Base -base;
use Carp qw(carp croak);
use POSIX qw(strftime ceil floor);
use Fcntl qw(O_WRONLY O_APPEND O_CREAT);
use Fcntl ':mode';
#set utf8 output encoding explicitly
binmode( STDOUT, ":encoding(utf8)" );
@fskale
fskale / dns.pl
Created July 11, 2019 10:41
Non-Blocking DNS Resolution using Net::DNS::Native and Mojo::IOLoop::Delay
#!/usr/bin/env perl
use Mojo::Base -strict;
use Mojo::IOLoop::Delay;
use Net::DNS::Native;
use Socket qw(:addrinfo IPPROTO_UDP SOCK_DGRAM);
my $dns = Net::DNS::Native->new(pool => 5, extra_thread => 1);
my $d = Mojo::IOLoop::Delay->new;
@fskale
fskale / ojo-find-mtime.pl
Created June 6, 2019 09:38
Mojo oneliner to find files that were modified e.g. < 1 week (depth 2 subdirs) and print the the modification time and and the age in seconds !
perl -E 'use Mojo::File "path"; use Cwd "cwd"; my $cwd=cwd(); say path(qq{$cwd})->list_tree({dir => 0, max_depth => 3})->map( sub { my $mtime = path($_)->lstat->mtime; time() - $mtime < 86400 ? sprintf("%s %d %d", $_, path($_)->lstat->mtime, time() - $mtime ) : undef;})->compact->join("\n");'
@fskale
fskale / write-nb.pl
Created June 6, 2019 08:30
Write delayed but non-blocking to STDOUT using Mojolicious ! (E.g. progress to STDOUT)
#!/usr/bin/env perl
use Mojo::Base -strict;
use Mojo::IOLoop::Stream;
use Mojo::IOLoop::Delay;
use Mojo::ByteStream 'b';
# Create stream
my $stream = Mojo::IOLoop::Stream->new(\*STDOUT)->timeout(0);
my $text
= b(