Skip to content

Instantly share code, notes, and snippets.

View erichnascimento's full-sized avatar
🚧
Building the next big thing

Erich Nascimento erichnascimento

🚧
Building the next big thing
View GitHub Profile
@erichnascimento
erichnascimento / bind-port.sh
Created August 19, 2016 17:10
Bind Vagrant port to host port
# List the Vagrant config to get ip address and key path
$ vagrant ssh-config
# Bind port
$ sudo ssh -L 0.0.0.0:80:<vagran-ip>:80 -i <path-to-listed-private-key> -p 2222 -N vagrant@localhost
@erichnascimento
erichnascimento / db.1.rake
Created November 19, 2017 21:34 — forked from maxd/db.1.rake
Rake task for drop active connections to PostgreSQL database
namespace :db do
namespace :drop do
task connections: :environment do
begin
database = ActiveRecord::Base.connection.current_database
ActiveRecord::Base.connection.execute(<<-SQL)
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = '#{database}' AND pid <> pg_backend_pid();
SQL
#!/usr/bin/env bash
# Install Nodejs
curl https://nodejs.org/dist/v8.12.0/node-v8.12.0-linux-x64.tar.xz -O \
&& tar xf node-v8.12.0-linux-x64.tar.xz \
&& cp -R node-v8.12.0-linux-x64/* /usr/local \
&& rm -rf node-v8.12.0-linux-x64 \
&& rm -f node-v8.12.0-linux-x64.tar.xz
@erichnascimento
erichnascimento / bind-dot-to-comma-mac-keyboard.sh
Created February 2, 2023 17:41
Bind Apple Numeric Keyboard dot key to comma due to BRL currency on MacOS Ventura
mkdir -p $HOME/Library/KeyBindings
nano $HOME/Library/KeyBindings/DefaultKeyBinding.dict
# Put the following content into them
#
# {
# "#." = ("insertText:", ",");
# }
#
INSERT INTO public.banks (id, name, ispb_code, compensation_code, created_at, updated_at) VALUES ('113cd26a-e451-4a86-8fef-e30d353860f3', 'BCO DO BRASIL S.A.', '0', '1', '2023-08-25 12:04:04.798226', null);
INSERT INTO public.banks (id, name, ispb_code, compensation_code, created_at, updated_at) VALUES ('2abd0e9c-8a84-406c-8e85-60b9c27ff52d', 'BRB - BCO DE BRASILIA S.A.', '208', '70', '2023-08-25 12:04:04.798226', null);
INSERT INTO public.banks (id, name, ispb_code, compensation_code, created_at, updated_at) VALUES ('a67e2928-9a99-4688-b66f-e27a61a0af84', 'SANTINVEST S.A. - CFI', '122327', '539', '2023-08-25 12:04:04.798226', null);
INSERT INTO public.banks (id, name, ispb_code, compensation_code, created_at, updated_at) VALUES ('a7c6613f-08b6-4303-8a6a-68f949f8d290', 'CCR SEARA', '204963', '430', '2023-08-25 12:04:04.798226', null);
INSERT INTO public.banks (id, name, ispb_code, compensation_code, created_at, updated_at) VALUES ('b7100d66-f3b5-4968-83b3-967f3c0da6fa', 'AGK CC S.A.', '250699', '272', '2023-0
@erichnascimento
erichnascimento / client.py
Last active March 18, 2025 23:02
Este servidor responde a pings do cliente para medir latência e testar a confiabilidade da conexão.
import asyncio
import websockets
import time
SERVER_IP = "192.168.X.X" # IP da máquina que está rodando o servidor
PORT = 8765 # Porta do servidor WebSocket
URL = f"ws://{SERVER_IP}:{PORT}"
async def monitor_websocket():
while True: