Skip to content

Instantly share code, notes, and snippets.

View andrefreitas's full-sized avatar

André Freitas andrefreitas

View GitHub Profile
@andrefreitas
andrefreitas / main.md
Created September 25, 2019 15:10
Postgres Admin Quickies

Find if a query is blocked by another

select pid,
       usename,
       pg_blocking_pids(pid) as blocked_by,
       query as blocked_query
from pg_stat_activity
where cardinality(pg_blocking_pids(pid)) > 0;
@andrefreitas
andrefreitas / notes.c
Created November 29, 2018 00:07
notes.c
#include <stdio.h>
float computeAverage(int *notes, int length) {
float sum = 0;
for(int i = 0; i < length; i++) {
sum += notes[i];
}
return sum / length;
@andrefreitas
andrefreitas / genstage_example.exs
Created November 22, 2018 09:36
Example of using Genstage
defmodule EventsProducer do
use GenStage
def init(min) do
{:producer, min}
end
def handle_demand(demand, min) when demand > 0 do
events = Enum.to_list(1..min+demand)
{"timestamp":null, "logger_event_id":"8g272igf2378f3287f2387623f623","event_type":"telephone_created","event":{"type":"local","telephone_id":"5e8d60283cc24683a9524906","number":"+165891030224","logger_timestamp":"2018-09-21T16:40:52.267213Z","logger_event_id":"GZS759FwcPXmLa8httsPu+XweuRgeCCJ0zCEVNlOChM=","event_id":"GZS759FwcPXmLa8httsPu+XweuRgeCCJ0zCEVNlOChM=","event":"telephone_created","country":"US","account_id":"5e8d60283cc24683a952a1fb"},"agent_id":null,"account_id":"5e8d60283cc24683a952a1fb"}
{"timestamp":null,"logger_event_id":null,"event_type":"telephone_created","event":{"type":"local","telephone_id":"5e8d60283cc24683a9524906","number":"+165891030224","logger_timestamp":"2018-09-21T16:40:52.782497Z","logger_event_id":"xg7ZHjf+r0lH3bLJ4JGhUYX1W84NU/HZHWR3hN68Ubs=","event_id":"xg7ZHjf+r0lH3bLJ4JGhUYX1W84NU/HZHWR3hN68Ubs=","event":"telephone_created","country":"US","account_id":"5e8d60283cc24683a952a1fb"},"agent_id":null,"account_id":"5e8d60283cc24683a952a1fb"}
@andrefreitas
andrefreitas / keybase.md
Created July 26, 2016 19:10
keybase.md

Keybase proof

I hereby claim:

  • I am andrefreitas on github.
  • I am andrefreitas (https://keybase.io/andrefreitas) on keybase.
  • I have a public key ASCNA3WqPj9-mrU8gYxaUg-OmgeaF9sl8rJdvLPSIf3QXwo

To claim this, I am signing this object:

@andrefreitas
andrefreitas / 0_reuse_code.js
Created February 18, 2016 12:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
py.test
======================================================================= test session starts =======================================================================
platform linux2 -- Python 2.7.9, pytest-2.8.2, py-1.4.30, pluggy-0.3.1
rootdir: /code, inifile: setup.cfg
plugins: cov-2.2.0
collected 76 items
bugimporters/tests/test_bugzilla.py .............
bugimporters/tests/test_github.py ....
bugimporters/tests/test_google.py ..F.F.F.F..........
@andrefreitas
andrefreitas / docker-compose.yml
Last active October 8, 2016 02:41
sentry docker-compose
redis:
image: redis
postgres:
image: postgres
environment:
- POSTGRES_PASSWORD=sentry
- POSTGRES_USER=sentry
volumes:
- /var/lib/postgresql/data
cmake_minimum_required(VERSION 3.1)
project(hello)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set(SOURCE_FILES
hello.h
hello.cpp
main.cpp
)
import pdb; pdb.set_trace()