Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Juan Pedro Pérez Alcántara malkab

💭
I may be slow to respond.
View GitHub Profile
@malkab
malkab / information_management_cheatsheet.md
Last active Feb 28, 2021
Information Management Cheatsheet
View information_management_cheatsheet.md

Information Management Cheatsheet

Some stuff about organization, that terrible issue in my life.

Bookmarking

Use Firefox for bookmarking:

Shortcut Function
View psql_cheatsheet.md

psql Cheatsheet

Cheatsheet for psql, the command line client for PostgreSQL.

Launch

Do:

@malkab
malkab / git_working_with_branches.md
Last active Feb 17, 2021
Git - Working with branches
View git_working_with_branches.md

Comparing Branches

First, the term working tree refers to the current checked out branch, the working directory in it's present state.

It is recommended that comparison are made on commited, clean states, and not on uncommited changes. To compare with the current uncommited state of the working tree move the changes to staged. If not, new files won't show up at the SEARCH & COMPARE dialog, but this is tricky.

Use the VSC Git extension. To evaluate if a stalled branch is worth to be maintained, check out the develop, master, or main branch. If not very sure of the result, create a merge test branch.

Right click on the stalled branch and select Compare with Working Tree. The SEARCH & COMPARE section will read Compating XXX to Working Tree, being XXX the right clicked branch. The interpretation of the output is based on the changes to be done to XXX to reach the state of WT. Therefore:

View docker_recipes.md

Docker Recipes

Some Docker recipes.

GitLab and Docker Registry Tokens

GitLab provides access tokens at various access levels, like API or Read Registry ones. To use them:

@malkab
malkab / gpg_pgp_gnupg2.md
Created Feb 12, 2021
GPG, PGP, and GNUPG2
View gpg_pgp_gnupg2.md

GPG, PGP, and GNUPG2

Encryption and how to read and write it with GPG.

Installation of Keys

In most cases is just a matter of copying the ~/.gnupg folder. Check available keys with commands explained below.

Owner of folder .gnupg and its contents must be the user. Folder permissions must be 700, and permissions for file gpg.conf must be 600.

@malkab
malkab / postgresql-copy_from_copy_to.md
Created Feb 10, 2021
PostgreSQL - copy from / copy to
View postgresql-copy_from_copy_to.md

Copy To and Copy From

Copy is a command and a psql metacommand to import data into a PostgreSQL:

-- Tables
\copy test_data.test from sigwx.csv with delimiter '|' csv delimiter E'\t' header quote '"' encoding 'utf-8' null '-'

\copy test_data.test to sigwx.csv with delimiter '|' csv header quote '"' encoding 'utf-8' null '-'
View imagemagick_recipes.sh
# -----
#
# Some recipes for ImageMagick
#
# -----
# Cropping one pixel from the border, in place, batch version
mogrify -crop +1+1 -crop -1-1 ../src/images/*.png
@malkab
malkab / general_software_design_notes.md
Created Jan 12, 2021
General Software Design Notes
View general_software_design_notes.md

Some Miscellaneous Notes about Software Design

Dependencies in Objects

In the past, we tend to overstuff objects with fixed dependencies. Object A uses object B for a lot of things. Is the relation is 1:1, it may be ok to fix the instance of B as a member in A, but if not, if A can use in a given method ANY instance of B, then provide the B object directly to the method. This way the code is free to check for loaded dependencies into A before executing methods, it's up to the API user to ensure they are providing the right object to the method. This is specially useful when dealing with dependencies that comes from a DB, since they are async procedures and the code goes too complicated. Leave this complication to the client code.

@malkab
malkab / postgresql-cheatsheet_reminders.md
Last active Jan 11, 2021
PostgreSQL - Cheatsheet & Reminders
View postgresql-cheatsheet_reminders.md

PostgreSQL Cheatsheet & Reminders

Some hints and important stuff about PostgreSQL.

Reordering columns in existing tables with data: never do that, pointers to data seems to be lost. Redo the table if needed with create select and such.

Avoiding divisions by zero: the nullif function is an useful way to avoid them:

 round(((sum(e001518)::float) / (nullif(sum(e166418), 0))::float)::numeric, 2)
View tmux-cheatsheet.md

Tmux Cheatsheet

Commands

Command Action
PREFIX-a Send nested prefix