Skip to content

Instantly share code, notes, and snippets.

With the sample Open Metrics SLOC scrape, how to represent that in a Grafana table with these headers?
Baseline, Release, Total Baseline SLOC Ada, Total Release SLOC C++, Added SLOC Ada, Added SLOC C++, Modified SLOC Ada, Modified SLOC C++, Deleted SLOC Ada, Deleted SLOC C++
ChatGPT said:
To represent the OpenMetrics SLOC data in a Grafana table with your specified headers, follow this plan:
🪄 Grafana Table Setup Plan
📋 Desired Headers:
| Baseline | Release | Total Baseline SLOC Ada | Total Baseline SLOC C++ | Added SLOC Ada | Added SLOC C++ | Modified SLOC Ada | Modified SLOC C++ | Deleted SLOC Ada | Deleted SLOC C++ |
🧮 Step 1: Use Prometheus as a Data Source
JFrog Artifactory doesn't have a Perl repository type, which would regenerate a new set of Perl modules index files on every artifact change in the repository. Create a Jfrog Artifactory plugin that will regenerate the Perl index files every type a file is added, removed or modified in order to allow Artifactory to become a "DarkPAN", or offline CPAN.
ChatGPT said:
To enable JFrog Artifactory to act as a DarkPAN (a private/offline CPAN mirror), you can write a user plugin that listens to events like artifact deployment, deletion, or modification, and then regenerates the required Perl index files (such as 02packages.details.txt.gz, etc.).
🛠 Plugin Strategy
We'll create a User Plugin in Groovy that:
Hooks into the afterCreate, afterDelete, and afterMove events.

Install Perlbrew

$ PERLBREW_ROOT=/data/perlbrew perlbrew init
$ . /data/perlbrew/etc/bashrc
$ perlbrew self-install && perlbrew install-cpanm
$ perlbrew install-multiple -j 10 -n perl-5.40.0 perl-5.32.1 perl-5.26.3

Setup CPAN::Mini::Inject

#!/usr/bin/env perl
use strict;
use warnings;
use File::Find;
use File::Spec;
use File::Basename;
use File::Path qw(make_path);
use MIME::Base64;
my $srcdir = shift or die "Usage: $0 /path/to/dir\n";
$ git log --pretty=format:"%H %d%n%s%n%b%n---" | perl -Mojo -E 'b(<STDIN>)->split("\n\n---")->map(sub{s/^\n//s; b($_)->split("\n",2)->tap(sub{warn $_->[0]; $_->[0] =~ /^([0-9a-f]+)\s+(\(([^\)]+)\))?$/; $_=c($1//"",$2//"",$_->[1]//"")->join("\n")})})->join("\n---\n")->say'

Media Sync

  • Auto Sync
    • When a hard drive is connected (one allowed by usbguard), run an application
    • Using an /etc config file, the UUID maps to what type of content to sync
    • rsync the type of content to the mount point of the hard drive
    • in the background, regularly check the progress of the transfer (du -sbc /dst | tail -1 | cut -f1) / (du -sbc /src | tail -1 | cut -f1) and write the percentage to /tmp/media/mount_point
      • if the size > 100, flip the division
      • if rsync is not running, empty /tmp/media/mount_point
  • if the media is not mounted, remove /tmp/media/mount_point
@s1037989
s1037989 / xprogress.c
Created March 30, 2025 15:59
multiple progress bars for x11
// $ rm -f xprogress.c ; vi xprogress.c ; gcc -o xprogress xprogress.c -lX11
// $ mkdir -p media ; echo 10 > media/media1.txt ; echo 20 > media/media2.txt ; ./xprogress media
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
# https://arminreiter.com/2022/01/create-your-own-certificate-authority-ca-using-openssl/
# https://blog.xelnor.net/firefox-systemcerts/
CANAME=${1:-MyOrg-RootCA}
# optional, create a directory
mkdir $CANAME
cd $CANAME
# generate aes encrypted private key
openssl genrsa -aes256 -out $CANAME.key 4096
# create certificate, 1826 days = 5 years
package Mojolicious::Command::start;
use Mojo::Base 'Mojolicious::Command', -signatures;
use Mojo::Util qw(extract_usage getopt);
has description => 'Show versions of available modules';
has usage => sub { shift->extract_usage };
has perlbrew_with => sub {
return undef unless $ENV{PERLBREW_ROOT} && $ENV{PERLBREW_HOME} && $ENV{PERLBREW_PERL};
@s1037989
s1037989 / gist:0119f95d593b700bdef8a0e56e6e9e98
Created November 14, 2024 01:00
Flickr API OAuth and Upload
package Mojolicious::Plugin::Flickr;
use Mojo::Base 'Mojolicious::Plugin', -signatures;
use Digest::SHA qw(hmac_sha1);
use Mojo::Collection qw(c);
use Mojo::JSON qw(j);
use Mojo::Parameters;
use Mojo::Util qw(b64_encode hmac_sha1_sum md5_sum url_escape);
has app => undef, weak => 1;