Skip to content

Instantly share code, notes, and snippets.

View ferrao's full-sized avatar
🎯
Focusing

Rui Ferrão ferrao

🎯
Focusing
View GitHub Profile
@ferrao
ferrao / gpg
Created March 29, 2024 22:16
GPG
# Encrypt files, not caching password
gpg -c --no-symkey-cache file.txt
# decrypt files, not caching password
gpg --no-symkey-cache file.txt.gpg
### Keybase proof
I hereby claim:
* I am ferrao on github.
* I am ruiferrao (https://keybase.io/ruiferrao) on keybase.
* I have a public key whose fingerprint is 6AB8 59DC 20D4 1D18 FCF8 C6DE 42E7 636B CF77 1773
To claim this, I am signing this object:
@ferrao
ferrao / README.md
Created March 10, 2022 22:59 — 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:
@ferrao
ferrao / git-gist.md
Last active May 24, 2021 15:11
Git most used

Update fork from upstream

git fetch upstream master
git merge upstream/master

Deploy from branch

Overwrite local staging branch (tracking upstream) with master(upstream fork) :

@ferrao
ferrao / aws-iam.md
Last active March 19, 2020 21:14
AWS cli IAM examples

AWS IAM

aws iam create-user --profile <aws-cli-profile> --user-name <username> 
aws iam create-login-profile --profile <aws-cli-profile> --user-name <username> --password '<password>'
aws iam delete-login-profile --profile >aws-cli-profile> --user <username>
@ferrao
ferrao / aws-rds.md
Last active November 6, 2019 13:44
AWS RDS

AWS RDS - Postgres 11

Recreate Database

\c postgres
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'postgres'
  AND pid <> pg_backend_pid();
\c template1;
@ferrao
ferrao / aws-key-verifiy.sh
Last active July 19, 2019 09:03
AWS Key Pair verification
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#verify-key-pair-fingerprints
openssl rsa -in ~/.ssh/privatekey -pubout -outform DER | openssl md5 -c
openssl pkcs8 -in path_to_private_key -inform PEM -outform DER -topk8 -nocrypt | openssl sha1 -c
@ferrao
ferrao / asciidoctor-pdf-theme.yaml
Created January 19, 2019 22:07
Asciidoctor pdf theme to use as base for corporate theme
title_page:
logo_image: image:logo.png[]
page:
layout: portrait
margin: [3.2cm, 2cm, 2.2cm, 2cm]
size: A4
base:
font_color: #333333
font_family: Helvetica
font_size: 12
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten