Skip to content

Instantly share code, notes, and snippets.

View rafaeljesus's full-sized avatar

Rafael Jesus rafaeljesus

  • Berlin, Germany
View GitHub Profile
@rafaeljesus
rafaeljesus / async_get.go
Created November 11, 2016 23:13
Asynchronous http request in golang
type HttpResp struct {
Id string
Resp *http.Response
Err error
}
func AsyncGet(urls map[string]string) []*HttpResp {
ch := make(chan *HttpResp)
responses := []*HttpResp{}
@rafaeljesus
rafaeljesus / bb.js
Created December 4, 2015 13:28 — forked from stephantabor/bb.js
Bluebird .each vs .mapSeries vs .map
var Promise = require('bluebird');
var funcs = Promise.resolve([500, 100, 400, 200].map((n) => makeWait(n)));
funcs
.each(iterator) // logs: 500, 100, 400, 200
.then(console.log) // logs: [ [Function], [Function], [Function], [Function] ]
funcs
.mapSeries(iterator) // logs: 500, 100, 400, 200
@rafaeljesus
rafaeljesus / linkedin-unfollow-everyone.js
Created November 18, 2021 17:53 — forked from brunolemos/linkedin-unfollow-everyone.js
Unfollow everyone on Linkedin
(() => {
let count = 0;
function getAllButtons() {
return document.querySelectorAll('button.is-following') || [];
}
async function unfollowAll() {
const buttons = getAllButtons();
@rafaeljesus
rafaeljesus / system_design_numbers_cheat_sheet.md
Created August 8, 2021 15:59 — forked from mwakaba2/system_design_numbers_cheat_sheet.md
Updated easy to remember system design numbers for back-of-the-envelope calculations

Updated, easy to remember numbers for back-of-the-envelope calculations in system design interviews

Powers of two table

Power    Approx Value (Bytes)       Bytes
-----------------------------------------
10                 1 thousand        1 KB
16                16 thousand       64 KB
20                  1 million        1 MB
30 1 billion 1 GB
@rafaeljesus
rafaeljesus / grpc-load-balancing.md
Created March 16, 2021 10:54 — forked from rponte/grpc-load-balancing.md
gRPC Load Balancing may not be that easy

Why gRPC load balancing is so tricky?

At a high-level, we need to understand two points:

  • gRPC is built on HTTP/2, and HTTP/2 is designed to have a single long-lived TCP connection (a sticky and persistent connection);
  • To do gRPC load balancing, we need to shift from connection balancing to request balancing;

Some interesting articles about this subject

@rafaeljesus
rafaeljesus / NearbyWords.java
Created February 22, 2021 20:00 — forked from alexrios/NearbyWords.java
Facebook's How to Crush Your Coding Interview. Problem: Write a function that given a string, returns all nearby words. You are given the following helper functions: Set<String> getNearbyChars(char c); isWord(String word);
package facebook;
import java.util.HashSet;
import java.util.Set;
/**
* The complexity of that algorithm is O(n^m), where:
* n - the length of a string.
* m - number of permutations.
*/
package main
import (
"bufio"
"flag"
"fmt"
"io"
"os"
"path/filepath"
"regexp"

Quick cheat sheet of helpful tmux commands

  1. tmux new - Create and attach to a new session.
  2. tmux new -s NAME_HERE - Create and attach to a new session named NAME_HERE.
  3. CTRL-b, d - Detach (i.e. exit) from the currently-opened tmux session (alternatively, tmux detach). Note, this means press and hold CTRL, press b, release both, press d.
  4. tmux ls - Show list of tmux sessions.
  5. tmux a - Attach to the previously-opened tmux session.
  6. tmux a -t NAME_HERE - Attach to the tmux session named NAME_HERE.
  7. CTRL-d - Delete (i.e. kill) currently-opened tmux session (alternatively tmux kill-session).
  8. CTRL-b, [ - Enter copy mode, and enable scrolling in currently-opened tmux session. Press q to exit.
  9. CTRL-b, " - Split window horizontally (i.e. split and add a pane below).
@rafaeljesus
rafaeljesus / k8s-cluster-module.tf
Last active December 1, 2020 07:03
k8s cluster creation terraform
module "vpc" {
source = "git::git@github.com:rafaeljesus/vpc?ref=master"
vpc_id = var.vpc_id
vpc_cidr_block = var.vpc_cidr_block
azs = slice(data.aws_availability_zones.available.names, 0, 3)
public_subnets = var.vpc_public_subnets
private_subnets = var.vpc_private_subnets
igw_id = var.vpc_igw_id
@rafaeljesus
rafaeljesus / monzo-alertmanager-receiver.yaml
Created March 7, 2019 23:18 — forked from milesbxf/monzo-alertmanager-config.yaml
Monzo's Alertmanager Slack templates
receivers:
###################################################
## Slack Receivers
- name: slack-code-owners
slack_configs:
- channel: '#{{- template "slack.monzo.code_owner_channel" . -}}'
send_resolved: true
title: '{{ template "slack.monzo.title" . }}'
icon_emoji: '{{ template "slack.monzo.icon_emoji" . }}'
color: '{{ template "slack.monzo.color" . }}'