Skip to content

Instantly share code, notes, and snippets.

View guilhermebkel's full-sized avatar
👨‍🏫
programming and mentoring

Guilherme Mota guilhermebkel

👨‍🏫
programming and mentoring
View GitHub Profile
@guilhermebkel
guilhermebkel / aws-multipart-upload-nodejs.ts
Last active January 8, 2020 10:07
aws-multipart-upload-nodejs
import * as AWS from "aws-sdk"
import { chunk } from "lodash"
import awsConfig from "config/aws"
const S3 = new AWS.S3(awsConfig.S3)
async function upload(params) {
const { Body, ACL, Bucket, Key, ContentType } = params
const createMultipartUpload = {
ACL,
@guilhermebkel
guilhermebkel / oauth2-boilerplate-nodejs.js
Last active November 1, 2019 09:22
oauth2-boilerplate-nodejs
const request = require('request')
const cors = require('cors')
const express = require('express')
const app = express()
app.use(cors())
app.get('/oauth/login', login)
app.get('/oauth/callback', callback)
app.listen(3333)
@guilhermebkel
guilhermebkel / axios-rate-limiter.js
Last active November 7, 2019 20:56
axios-rate-limiter
import axios from 'axios'
const CONCURRENT_UPLOADS = 6
// Time between verifications to know if there's
// a space on the queue to make a new request
const INTERVAL_MS = 10
let PENDING_UPLOADS = 0
@guilhermebkel
guilhermebkel / index.ts
Last active January 8, 2020 10:04
different-path-alias-for-typescript-dev-and-prod
// Usually the file you use to start your application
// ...
import "module-alias/register"
import "tsconfig-paths/register"
// ...
@guilhermebkel
guilhermebkel / postgres_dump.sh
Last active January 9, 2020 10:09
postgres-database-commands
echo "Command to make a dump of postgres database"
pg_dump -v -h DB_HOST -U DB_USER -d DB_NAME > DUMP_FILE.sql
@guilhermebkel
guilhermebkel / async-queue.js
Last active January 9, 2020 10:00
async-queue
/*
Service to make async process of any payload array, with concurrency support.
Author: Guilherme Mota Bromonschenkel Lima
Github: guilhermebkel
*/
// Milliseconds between checks to look for some available spot on the queue.
const REFRESH_TIME = 100;
@guilhermebkel
guilhermebkel / 📊 Weekly development breakdown
Last active March 14, 2021 00:00
Weekly Development Stats
TypeScript 25 hrs 24 mins ████████████████▋░░░░ 79.7%
JavaScript 2 hrs 45 mins █▊░░░░░░░░░░░░░░░░░░░ 8.7%
Docker 1 hr 28 mins ▉░░░░░░░░░░░░░░░░░░░░ 4.6%
Markdown 36 mins ▍░░░░░░░░░░░░░░░░░░░░ 1.9%
Other 36 mins ▍░░░░░░░░░░░░░░░░░░░░ 1.9%
@guilhermebkel
guilhermebkel / query.sql
Last active January 23, 2020 14:21
Updating single value inside json on postgres
/*
-> Supposing there's a table called 'sel_collections' and a column 'info' with the following format:
{ "total_pictures": 2, "total_size": 100 }
-> After making the command below, the value inside this column will be:
{ "total_pictures": 3, "total_size": 100 }
*/
UPDATE
sel_collections
@guilhermebkel
guilhermebkel / folders_size.sh
Created February 7, 2020 16:25
Show folders size recursively
du -hsc *
@guilhermebkel
guilhermebkel / clean_cache.sh
Created February 27, 2020 10:08
Clean cache command
free -h && sudo sysctl -w vm.drop_caches=3 && sudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches && free -h