Skip to content

Instantly share code, notes, and snippets.

View portothree's full-sized avatar
♟️

Gus Porto portothree

♟️
View GitHub Profile
@portothree
portothree / arion-compose.nix
Created December 27, 2021 12:23
MongoDB and NodeJS arion-compose.nix file
{ pkgs, ... }: {
config.services = {
mongodb = {
service = {
image = "mongo:latest";
container_name = "pgil-mongodb";
ports = [ "27030:27017" ];
volumes = [ "${toString ./.}/tmp/mongodb-data:/data/db" ];
stop_signal = "SIGINT";
};
@portothree
portothree / gist:3de08c3cb24683879f6bc172493cb16d
Created November 3, 2021 16:39
Ubuntu Proxmox VM network

Ubuntu 16.04

ip add

vi /etc/network/interfaces

auto ens18
iface ens18 inet static
address 128.204.192.xxx
@portothree
portothree / promise-timeout.js
Last active June 23, 2022 12:09
Timeout an Promise
function timeoutPromise(prom, time) {
let timer;
return Promise.race([
prom,
new Promise(
(_r, rej) =>
(timer = setTimeout(rej, time, new Error("Promise timed out")))
),
]).finally(() => clearTimeout(timer));
@portothree
portothree / user-story-xp.txt
Created September 28, 2021 17:53
Extreme programming user story
The front says:
<Story Title>
As an X
I want Y
So that Z
The back is split in two columns, labelled:
const Benchmark = require('benchmark');
const suite = new Benchmark.Suite();
const APPOINTMENT_WAITING_LIST_TABLE = 'appointment_waiting_list';
const INTERCEPTION_LIST_TABLE = 'interception_list';
async function seed_data() {
await knex.raw(`
INSERT INTO test.appointment_waiting_list (account_id,status,registered_at,rejection_reason,appointment_id,created_at,updated_at) VALUES
@portothree
portothree / constraints.sql
Created September 14, 2021 14:34
Retrieve Postgres constraints with `pg_catalog.pg_constraint`
SELECT con.*
FROM pg_catalog.pg_constraint con
INNER JOIN pg_catalog.pg_class rel
ON rel.oid = con.conrelid
INNER JOIN pg_catalog.pg_namespace nsp
ON nsp.oid = connamespace
WHERE rel.relname = 'table_name';
@portothree
portothree / main.py
Last active September 6, 2021 18:15
Sqlalchemy's session injection with dependency-injector lib
import contextlib
import logging
import dependency_injector.containers as containers
import dependency_injector.providers as providers
import sqlalchemy
from sqlalchemy import orm, MetaData, Column, Integer, String, Table
logger = logging.getLogger(__name__)
@portothree
portothree / tearing.sh
Last active August 30, 2021 09:02
Fix AMD GPU Radeon Screen Tearing in Debian, Linux Mint and Ubuntu
lspci -nnk | grep -i -EA3 "3d|display|vga"
ls -l /etc/X11
mkdir ~/xorg-backup
sudo mv -v /etc/X11/xorg.conf ~/xorg-backup/
sudo mv -v /etc/X11/xorg.conf.d ~/xorg-backup/
sudo vim /etc/X11/xorg.conf
@portothree
portothree / github-invites.md
Created July 7, 2021 14:09
All github invitations to be collaborator

Currently there's no UI to check for all invitations to collaborate in projects, but Github API has an endpoint for that.

You need a personal access token with repo:invite rights in order to view the list of your invitations.

curl -H "Authorization: token YOUR_PERSONAL_ACCESS_TOKEN" \
https://api.github.com/user/repository_invitations
@portothree
portothree / l2tpclient.sh
Last active July 28, 2025 20:46 — forked from danielv99/l2tpclient.sh
L2TP VPN client on Linux Debian
# Requirements
# debian/ubuntu
apt-get -y update && apt-get -y upgrade
apt-get -y install strongswan xl2tpd libstrongswan-standard-plugins libstrongswan-extra-plugins
VPN_SERVER_IP=''
VPN_IPSEC_PSK='y'
VPN_USER=''
VPN_PASSWORD=''