Skip to content

Instantly share code, notes, and snippets.

View garciparedes's full-sized avatar
🤖
Coding!

Sergio García Prado garciparedes

🤖
Coding!
View GitHub Profile
@garciparedes
garciparedes / slides-downloader.js
Created June 27, 2022 09:42
Download all named `canvas` elements as png images.
const elements = document
.getElementsByTagName("canvas");
for (let element of elements) {
if (!element.id) {
continue;
}
const image = element
.toDataURL("image/png")
  • Add the following packages to pyproject.toml:

    • minos-microservice-transactions
  • Update the config.yml file as follows:

    • Replace minos.aggregate.DatabaseTransactionRepository by minos.transactions.DatabaseTransactionRepository.
    • Replace minos.aggregate.DatabaseEventRepository by minos.aggregate.DatabaseDeltaRepository.
    • Remove minos.aggregate.TransactionServiceminos.aggregate.TransactionService from the services section.
    • Add the following fields to the aggregate section as follows (replacing MyAggregate with the corresponding class name):
  • Add the following packages to pyproject.toml:
    • minos-database-aiopg
    • minos-database-lmdb
  • Add the following changes to config.yml:
    • Add client to database-releated sections:
      • In default, repository, snapshot, broker, etc. add: client: minos.plugins.aiopg.AiopgDatabaseClient
      • In saga or saga.storage add: client: minos.plugins.lmdb.LmdbDatabaseClient
    • Replace the following classes:
@garciparedes
garciparedes / docker-compose.yml
Created February 9, 2022 14:30
A template for a Minos Project launched on top of Docker Compose
version: '3.9'
x-microservice-environment: &microservice-environment
- MINOS_BROKER_QUEUE_HOST=postgres
- MINOS_BROKER_HOST=kafka
- MINOS_REPOSITORY_HOST=postgres
- MINOS_SNAPSHOT_HOST=postgres
- MINOS_DISCOVERY_HOST=discovery
x-microservice-depends-on: &microservice-depends-on
- postgres
- kafka
@garciparedes
garciparedes / remove_databases.sh
Created October 21, 2021 14:49
Remove Users and Databases created for testing
#!/bin/bash
PREFIX='test_db'
export PGPASSWORD=postgres
export PGUSER=postgres
export PGHOST=localhost
export PGPORT=5432
TEST_DB_LIST=$(psql -l | awk '{ print $1 }' | grep '^[a-z]' | grep -v template | grep -v postgres)
for TEST_DB in $TEST_DB_LIST ; do
@garciparedes
garciparedes / remove_roles.sql
Last active June 2, 2021 10:41
Remove roles with name pattern
# If out of memory is raised: https://stackoverflow.com/a/43530569/3921457
do $$
declare tablename text;
declare rolename text;
begin
for tablename in select datname FROM pg_database where datname like 'test_%'
loop
execute 'DROP DATABASE ' || tablename;
end loop;

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

#!/bin/bash
for x in *.zip ; do unzip -d . -o -u $x ; done
@garciparedes
garciparedes / ultrawide-script
Last active November 13, 2019 10:10
Screen resolution setup for ultra wide screen
#!/bin/bash
# Screen resolution setup for ultra wide screen
# URL: https://gist.github.com/garciparedes/f3b6d38ef7125a7b3c04d5e5ea970de4
sudo cvt 2560 1080 60
xrandr --newmode "2560x1080_60.00" 230.00 2560 2720 2992 3424 1080 1083 1093 1120 -hsync +vsync
sudo xrandr --addmode HDMI-1-2 2560x1080_60.00
sudo xrandr --output HDMI-1-2 --mode 2560x1080_60.00
@garciparedes
garciparedes / gcd_and_lcm.py
Created May 4, 2019 10:09 — forked from endolith/gcd_and_lcm.py
GCD and LCM functions in Python for several numbers
# Greatest common divisor of 1 or more numbers.
from functools import reduce
def gcd(*numbers):
"""
Return the greatest common divisor of 1 or more integers
Examples
--------