Skip to content

Instantly share code, notes, and snippets.

@viliampucik
viliampucik / grub-hidpi-console-font.sh
Created December 20, 2022 19:57
GRUB HiDPI Console Font
sudo pacman -S terminus-font
sudo grub-mkfont --output=/boot/efi/grub/fonts/ter-u32b.pf2 --size=32 /usr/share/fonts/misc/ter-u32b.otb
echo GRUB_FONT=/boot/efi/grub/fonts/ter-u32b.pf2 | sudo tee -a /etc/default/grub
sudo grub-mkconfig -o /boot/efi/grub/grub.cfg
@viliampucik
viliampucik / 99-local-webcam.rules
Created June 19, 2021 18:05
Always set zoom level for a webcam
# /etc/udev/rules.d/99-local-webcam.rules
# Logitech C925e webcam zoom
SUBSYSTEM=="video4linux", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="085b", PROGRAM="/usr/bin/v4l2-ctl --set-ctrl zoom_absolute=150 --device /dev/%k"
@viliampucik
viliampucik / nnmreplay.pl
Created January 17, 2021 14:47
Replay NNMi key incidents
#!/usr/bin/env perl
use strict;
use warnings;
use DBD::Pg;
use DBI;
use Getopt::Long qw( :config no_ignore_case bundling );
use Net::Domain 'hostfqdn';
use Net::SNMP ':asn1';
use Pod::Usage;
use POSIX 'strftime';
@viliampucik
viliampucik / pythonstartup.py
Created January 11, 2021 22:02
XDG compliant ~/.python_history
# Store interactive Python shell history in ~/.cache/python_history
# instead of ~/.python_history.
#
# Create the following .config/pythonstartup.py file
# and export its path using PYTHONSTARTUP environment variable:
#
# export PYTHONSTARTUP="${XDG_CONFIG_HOME:-$HOME/.config}/pythonstartup.py"
import atexit
import os
@viliampucik
viliampucik / zte-speedport-entry-2i-key-generator.py
Last active December 6, 2023 12:37
ZTE Speedport Entry 2i Key Generator
#!/usr/bin/env python
#
# ZTE Speedport Entry 2i Key Generator
#
# The script generates the key for decryption and encryption
# of ZTE Speedport Entry 2i configuration file using
# https://github.com/mkst/zte-config-utility
#
# Usage:
#
@viliampucik
viliampucik / jet-patch.c
Created January 10, 2021 11:56
Patch Blocking HP/HPE/DXC/AT&T JET Client From Message (Un)Acknowledging
#include <syslog.h>
#include "opcsvapi.h"
int opcmsg_ack( opc_connection opc_conn, opcdata message_id ) {
const char *id = opcdata_get_str( message_id, OPCDATA_ID );
syslog( LOG_LOCAL0 || LOG_INFO, "JET Patch blocked JET Client from acknowledging %s\n", id );
return OPC_ERR_OK;
}
@viliampucik
viliampucik / gpt-backup-restore.sh
Created January 9, 2021 10:52
GPT Backup and Restore
# GPT Backup
sudo sgdisk --backup=nvme0n1.gpt /dev/nvme0n1
# GPT Restore
sudo sgdisk --load-backup=nvme0n1.gpt /dev/nvme0n1
@viliampucik
viliampucik / timeit-test.py
Created December 1, 2020 18:05
Python code benchmarking example
#!/usr/bin/env python
# An example of Python code benchmarking.
# In this case math.prod vs functools.reduce(operator.mul).
# As can be seen, math.prod is almost twice as fast as the other option:
#
# ./timeit-test.py
# 4.723656065994874
# 7.586232994995953
# 18.008398708996538
@viliampucik
viliampucik / proxy-arp.sh
Created November 18, 2020 17:49
Proxy ARP
#!/bin/sh
# Enable connection between AP and RPi without NAT
# AP --- wifi --- laptop --- ethernet --- RPi
# Reference: https://wiki.debian.org/BridgeNetworkConnectionsProxyArp
# 0. Assign static IP to RPi
# 1. Enable Proxy ARP and routing on the laptop
echo 1 > /proc/sys/net/ipv4/conf/all/proxy_arp
echo 1 > /proc/sys/net/ipv4/ip_forward
@viliampucik
viliampucik / python-http-server.sh
Created June 22, 2020 13:48
Turn Python into HTTP server serving local directory
# Python 3
sudo python -m http.server 80
# Python 2
sudo python2 -m SimpleHTTPServer 80