Skip to content

Instantly share code, notes, and snippets.

View calexandrepcjr's full-sized avatar
🎯
Focusing

Carlos Alexandre calexandrepcjr

🎯
Focusing
View GitHub Profile
/*
Java Age counting
In the Java file, write a program to perform a GET request on the route:
https://coderbyte.com/api/challenges/json/age-counting
Which contains a data key and the value is a string which contains items in the format:
key=STRING, age=INTEGER
@calexandrepcjr
calexandrepcjr / send_slack_message_from_cloudwatch_logs.js
Last active August 16, 2022 18:59
Sends Slack Message by receiving a cloudwatch log identified by a tag
/**
* EXAMPLE: [ONBOARDING]Someone has just signed up!
**/
const https = require('https');
const zlib = require('zlib');
exports.handler = (event, context, callback) => {
const options = {
hostname: "hooks.slack.com",
@calexandrepcjr
calexandrepcjr / latency.txt
Created June 10, 2022 19:36 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@calexandrepcjr
calexandrepcjr / perf_stats.js
Created February 10, 2022 18:49
Perf calculation between two environments (beta/stable) using Postman exported data
/**
* Perf calculation between two environments (beta/stable) using Postman exported data
* JSON schema:
* {
* "environmentName": [
* exportedResultObject
* ]
* }
*
* E.g
@calexandrepcjr
calexandrepcjr / export_notion_page.py
Created September 3, 2021 13:07
Exports notion pages to markdown
from narkdown.exporter import NotionExporter
if __name__ == "__main__":
token_v2 = "you can take this token opening the browser's page inspector, going to page storage and take token_v2 from the notion cookies"
page_url = "https://www.notion.so/company_name/link"
notion_exporter = NotionExporter(token_v2)
notion_exporter.get_notion_page(page_url)
@calexandrepcjr
calexandrepcjr / elasticsearch_slowlog_for_all_indices.md
Created August 4, 2021 18:03 — forked from renshuki/elasticsearch_slowlog_for_all_indices.md
How to enable slowlogs for all indices and tweak slowlog logger level

Slowlog thresholds for all indices

Add slowlog thresholds for all indices

PUT /_all/_settings 
{
"index.search.slowlog.threshold.query.warn": "10s",
"index.search.slowlog.threshold.query.info": "5s",
"index.search.slowlog.threshold.query.debug": "2s",
@calexandrepcjr
calexandrepcjr / only_weekends_psql.sql
Created April 1, 2021 20:41
Extract only rows from weekends
SELECT
*
FROM table
WHERE EXTRACT(ISODOW FROM created_at) IN (6, 7);
@calexandrepcjr
calexandrepcjr / delete_folder.js
Last active March 16, 2021 02:57
Deletes a folder, considerable retrocompatibility + OS usage
#!/usr/bin/node
const folderPath = "dist",
nodeMajorVersion = process.version.match(/\d+/g)[0],
hasMajorVersionGreatherThanOrEqual = (aVersion) =>
nodeMajorVersion >= aVersion,
successMessage = () => console.log("Dist fold deleted!"),
removeFolder = (path) => {
const fs = require("fs");
@calexandrepcjr
calexandrepcjr / sheets.py
Created October 22, 2020 20:52
Sheets module improves the productivity when dealing with spreadsheets
"""
Sheets module improves the productivity when dealing with spreadsheets
"""
def detect_complex_types(_row):
return [index for (index, row) in enumerate(_row) if type(_row) is dict]
def map_complex_types_into_string(_values):
"""
GAPI Sheets module improves the Gapi sheets usage
Turn on the credentials in your account:
https://developers.google.com/sheets/api/quickstart/python
Put the redirect uri as http://localhost:9999/
"""