Skip to content

Instantly share code, notes, and snippets.

@mkhon
mkhon / zabbix_housekeeping.sh
Last active September 9, 2022 08:30
Force zabbix housekeeping with batched DELETE. Sample use: PGPASSWORD=password ./zabbix_housekeeping.sh history history_str history_text history_log history_uint trends trends_uint"
#!/bin/sh
psql="psql -h localhost -U zabbix zabbix"
interval="90 days"
limit=1000000
housekeeping()
{
t="$1"
echo "--> $t"
@mkhon
mkhon / ssh-agent.sh
Created June 27, 2022 12:37
Find existing ssh-agent or start new
#!/bin/sh
SSH_AUTH_SOCK=
for f in `ls /tmp/ssh-*/agent.*`; do
if SSH_AUTH_SOCK=$f ssh-add -l >/dev/null 2>&1; then
SSH_AUTH_SOCK=$f
echo "Found existing ssh agent SSH_AUTH_SOCK=$SSH_AUTH_SOCK"
break
fi
done
@mkhon
mkhon / import_key.py
Last active September 6, 2023 07:06
Copy non-exportable cryptopro key from a directory (*.key files) to registry //  Копирование non-exportable ключа из директории (файлы *.key) в реестр
#!/usr/bin/env python
import os, sys
import re
import winreg
import asn1
KEYNAME_ENCODING = 'windows-1251'
re_keyfile = re.compile(r'\.key$')
@mkhon
mkhon / zfs_revert.py
Last active November 7, 2023 11:12
This is the original zfs_revert-0.1.py script by Martin Vool <mardicas@gmail.com> for reverting ZFS transactions by destroying uberblocks, adapted for FreeBSD od (multiple spaces in output).
#!/usr/bin/python
# -*- coding: utf-8 -*-
#Script for reverting ZFS changes by destroying uberblocks
#Author: Martin Vool
#E-mail: mardicas@gmail.com
#Version: 0.1
#Date: 16 November 2009
@mkhon
mkhon / import-repo.sh
Last active May 7, 2020 13:17
Import private git repo to github
#!/bin/sh
set -e
SOURCE_BASE=${SOURCE_BASE:-git@bitbucket.org:mkhon}
# Example: REPO_PREFIX=orgs/my-org
REPO_PREFIX=${REPO_PREFIX:-user}
import_repo()
{
repo="$1"
@mkhon
mkhon / completer.py
Last active August 29, 2015 14:21
Simple shell-like completer in Python and readline
#!/usr/bin/env python
#
# Based on the following snippets:
# - http://stackoverflow.com/questions/5637124/tab-completion-in-pythons-raw-input
# - http://pysh.sourceforge.net/
#
import os
import re
import readline
import subprocess
@mkhon
mkhon / pfsense-gce.md
Last active December 18, 2017 21:27
pfSense 2.2.2 on Google Compute Engine

Initial install (virt-manager on Linux)

virt-install --name pfsense --ram 1024 --vcpus=1 --os-variant freebsd7 --hvm --vnc \
--controller type=scsi,model=virtio-scsi --disk path=pfSense-2.2.2.raw,size=4,bus=scsi \
--network=bridge:br0,model=virtio \
--cdrom pfSense-LiveCD-2.2.2-RELEASE-amd64.iso

Configure vtnet0 as WAN.

Post-configuration

@mkhon
mkhon / apr-iconv.patch
Created March 5, 2015 12:02
Fix apr-iconv 1.2.1 build with VS2013
Fix apr-iconv build with Visual Studio 2013 (and earlier?).
The error without the patch is:
adobe-stdenc.obj : error LNK2011: precompiled object not linked in; image may not run
..\Release\iconv\adobe-stdenc.so : fatal error LNK1120: 1 unresolved externals
--- build/modules.mk.win.orig 2007-10-19 05:49:36.000000000 +0700
+++ build/modules.mk.win 2015-03-05 17:49:21.000000000 +0600
@@ -218,7 +218,7 @@