Skip to content

Instantly share code, notes, and snippets.

View mizhka's full-sized avatar

Michael Zhilin mizhka

  • PostgresPro
  • Moscow
View GitHub Profile
@mizhka
mizhka / sysctl-tunables
Created June 4, 2019 09:40
FreeBSD 13-GENERIC-CURRENT tunables
kern.maxproc: Maximum number of processes
kern.ngroups: Maximum number of supplemental groups a user can belong to
kern.ipc.shm_allow_removed: Enable/Disable attachment to attached segments marked for removal
kern.ipc.shm_use_phys: Enable/Disable locking of shared memory pages in core
kern.ipc.shmall: Maximum number of pages available for shared memory
kern.ipc.shmseg: Number of segments per process
kern.ipc.shmmni: Number of shared memory identifiers
kern.ipc.shmmin: Minimum shared memory segment size
kern.ipc.shmmax: Maximum shared memory segment size
kern.ipc.semaem: Adjust on exit max value
alias sw=etherswitchcfg
sw port0 striptag
sw port1 striptag
sw port1 pvid 2
sw port3 addtag
sw port4 addtag
sw vlangroup0 members 0,2,3,4
Result:
<html>
<!DOCTYPE html>
<meta charset="utf-8">
<!-- Load d3.js -->
<script src="https://d3js.org/d3.v4.js"></script>
<!-- Create a div where the graph will take place -->
<div id="my_dataviz"></div>
<script>
function humanFileSize(bytes, si) {
@mizhka
mizhka / openconnect
Last active August 26, 2019 13:45
OpenConnect FreeBSD rc script
#!/bin/sh
# $Id$
#
# $FreeBSD$
#
# PROVIDE: openconnect
# REQUIRE: NETWORKING
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf to enable openconnect
@mizhka
mizhka / dhcpd.conf
Last active March 1, 2022 12:47
Jail+vnet
# dhcpd.conf
# option definitions common to all supported networks...
option subnet-mask 255.255.255.0;
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.20.0 netmask 255.255.255.0 {
range 192.168.20.2 192.168.20.40;
option domain-name-servers 192.168.20.1;
option routers 192.168.20.1;
@mizhka
mizhka / brother_lpdwrapper_DCP1610W
Created December 22, 2019 09:40
DCP1610w filter patched for FreeBSD (location - /usr/local/libexec/cups/filter/)
#! /bin/sh
#
# CUPS filter for DCP1610W
# Copyright Brother Industries,Ltd 2006-2014
#
# Ver1.05
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
% sysctl dev.pcm
dev.pcm.1.bitperfect: 0
dev.pcm.1.buffersize: 65536
dev.pcm.1.rec.vchanformat: s16le:2.0
dev.pcm.1.rec.vchanrate: 48000
dev.pcm.1.rec.vchanmode: fixed
dev.pcm.1.rec.vchans: 1
dev.pcm.1.rec.autosrc: 2
dev.pcm.1.rec.32bit: 24
dev.pcm.1.%parent: hdaa0
@mizhka
mizhka / poudriere_reverse_proxy.lst
Created February 8, 2021 10:40
poudriere behind reverse proxy
# Place these sections into the relevant nginx.conf or included files sections.
worker_processes 1;
events {
worker_connections 1024;
}
http {
# Allow gzipping js, css, log, svg and json files.
@mizhka
mizhka / pgflame.sh
Last active November 18, 2022 20:31
FlameGraph for PostgreSQL with steroids
#/usr/bin/env sh
FLAMEHOME=/home/mizhka/repo/fbsd/FlameGraph
${FLAMEHOME}/stackcollapse-perf.pl $1 | sort | grep Postgre | \
sed 's#postmaster;_start;__libc_start_main;main;PostmasterMain;\[postgres\];##g' | \
sed 's#postmaster;_start;__libc_start_main;main;PostmasterMain;\[unknown\];##g' | \
sed 's#postmaster;\[postgres\];##g' | \
sed 's#postmaster;\[unknown\];##g' | \
sed 's#postgres;\[postgres\];##g' | \
@mizhka
mizhka / xact_timing.awk
Created December 1, 2022 09:23
Transaction information from pg_waldump
#!/usr/bin/awk -f
function process_pgclass (line) {
split(line,field,";")
relid2name[field[8]] = field[2]
#printf("'%s' %s\n", field[8], field[2])
return
}
BEGIN {