Skip to content

Instantly share code, notes, and snippets.

View leonardorifeli's full-sized avatar
🔥
Working from home. Memento mori.

Leonardo Rifeli leonardorifeli

🔥
Working from home. Memento mori.
View GitHub Profile
@leonardorifeli
leonardorifeli / postgresql-on-aws-tips.md
Created November 18, 2020 21:58 — forked from juliandunn/postgresql-on-aws-tips.md
Notes on PostgreSQL performance optimization on RDS

Deep Dive: PostgreSQL on AWS

When loading data

  • disable backups (backup_retention=0)
  • disable multi-AZ and autovacuum
  • pg_dump -Fc (compressed) and pg_restore -j (parallel)
  • Increase maintenance_work_mem
@leonardorifeli
leonardorifeli / postgresql-on-aws-tips.md
Created November 18, 2020 21:58 — forked from juliandunn/postgresql-on-aws-tips.md
Notes on PostgreSQL performance optimization on RDS

Deep Dive: PostgreSQL on AWS

When loading data

  • disable backups (backup_retention=0)
  • disable multi-AZ and autovacuum
  • pg_dump -Fc (compressed) and pg_restore -j (parallel)
  • Increase maintenance_work_mem
@leonardorifeli
leonardorifeli / joker.js
Created October 19, 2020 04:15
Puppeteer
const puppeteer = require('puppeteer');
class Jokes {
static async getBestData() {
const browser = await this.getBrowser();
const page = (await browser.pages())[0];
await this._definePageConfig(page);
@leonardorifeli
leonardorifeli / CSVParser.js
Last active October 19, 2020 03:13
CSV Parser
const CSV_URL = "https://gist.githubusercontent.com/leonardorifeli/9051a515e14c061247d483906383152e/raw/78f3b0702ade0348aa776d2727eddbe815df8348/spotify-music-classification";
const request = require('request-promise-native').defaults({
resolveWithFullResponse: true
});
const csv = require('csvtojson');
class CSVParser {
static async parseCSV(url) {
@leonardorifeli
leonardorifeli / DateParser.ts
Last active October 19, 2020 02:55
Date Parser with typescript
class DateParser {
date: Date;
constructor(date: string) {
try {
this.date = new Date(this.format(date));
} catch (e) {
throw e;
}
@leonardorifeli
leonardorifeli / golang_kinesis.go
Created June 14, 2018 00:59 — forked from coboshm/golang_kinesis.go
Golang + Kinesis firehose
package main
import (
"log"
"encoding/json"
"fmt"
"os"
"math/rand"
// the wizare functions
var sendString = (function(rfb, force, sendDelay) {
sendDelay = sendDelay || 25;
var _q = [];
var _qStart = function() {
var chr = _q.shift();
if (chr) {
rfb.sendKey(chr);
setTimeout(_qStart, sendDelay);
}
@leonardorifeli
leonardorifeli / AWS_S3_File_Upload.js
Created January 4, 2018 13:47 — forked from homam/AWS_S3_File_Upload.js
How to upload files to AWS S3 with NodeJS SDK
var AWS = require('aws-sdk'),
fs = require('fs');
// For dev purposes only
AWS.config.update({ accessKeyId: '...', secretAccessKey: '...' });
// Read in the file, convert it to base64, store to S3
fs.readFile('del.txt', function (err, data) {
if (err) { throw err; }
@leonardorifeli
leonardorifeli / restart_bluetooth.sh
Created September 4, 2017 20:11 — forked from nicolasembleton/restart_bluetooth.sh
Restart Bluetooth Daemon on Mac OS X without restarting
#!/bin/bash
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
@leonardorifeli
leonardorifeli / asyncAwait.js
Last active July 11, 2017 15:08
Apresentação Node.js
async function sendAsync(userId) {
let user = await getUser(userId);
let profile = await getProfile(user);
let account = await getAccount(profile);
let report = await getReport(account);
let send = sendStatistic(report);
console.log(send);
}