Skip to content

Instantly share code, notes, and snippets.

$ find . -type f | sort
./Dockerfile
./bin/[
./bin/[[
:snip:
./lib/libpthread.so.0
./lib/libresolv.so.2
$ mkdir /tmp/busybox
$ find . -type f | xargs ldd 2>/dev/null | grep -v :$ | perl -pE 's/^\s+//;s/ \(\w+\)$//;s/^.*? => //' | grep ^/ | sort -u | xargs cp -v --parents -t /tmp/busybox
use Mojolicious::Lite -signatures;
# for i in $(carton exec -- perl jenkins.pl jenkins http://localhost:3000/); do k=$(mojo get $i); for j in $(mojo get $i/ws); do echo -e "$j\t$k"; done; done
use Mojo::Util qw(md5_sum);
get '/' => sub ($c) {
$c->render(json => {
number => 1,
url => $c->url_for('job1', name1 => 'a')->to_abs,
CENTRAL="http://localhost:3000"
PushCentral $MYNAME
Summary () {
for U in $WWWDIR/snippet.*.html; do
cat $U >> $WWWDIR/summary.html
RESLT=$?
if [ $RESLT -gt 0 ]; then
echo "$U is unreachable" >> /tmp/tmp.$$.moshel_alert.tmp
fi
package Mojolicious::Plugin::RequestBase;
use Mojo::Base 'Mojolicious::Plugin';
sub register {
my ($self, $app, $conf) = @_;
$app->hook(before_dispatch => sub {
my $c = shift;
#warn $c->req->url;
return unless $c->req->reverse_proxy;
#!/usr/bin/env perl
use Mojolicious::Lite -signatures;
use Mojo::File qw(path);
use Mojo::IOLoop;
use Mojo::JSON qw(false true);
use Mojo::Log;
my $tmp = path('/dev/shm/v')->make_path;
@s1037989
s1037989 / gist:74bc5b0d5bd4e1da409be8850456e1a7
Last active February 18, 2021 02:47
pack non-binary files into a single text file, and unpack them again
txtpack() {
if test -d "$1"/.git; then
cd "$1"
local tmp=$(mktemp -t "$1.$(git rev-parse --short HEAD).XXXX")
cd -
else
local tmp=$(mktemp -t "$1.xxxxxxxxx.XXXX")
fi
for i in $(find "$1" ! -path "*/.git/*" -type f); do
if iconv -f utf-8 -t utf-8 "$i" > /dev/null 2>&1; then
#!/usr/bin/env bash
iwatch() {
local OPTARG OPTIND
while getopts 'qv:V:' o; do
case "$o" in
q) quiet=1;;
v) quiet=1; _REPLY=$OPTARG;;
V) _REPLY=$OPTARG;;
esac
@s1037989
s1037989 / DiePids.pm
Last active January 3, 2021 17:05
Simple TCP Key-Value store in Perl
package DiePids;
use 5.010;
use strict;
use warnings;
use Time::HiRes qw(usleep);
sub new { bless [], shift }
@s1037989
s1037989 / README.md
Last active January 9, 2024 00:37
ip-discover: Setup a device for discovery on a network using socat

ip-discover

Setup a device for discovery on a network using socat

On the device to be discovered:

  • Copy ip-discovery to /usr/bin and run chmod +x /usr/bin/ip-discovery
  • Copy ip-discovery.service to /etc/systemd/system, adjust the code-word, and run sudo systemctl daemon-reload && sudo systemctl start ip-discovery

On the device wanting to discover the device to be discovered:

  • Copy ip-discover to your home folder and run . ~/ip-discover
@s1037989
s1037989 / ff
Last active February 1, 2021 04:05
file filter
#!/usr/bin/env bash
check_perm() {
local path="$1"
local min="$2"
local max="$3"
local owner="$4"
local group="$5"
local stat=( $(stat -L -c "0%#a %U %G" $path 2>/dev/null) )
local fperm=${stat[0]}