Skip to content

Instantly share code, notes, and snippets.

View andrewsmedina's full-sized avatar

Andrews Medina andrewsmedina

View GitHub Profile
@andrewsmedina
andrewsmedina / postgres_queries_and_commands.sql
Created September 27, 2021 18:18 — 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%'
# http://hadoop.apache.org/zookeeper/docs/current/zookeeperAdmin.html
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
from elasticsearch import Elasticsearch
query = {
"query": {
"bool": {
"should":
[
{
"term": {
"id-topico": ""
@andrewsmedina
andrewsmedina / tmux.md
Created November 22, 2018 14:13 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

Renião Tech Councel (16/10/2018)

Pauta

  • Nosso horário
  • Deliverable do OKR
  • Reunião tech leaders
  • Comunicação
  • Canal
@andrewsmedina
andrewsmedina / findLongRunningOp.js
Created May 16, 2018 01:52 — forked from kylemclaren/findLongRunningOp.js
Find and (safely) kill long running MongoDB ops
db.currentOp().inprog.forEach(
function(op) {
if(op.secs_running > 5) printjson(op);
}
)
  1. andrews (05/03/2018)
  2. gene (12/03/2018)
  3. marcinho (19/03/2018)
  4. hel (26/03/2018)
  5. gabiru (02/04/2018)
  6. murtinha (09/04/2018)
  7. nunes (16/04/018)
  8. solux (23/04/2018)
  9. leo (30/04/2018)
import asyncio
import signal
async def polling():
print('polling...')
await asyncio.sleep(3)
asyncio.ensure_future(polling())
loop = asyncio.get_event_loop()
loop.create_task(polling())
@andrewsmedina
andrewsmedina / README.md
Created December 21, 2015 19:42 — forked from rantav/README.md
Find slow queries in mongo DB

A few show tricks to find slow queries in mongodb

Enable profiling

First, you have to enable profiling

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...

#!/bin/bash
PREFIX=registry.cloud.tsuru.io/tsuru/
read command
for image in "$@"
do
echo "Generating $image... "
full_image=${PREFIX}${image}
id=`docker -H 127.0.0.1:4243 run -d $full_image $command`