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%'
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 / gist:c5ee574a5b5b2944b66d
Created January 2, 2016 13:47
output from django-admin2 tests with django 1.8
py27-dj1.8.x installed: Django==1.8.7,django-braces==1.8.1,django-crispy-forms==1.5.2,django-debug-toolbar==1.4,django-extra-views==0.7.1,django-filter==0.11.0,django-floppyforms==1.2.0,djangorestframework==2.4.4,py==1.4.31,pytest==2.8.5,pytest-django==2.9.1,pytz==2014.7,six==1.10.0,sqlparse==0.1.18,wheel==0.24.0
py27-dj1.8.x runtests: PYTHONHASHSEED='1485872978'
py27-dj1.8.x runtests: commands[0] | py.test
============================= test session starts ==============================
platform darwin -- Python 2.7.10, pytest-2.8.5, py-1.4.31, pluggy-0.3.1
django settings: example.settings (from environment variable)
rootdir: /Users/andrews/projects/opensource/django-admin2, inifile:
plugins: django-2.9.1
collected 212 items
@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...

#!/usr/bin/env python
import argparse
import json
import os
import urllib2
def get_envs(app_name):
resp = request("/apps/{}/env".format(app_name))