Skip to content

Instantly share code, notes, and snippets.

@robsmith1776
robsmith1776 / journalctl.txt
Created July 7, 2023 15:04 — forked from MrAndrewMal/journalctl.txt
How to read live-tail logs of multiple services with journalctl
#Systemd - How to read live-tail logs of multiple services with journalctl
sudo journalctl --follow _SYSTEMD_UNIT=docker.service + _SYSTEMD_UNIT=apache2.service
@robsmith1776
robsmith1776 / Dockerfile
Created December 8, 2022 22:13 — forked from tym-xqo/Dockerfile
pg_service.conf + psycopg2 example
FROM python:3-alpine
# install requirements for psycopg2
RUN apk update && apk add -u \
postgresql-dev \
gcc \
python3-dev \
musl-dev
RUN pip3 install psycopg2

Mac install Nerd Font (Fire code)

brew cask
brew tap homebrew/cask-fonts 
brew install font-fira-code
brew install font-Fira-Code-nerd-font
brew install font-hack-nerd-font
@robsmith1776
robsmith1776 / README.md
Created September 29, 2022 17:12 — forked from valyala/README.md
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:
with table_stats as (
select psut.relname,
psut.n_live_tup,
1.0 * psut.idx_scan / greatest(1, psut.seq_scan + psut.idx_scan) as index_use_ratio
from pg_stat_user_tables psut
order by psut.n_live_tup desc
),
table_io as (
select psiut.relname,
sum(psiut.heap_blks_read) as table_page_read,
import rds_config
import mysql.connector
import csv
connection = None
# create connection to MySQL database
try:
connection = mysql.connector.connect(user=rds_config.db_username,
@zoonderkins
zoonderkins / mac-install-nerd-font.md
Last active June 13, 2023 10:07
Mac install Nerd Font

Mac install Nerd Font (Fire code)

brew cask
brew tap homebrew/cask-fonts 
brew install font-fira-code
brew install font-Fira-Code-nerd-font
brew install font-hack-nerd-font
@MrAndrewMal
MrAndrewMal / journalctl.txt
Last active December 8, 2023 00:55
How to read live-tail logs of multiple services with journalctl
#Systemd - How to read live-tail logs of multiple services with journalctl
sudo journalctl --follow _SYSTEMD_UNIT=docker.service + _SYSTEMD_UNIT=apache2.service
@MineRobber9000
MineRobber9000 / donotuse3.py
Last active February 8, 2024 12:48
How to NEVER use lambdas - Python 3 edition
###########################################################
# How to NEVER use lambdas. An inneficient and yet educa- #
# tonal [sic] guide to the proper misuse of the lambda #
# construct in Python 3.x. [DO NOT USE ANY OF THIS EVER] #
# original by (and apologies to): e000 (13/6/11) #
# now in Python 3 courtesy of: khuxkm (17/9/20) #
###########################################################
## Part 1. Basic LAMBDA Introduction ##
# If you're reading this, you've probably already read e000's
@robsmith1776
robsmith1776 / crosstab.sql
Created September 13, 2020 12:33 — forked from romansklenar/crosstab.sql
PostgreSQL "pivot table" example using tablefunc extension
CREATE EXTENSION tablefunc;
CREATE TABLE sales(year int, month int, qty int);
INSERT INTO sales VALUES(2007, 1, 1000);
INSERT INTO sales VALUES(2007, 2, 1500);
INSERT INTO sales VALUES(2007, 7, 500);
INSERT INTO sales VALUES(2007, 11, 1500);
INSERT INTO sales VALUES(2007, 12, 2000);
INSERT INTO sales VALUES(2008, 1, 1000);
INSERT INTO sales VALUES(2009, 5, 2500);