Skip to content

Instantly share code, notes, and snippets.

View luisfmelo's full-sized avatar
🇵🇹

Luís Melo luisfmelo

🇵🇹
View GitHub Profile
kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')
# 1. Download SonarQube
# 2. Unzip SonarQube
# 3. Create alias in zshrc
alias sonarqube="~/Downloads/SonarQube/bin/macosx-universal-64/sonar.sh"
# Reload zshrc
source ~/.zshrc
# 1. Download SonarScanner
# 2. Unzip SonarScanner
# 3. Create alias in zshrc
@luisfmelo
luisfmelo / request_with_cookies.py
Last active April 2, 2020 15:41
Request in Python #python #snipets
import requests
cookies = {
'__CommerceAnonymousShopper_ef77e72d-62b9-4b0f-8113-d111c9d6d7ce_Internet': '0244BMnIHNMxBiU18bxI2LVwQ==gfaaPVByamPky3ScceGAIJH4HIewfUwvAuXMb1ZyeyR5RDwQ+UyuySlW+fvQz99i9FnfwWipjCCcJfczFtw81vOhM1CINV1OBUTBpz40guVmXm3FansO9ZhN5sPUkQASDK510rizcwI767NmhsSlS1+PCZkvgMN10lGJct1ZHXRiRSl0eedSPuaRDyzZkaPyySJ5pioZrN31tGqcCv83Ag==',
'ASP.NET_SessionId': 'vsbmxeje5ujbb133p4ipgq45',
'AnonymousBasket': 'AAEAAAD/////AQAAAAAAAAAGAQAAACQwMmIwYTgzNC01NzkyLTRkNGMtODQxNS04ZDQ2OTA1NDYyMGUL',
'cPrompt_useCookies': '1',
'f5avrbbbbbbbbbbbbbbbb': 'CBHBCBOOHJEGEOOKIMFKMJLGENPKADJMIFPKDOIJILOOJPLOMDHNPODPAOJOPKHLNAADENJLAFHFLGDKCOGABJBFCAICNKMEFFPIDHBLCPKMPFINNMOMLCMLBFKAACHG',
'FedAuth': '77u/PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48U1A+MDUudHxhZGZzIHN0cyBzb25hZXxsdWlzbWVsbzdAZ21haWwuY29tLDA1LnR8YWRmcyBzdHMgc29uYWV8bHVpc21lbG83QGdtYWlsLmNvbSwxMzIzMDMxODczNTcyMTAwMDAsVHJ1ZSxDSkNrckdUMXhDNVZWUGhXWk9tYmZ1L2pkbk5QUlJ5LzRJMVg5RTI5TFRIcThOSFhqK3NTYmRRc0RTS3M4elRPMUVwcVA0Rk5BSlA3
@luisfmelo
luisfmelo / httpClient.go
Created August 28, 2019 14:07
An HTTP client wrapper done by hriddhidey
// Fetch makes network calls using the method (POST/GET..), the URL // to hit, headers to add (if any), and the body of the request.
// Feel free to add more stuff to before/after making the actual n/w call!
func Fetch(method string, url string, header map[string]string, body io.Reader) (*http.Response, err) {
// Create client with required custom parameters.
// Options: Disable keep-alives, 30sec n/w call timeout.
client := &http.Client{
Transport: &http.Transport{
DisableKeepAlives: true,
},
Timeout: time.Duration(10 * time.Second),
@luisfmelo
luisfmelo / ssh_config.sh
Last active July 18, 2019 08:30
SSH config file example
# SSH access: ssh namespace-for-access-1
# Equivalent to ssh ubuntu@50.20.10.200 -i ~/.ssh/huub/api_core_key
Host namespace-for-access-1
HostName 50.20.10.200
User ubuntu
Identityfile ~/.ssh/organization/ssh_key
# Tunel access. We can access localhost:8501 of the server (10.200.60.10) on our port 8500
# We can also put another ip insted of localhost:8501. Ex. some other EC2/RDS in an AWS VPC
@luisfmelo
luisfmelo / postgres-blocked-update.sql
Created July 17, 2019 10:12
Postgres - Blocked update
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
UPDATE table_name
SET column = 'value'
WHERE id IN (
SELECT id
FROM table_name
WHERE is_to_update is TRUE
ORDER BY id LIMIT 1
FOR UPDATE SKIP LOCKED
@luisfmelo
luisfmelo / System Design.md
Created July 5, 2019 14:47 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@luisfmelo
luisfmelo / postgres_queries_and_commands.sql
Created January 18, 2019 18:14 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
CREATE OR REPLACE FUNCTION calculate_business_days(start_date timestamp, end_date timestamp) RETURNS integer
AS
'
select sum(case when extract(dow from dt) in (1, 2, 3, 4, 5) then 1 else 0 end)::integer - 1 as thediff
from (
select start_date,
end_date,
generate_series(start_date, end_date, ''1 day''::interval) as dt
) t
---
--- Credits: mateuszwenus
---
-- 1. Create Table to manage dependencies
create table deps_saved_ddl
(
deps_id serial primary key,
deps_view_schema varchar(255),
deps_view_name varchar(255),