Skip to content

Instantly share code, notes, and snippets.

@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 22, 2024 23:19
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%'
@pomack
pomack / http_echo_and_proxy_server.py
Created August 9, 2013 14:42
A simple python HTTP server that either serves as a proxy or as an echo server. If working as an echo server, it outputs the headers and body into log output and to the client, which is useful when debugging a reverse proxy or caching server to see what is being sent. If working as a proxy server, it outputs what the request headers will be to t…
#!/usr/bin/env python
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import StringIO
import argparse
import logging
import os
import random
import sys
import urllib2
@thiagooak
thiagooak / kill-rmq-connections.sh
Created December 13, 2013 12:11
kill ALL rabbitmq connections
rabbitmqctl list_connections pid port state user vhost recv_cnt send_cnt send_pend name | awk '{print "rabbitmqctl close_connection \"" $1 "\" \"manually closing idle connection\"" | "/bin/bash" }'
import os
import subprocess
import argparse
import requests
def changed_files(workdir, prevcommit, commit, cmd='git'):
p = subprocess.Popen([cmd, 'diff', '--name-only', prevcommit, commit],
cwd=workdir, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@mattbennett
mattbennett / app.py
Last active June 3, 2024 14:14
Nameko celery integration
from flask import Flask, request
from nameko.standalone.rpc import ServiceRpcProxy
app = Flask(__name__)
@app.route('/')
def task_list():
return """
<html>
@vasanthk
vasanthk / System Design.md
Last active July 24, 2024 07:54
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?
@jvawdrey
jvawdrey / pcfdev-aws-deploy.md
Created June 24, 2016 04:55
pcf dev AWS deploy steps

Deploying MicroPCF on AWS

January 5th, 2016

Instructions for deploying micropcf to AWS.

I encountered several challenges relating to AWS configurations and the available Vagrantfile while deploying micropcf to AWS. This documentation details the steps taken to successfully deploy micropcf to AWS.

@nota-ja
nota-ja / README.md
Last active August 18, 2022 15:37
Multiple App Ports Demo on Cloud Foundry
@jsoverson
jsoverson / reddit-signup.js
Created December 3, 2018 17:46
Reddit signup script w/Puppeteer and 2Captcha
const puppeteer = require('puppeteer');
const request = require('request-promise-native');
const poll = require('promise-poller').default;
const siteDetails = {
sitekey: '6LeTnxkTAAAAAN9QEuDZRpn90WwKk_R1TRW_g-JC',
pageurl: 'https://old.reddit.com/login'
}
const getUsername = require('./get-username');
@gwangjinkim
gwangjinkim / install-and-start-postgresql-in-conda-locally
Last active June 10, 2024 05:01
How to install and run postgresql in conda
This gist I write, because I couldn't find step by step instructions
how to install and start postgresql locally (using conda within a conda environment - with the result
that you can run it without sudo/admin rights on your machine!)
and not globally in the operating system (which requires sudo/admin rights on that machine).
I hope, this will help especially people new to postgresql (and those who don't have sudo/admin rights on a specific machine but want
to run postgresql there)!
####################################
# create conda environment