Skip to content

Instantly share code, notes, and snippets.

View vinnix's full-sized avatar
🥄

Vinícius Abrahão Bazana Schmidt vinnix

🥄
View GitHub Profile
@elisboa
elisboa / sortfiles-exif.sh
Last active August 22, 2022 16:59
A simple script to sort photo files based on their exif information
#!/usr/bin/env bash
# ---
#!/bin/bash -x
echo -e "### WELCOME TO $0\n"
if [[ -z ${DEST_DIR} ]]
then
TIMESTAMP=$(date +%s)
echo -e "Setting destination dir as ${TIMESTAMP}"
@saurabhnanda
saurabhnanda / tuning-postgres-zfs.md
Last active August 2, 2023 06:06
Tuning Postgres + ZFS

Tuning ZFS + Postgres to outperform EXT4 + Postgres

Please refer to ZFS 2-3x slower than EXT4 to see how ZFS defaults + Postgres defaults severely underperform EXT4 defaults + Postgres defaults (and also to know more about the system on which these benchmarks were performed). This page documents how to tune ZFS + Postgres to give better performance for the tpcb-like benchmark.

BIG FAT WARNING

Please do not copy these settings blindly because I am myself not clear on why/how these settings had the impact they did. For example, I cannot explain why full_page_writes=off independently did not give that much boost, nor did an optimized PG configuration. However, putting both of them together gave a 2-4x boost compared to baseline numbers.

Benchmark results

@phill-tornroth
phill-tornroth / cp-parameter-group.py
Created August 23, 2018 19:19
Copies an rds parameter group with support for cross-region copying. Quick bashed out script because AWS cli doesn't support.
"""
Copies a parameter group in RDS, particularly useful for doing cross-region copies (which AWS documents,
but doesn't actually support at the time of this writing.
Usage: python cp-parameter-group.py us-west-1:lookerdb-56 us-west-2:lookerdb-56
"""
import boto3
import sys
@vinnix
vinnix / valgrind_bitcoind.log
Last active December 26, 2017 02:48
Result of potential memleak using bitcoin-qt
$ ./bitcoin-qt --version
Bitcoin Core version v0.15.99.0-5180a86 (64-bit)
Copyright (C) 2009-2017 The Bitcoin Core developers
[vinnix@vnxsam bin]$ valgrind --leak-check=full --show-leak-kinds=all --leak-check=yes ./bitcoind
==2817== Memcheck, a memory error detector
==2817== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==2817== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==2817== Command: ./bitcoind
==2817==
@silveraid
silveraid / CentOS-Docker
Created October 27, 2017 12:09
Creating minimal CentOS docker image from scratch
# Create a folder for our new root structure
$ export centos_root='/centos_image/rootfs'
$ mkdir -p $centos_root
# initialize rpm database
$ rpm --root $centos_root --initdb
# download and install the centos-release package, it contains our repository sources
$ yum reinstall --downloadonly --downloaddir . centos-release
$ rpm --root $centos_root -ivh centos-release*.rpm
$ rpm --root $centos_root --import $centos_root/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
# install yum without docs and install only the english language files during the process
@anvk
anvk / psql_useful_stat_queries.sql
Last active July 12, 2024 11:28
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@vinnix
vinnix / json_manipulator.sql
Created September 10, 2016 17:20 — forked from matheusoliveira/json_manipulator.sql
Simple PostgreSQL functions to manipulate json objects. (Note: performance is not a concern for those functions)
CREATE OR REPLACE FUNCTION public.json_append(data json, insert_data json)
RETURNS json
IMMUTABLE
LANGUAGE sql
AS $$
SELECT ('{'||string_agg(to_json(key)||':'||value, ',')||'}')::json
FROM (
SELECT * FROM json_each(data)
UNION ALL
SELECT * FROM json_each(insert_data)
@wsdookadr
wsdookadr / json_manipulator.sql
Created May 31, 2016 10:57 — forked from matheusoliveira/json_manipulator.sql
Simple PostgreSQL functions to manipulate json objects. (Note: performance is not a concern for those functions)
CREATE OR REPLACE FUNCTION public.json_append(data json, insert_data json)
RETURNS json
IMMUTABLE
LANGUAGE sql
AS $$
SELECT ('{'||string_agg(to_json(key)||':'||value, ',')||'}')::json
FROM (
SELECT * FROM json_each(data)
UNION ALL
SELECT * FROM json_each(insert_data)
@RobinCPC
RobinCPC / gdb_in_vim.md
Last active December 12, 2023 20:08
How to use GDB in Vim

How to use ConqueGDB in Vim

Install ConqueGDB in Vim

Debug C/C++:

@Kartones
Kartones / postgres-cheatsheet.md
Last active July 16, 2024 10:46
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)