Skip to content

Instantly share code, notes, and snippets.

View dpavlin's full-sized avatar

Dobrica Pavlinušić dpavlin

View GitHub Profile
@dpavlin
dpavlin / gemini-cli-session.html
Created January 8, 2026 07:30
Gemini CLI chat session viewer
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gemini CLI chat session viewer</title>
<style>
:root {
--bg-color: #ffffff;
@dpavlin
dpavlin / google-ai-studio.html
Last active January 8, 2026 07:32
load Google AI studio conversation.json from gdrive backup and display it as single html page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Full Conversation Report</title>
<!-- Using a lightweight and fast Markdown parser from a CDN -->
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<style>
:root {
@dpavlin
dpavlin / scan-A4.sh
Created October 14, 2016 11:33
Scan pages using Sane's scanimage and convert them to pdf (with page and pdf preview using qiv and mupdf)
#!/bin/sh -e
nr=1
mkdir $1
while true ; do
file=$1/`printf "%04d" $nr`.jpg
echo "scanning page $nr -> $file"
scanimage --progress --resolution 300 --format jpg -l 0mm -t 0mm -x 210mm -y 297mm > $file
@dpavlin
dpavlin / bots-disable.conf
Last active July 17, 2024 17:20
apache rewrite_conf for apache cgi applications to mitigate full-cpu usage from badly behaving web robots usually in combination with more than one at the same time
# koha-dev:/etc/apache2# cat bots-disable.conf
RewriteEngine On
# disable PetalBot
RewriteCond %{HTTP_USER_AGENT} PetalBot [NC]
RewriteRule .* - [F]
# disable Barkrowler/0.9;
RewriteCond %{HTTP_USER_AGENT} Barkrowler [NC]
@dpavlin
dpavlin / mount-rpi-image.sh
Last active December 20, 2023 18:21
mount Raspberry Pi image, copy qemu-arm-static and chroot into it to tweak it
#!/bin/sh -xe
# mount Raspberry Pi image, copy qemu-arm-static and chroot into it to tweak it
dir=/tmp/rpi
test "umount" = "$1" && sudo umount $dir/boot && sudo umount $dir
image=$1
test -r "$image" || ( echo "Usage: $0 /path/to/rpi.img" && exit 1 )
@dpavlin
dpavlin / dell-duplicate-mac.txt
Last active August 6, 2022 05:06
How it this even possible? Same MAC on two Dell switches
dpavlin@black:~/dell-switch$ git -C snmpbulkwalk/ grep 0:11:43:9a:5b:88 | grep ifPhysAddress
sw-aula:IF-MIB::ifPhysAddress[25] = STRING: 0:11:43:9a:5b:88
sw-aula:IF-MIB::ifPhysAddress[26] = STRING: 0:11:43:9a:5b:88
sw-aula:IF-MIB::ifPhysAddress[27] = STRING: 0:11:43:9a:5b:88
sw-aula:IF-MIB::ifPhysAddress[28] = STRING: 0:11:43:9a:5b:88
sw-aula:IF-MIB::ifPhysAddress[29] = STRING: 0:11:43:9a:5b:88
sw-aula:IF-MIB::ifPhysAddress[30] = STRING: 0:11:43:9a:5b:88
sw-aula:IF-MIB::ifPhysAddress[31] = STRING: 0:11:43:9a:5b:88
sw-aula:IF-MIB::ifPhysAddress[32] = STRING: 0:11:43:9a:5b:88
sw-aula:IF-MIB::ifPhysAddress[100000] = STRING: 0:11:43:9a:5b:88
@dpavlin
dpavlin / influx-drop-shard.sh
Created April 10, 2022 14:02
drop oldest influxdb shards when disk space becomes too small
#!/bin/sh -e
free=`df -k /var/lib/influxdb/ | grep / | awk '{ print $4 }'`
test "$free" -gt 2097152 && exit 0
df -h /var/lib/influxdb
influx -database telegraf -execute 'show shards' | grep telegraf | head -2 | tee /dev/stderr | awk '{ print $1 }' | tail -1 | xargs -i influx -database telegraf -execute 'drop shard {}'
df -h /var/lib/influxdb
@dpavlin
dpavlin / sort-ip.pl
Created February 27, 2022 14:33
sort text output with ip addresses
#!/usr/bin/perl
use warnings;
use strict;
use Socket qw( inet_aton );
use Getopt::Long;
my $col = 1;
my $del = '\s+';
@dpavlin
dpavlin / Makefile
Last active April 17, 2021 14:38 — forked from kost/esp8266-wifi-beacon-generator.ino
ESP8266 WiFi Beacon Generator - Generate SSID beacon frames on ESP8226
builder:
/opt/arduino-1.6.8/arduino-builder -dump-prefs -logger=machine -hardware "/opt/arduino-1.6.8/hardware" -hardware "/home/dpavlin/.arduino15/packages" -hardware "/home/dpavlin/Arduino/hardware" -tools "/opt/arduino-1.6.8/tools-builder" -tools "/opt/arduino-1.6.8/hardware/tools/avr" -tools "/home/dpavlin/.arduino15/packages" -built-in-libraries "/opt/arduino-1.6.8/libraries" -libraries "/home/dpavlin/Arduino/libraries" -fqbn=esp8266:esp8266:generic:CpuFrequency=80,FlashFreq=40,FlashMode=dio,UploadSpeed=115200,FlashSize=512K64,ResetMethod=nodemcu,Debug=Disabled,DebugLevel=None____ -ide-version=10608 -build-path "/tmp/build74183724a5572046762b09cc6849235c.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "/home/dpavlin/Arduino/esp8266_spam/esp8266_spam.ino"
/opt/arduino-1.6.8/arduino-builder -compile -logger=machine -hardware "/opt/arduino-1.6.8/hardware" -hardware "/home/dpavlin/.arduino15/packages" -hardware "/home/dpavlin/Arduino/hardware" -tools "/opt/arduino-1.6.8/tools-builder" -to
@dpavlin
dpavlin / git.sh
Created April 18, 2020 13:57
do same thing to multiple git repos
#!/bin/sh -e
ls -d */.git | cut -d/ -f1 | while read dir ; do
cd $dir
echo "# cd" `pwd`
git $*
cd ..
done