Skip to content

Instantly share code, notes, and snippets.

@khun84
khun84 / postgresql-replication.md
Last active October 21, 2021 02:16
Postgresql

Playbook to setup physical replication in Postgresql 13

  1. Install the postgresql 13 for replica on another instance. sudo apt-get install postgresql-13. Install binary extension if theres any, ie sudo apt-get install postgresql-13-postgis-3
  2. Create a user in master server for replication connection. create user replica with password <password>
  3. Change the following postgres config in the master server
# in /etc/postgresql/13/main/postgres.conf

max_wal_senders = 5
synchronous_standby_names = 'pgslave001' # or any other you prefer
@khun84
khun84 / README.md
Created October 21, 2021 20:17 — forked from felixhammerl/README.md
Write TLS keys system-wide in macOS via SSLKEYLOGFILE and launchd
  1. Put tlskeylogger.plist at ~/Library/LaunchAgents/tlskeylogger.plist
  2. launchctl load ~/Library/LaunchAgents/tlskeylogger.plist, so it will load on the next restart
  3. launchctl start ~/Library/LaunchAgents/tlskeylogger.plist, so it will load the environment variable immediately
  4. Restart your browser(s)
  5. See how TLS keys are being written to ~/.tlskeyfile via tail -f ~/.tlskeyfile
@khun84
khun84 / wireshark.md
Created October 21, 2021 20:17 — forked from EddiG/wireshark.md
How to decrypt SSL/TLS traffic in Wireshark on MacOS

The main point is to save the SSL/TLS keys those used by the web browser (SSLKEYLOGFILE=/tmp/tmp-google/.ssl-key.log).
In the example below we run brand new instance of Google Chrome (--user-data-dir=/tmp/tmp-google do the trick):
SSLKEYLOGFILE=/tmp/tmp-google/.ssl-key.log /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir=/tmp/tmp-google
Then run the Wireshark and open the Preferences -> Protocols -> SSL, where we put the path to the SSL keys log file into the (Pre)-Master-Secret log filename field.
Now all SSL/TLS traffic from this browser instance will be decrypted.

@khun84
khun84 / holistics-jobs-export.rb
Last active January 19, 2022 02:31
Holistics jobs export
require 'json'
require 'csv'
data = `pbpaste`
data = JSON.parse(data);nil
data = data.select{|d| d.dig('schedule', 'paused') == false && d['source_type'] == 'dbtable' };nil
keys = [
'title',
'description',
'src_db', # from_ds_name
@khun84
khun84 / kafka-ruby.md
Last active December 19, 2022 13:54
Kafka
require 'kafka'
require 'avro_turf/messaging'

kaf_broker = "from-ur-credentials"
kaf_api_key = "from-ur-credentials"
kaf_api_secret = "from-ur-credentials"
schema_url = "from-ur-credentials"
schema_api_key = "from-ur-credentials"
schema_api_secret = "from-ur-credentials"
@khun84
khun84 / install-libv8.md
Created April 22, 2022 03:06
Fixing libv8 installation

Basically we just need to do the following

# 1. Install v8 ourselves
$ brew install v8-315
# 2. Install libv8 using the v8 binary we just installed
$ gem install libv8 -v '3.16.14.19' -- --with-system-v8
# 3. Install therubyracer using the v8 binary we just installed
$ gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8@315 # your path could be different, e.g. /usr/local/opt/[email protected]
# 4. Install the remaining dependencies
@khun84
khun84 / Nodejs Snippet
Last active August 20, 2022 01:44
Nodejs snippet
- sleep
- pipeline
- parallel task
@khun84
khun84 / Ruby Snippets
Last active August 20, 2022 06:31
Ruby snippets
- concurrent thread pool

ai-coding-assistant.md

🎯 Purpose

This prompt defines how an AI assistant should behave when collaborating with senior engineers. The assistant serves two key roles:

  1. As a fast and accurate executor for tactical tasks
  2. As a critical thinking partner for design, review, and sequencing

It promotes clean engineering habits, testability, sustainable delivery, and clear communication—without slowing down progress.

import logging
import sys
import os
import time
from confluent_kafka.admin import AdminClient, NewTopic, KafkaException
from confluent_kafka import Producer, Consumer, TopicPartition, OFFSET_BEGINNING, OFFSET_END, \
ConsumerGroupTopicPartitions
# --- Configuration ---
KAFKA_BROKERS = "comma separated list of brokers" # IMPORTANT: Use your SSL port (e.g., 9093)