Skip to content

Instantly share code, notes, and snippets.

View divi255's full-sized avatar

Sergiy S. divi255

View GitHub Profile
@divi255
divi255 / main.rs
Last active November 14, 2022 01:45
RPC call tracing with Rust+Tokio
// Full article: https://medium.com/@disserman/api-call-tracing-in-high-loaded-asynchronous-rust-applications-bc7b126eb470
//
// Cargo.toml:
// [package]
// name = "rct"
// version = "0.1.0"
// edition = "2021"
//
// [dependencies]
// hyper = { version = "0.14.23", features = ["server", "tcp", "http1"] }
@divi255
divi255 / thinkpad_acpi.patch
Created May 18, 2022 02:11
Thinkpad 2nd fan patch hack for Linux Kernel 5.13. Forces 2nd fan detection and control. Use at your own risk! (confirmed to work on P15 Gen2)
--- drivers/platform/x86/thinkpad_acpi.c.bak 2021-06-28 00:21:11.000000000 +0200
+++ drivers/platform/x86/thinkpad_acpi.c 2022-05-18 04:07:06.814390699 +0200
@@ -8883,31 +8883,22 @@
quirks = tpacpi_check_quirks(fan_quirk_table,
ARRAY_SIZE(fan_quirk_table));
- if (gfan_handle) {
- /* 570, 600e/x, 770e, 770x */
- fan_status_access_mode = TPACPI_FAN_RD_ACPI_GFAN;
- } else {
@divi255
divi255 / pydoc2rst.py
Last active December 22, 2020 23:23
Convert pydoc to rst. Dirty monkey patch above Sphinx.
#!/usr/bin/env python3
import sys
import tempfile
import os
import sphinx.ext.autodoc
from textwrap import dedent
from types import SimpleNamespace
_d = SimpleNamespace(result='')
@divi255
divi255 / update-debian.yml
Last active March 9, 2020 19:57
ansible playbook for debian/ubuntu updates
---
- hosts:
- all
remote_user: root
tasks:
- name: update everything
apt: upgrade=dist force_apt_get=yes autoclean=yes
- name: check if a reboot is necessary
register: reboot_required_file
stat: path=/var/run/reboot-required get_md5=no
@dohq
dohq / fzf-ssh.zsh
Last active March 21, 2024 14:44
fzf-ssh
function fzf-ssh () {
local selected_host=$(grep "Host " ~/.ssh/ssh_config | grep -v '*' | cut -b 6- | fzf --query "$LBUFFER" --prompt="SSH Remote > ")
if [ -n "$selected_host" ]; then
BUFFER="ssh ${selected_host}"
zle accept-line
fi
zle reset-prompt
}
@valyala
valyala / README.md
Last active September 1, 2024 20:40
Optimizing postgresql table for more than 100K inserts per second

Optimizing postgresql table for more than 100K inserts per second

  • Create UNLOGGED table. This reduces the amount of data written to persistent storage by up to 2x.
  • Set WITH (autovacuum_enabled=false) on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we never DELETE or UPDATE the table).
  • Insert rows with COPY FROM STDIN. This is the fastest possible approach to insert rows into table.
  • Minimize the number of indexes in the table, since they slow down inserts. Usually an index on time timestamp with time zone is enough.
  • Add synchronous_commit = off to postgresql.conf.
  • Use table inheritance for fast removal of old data: