Skip to content

Instantly share code, notes, and snippets.

View brunocasarotti's full-sized avatar

Bruno Casarotti brunocasarotti

  • São Paulo - Brazil
View GitHub Profile

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
const axios = require('axios');
const sqlite3 = require('sqlite3').verbose();
const fs = require('fs');
const { promisify } = require('util');
const { Worker, isMainThread, parentPort, workerData } = require('worker_threads');
const NUM_WORKERS = 3; // Using 3 worker threads, leaving 1 core free
const API_KEY = 'a48f0d74';
let logStream;
@brunocasarotti
brunocasarotti / openvpn.md
Last active October 29, 2024 13:37
Install OpenVPN3 on PopOS 22.04 and add it to package manager sources! No apt warnings!

Installing OpenVPN 3 on Debian-based Systems

To install OpenVPN 3 on a Debian-based system, follow these steps:

  1. Install the necessary dependencies:

    apt install apt-transport-https curl
  2. Switch to superuser mode:

@brunocasarotti
brunocasarotti / work-with-multiple-github-accounts.md
Created February 27, 2023 13:00 — forked from rahularity/work-with-multiple-github-accounts.md
How To Work With Multiple Github Accounts on your PC

How To Work With Multiple Github Accounts on a single Machine

Let suppose I have two github accounts, https://github.com/rahul-office and https://github.com/rahul-personal. Now i want to setup my mac to easily talk to both the github accounts.

NOTE: This logic can be extended to more than two accounts also. :)

The setup can be done in 5 easy steps:

Steps:

  • Step 1 : Create SSH keys for all accounts
  • Step 2 : Add SSH keys to SSH Agent
@brunocasarotti
brunocasarotti / sqs-monitor.sh
Created October 11, 2022 19:06
Monitor number of messages in SQS queues using AWS CLI bash script
#!/bin/bash
queues=(
"queue-1"
"queue-2"
)
for i in "${queues[@]}"
do
aws --profile MY-PROFILE sqs get-queue-attributes --queue-url https://sqs.us-east-1.amazonaws.com/00000000000000000/$i --attribute-names ApproximateNumberOfMessages \
| grep ApproximateNumberOfMessage \
@brunocasarotti
brunocasarotti / sqs_downloader.py
Last active October 11, 2022 19:01
Download all messages from sqs and save one per file in json format
import json
import os
import boto3
# Using AWS_PROFILE and AWS_REGION to authenticate
sqsResource = boto3.resource('sqs')
queue = sqsResource.get_queue_by_name(QueueName=os.getenv('QUEUE_NAME'))
output_dir = os.getenv('OUTPUT_DIR')
@brunocasarotti
brunocasarotti / git new repo with code.txt
Last active March 28, 2022 13:19
Git: new repo with existing files
git init
git remote add origin PATH/TO/REPO
git fetch
git reset origin/master # Required when the versioned files existed in path before "git init" of this repo.
git checkout -t origin/master
https://stackoverflow.com/questions/2411031/how-do-i-clone-into-a-non-empty-directory
@brunocasarotti
brunocasarotti / backup_databases.sql
Created October 11, 2018 19:19
This script allows you to backup all databases in a specific instance of sql server at once
DECLARE @name VARCHAR(50) -- database name
DECLARE @path VARCHAR(256) -- path for backup files
DECLARE @fileName VARCHAR(256) -- filename for backup
DECLARE @fileDate VARCHAR(20) -- used for file name
-- specify database backup directory
SET @path = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Backup\'
-- specify filename format
SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)