Skip to content

Instantly share code, notes, and snippets.

@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active May 6, 2024 12:37
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%'
@afair
afair / gist:3803895
Last active August 7, 2023 07:43
PostgreSQL and Pgpool Architecture

Hey! I saw this has been indexed by the search engines. It is a first draft of a post I ended up publishing on my blog at: Scaling PostgreSQL With Pgpool and PgBouncer

Thanks for stopping by!

PostgreSQL and Pgpool Architecture

@suziewong
suziewong / ssh.md
Last active April 27, 2018 02:14
SSH端口转发实验

通过本机的81号端口访问测试服务器89的我的私人apache目录(端口为11063)

使用本地转发,在本机上输入

ssh -L 81:210.32.200.89:11063 suzie@210.32.200.89

这时候打开浏览器,输入地址127.0.0.1:81 我同时也试验了

ssh -L 81:127.0.0.1:11063 suzie@210.32.200.89

ssh -L 81:localhost:11063 suzie@210.32.200.89

@econchick
econchick / gist:4666378
Created January 29, 2013 18:24
Implement a Binary Tree in Python
class Node:
def __init__(self, key):
self.key = key
self.parent = None
self.left = None
self.right = None
def insert(root, t):
new = Node(t)
@bluebanboom
bluebanboom / embpython.c
Last active September 12, 2021 04:51
Example of embedding python in c.
#include <Python.h>
#include <stdio.h>
/*
* gcc embpython.c -I/usr/include/python2.7 -lpython
**/
void loadModule()
{
/* run objects with low-level calls */
char *arg1="sir", *arg2="robin", *cstr;
printf("Load Module err!\n");
@dannvix
dannvix / intercept-https-with-python-mitmproxy.md
Last active February 16, 2023 02:43
Intercept and manipulate HTTPs traffic with Python and mitmproxy

Intercepts HTTPs Traffic with Python & mitmproxy

Warning

This Gist is created in 2014, and it's highliy outdated now, according to one of mitmproxy's manjor contributor (check his comment below). Thanks for letting us know, @mhils!

Introduction

Modern applications usually make use of back-end API servers to provide their services. With a non-transparent HTTPs proxy, which intercepts the communication between clients and servers (aka the man-in-the-middle scheme), you can easily manipulate both API requests and responses.

@ekimekim
ekimekim / escapes.py
Created May 29, 2013 05:56
A python library of constants and utility functions for using ANSI terminal escapes.
"""
A python library of constants and utility functions for using ANSI terminal escapes.
Example usage:
>>> import escapes as e
>>> print e.FORECOLOUR(e.RED) + "this is red" + e.UNFORMAT
"""
ESC = "\033" # escape character for terminal
CSI = ESC + "[" # Control Sequence Initiator
@jhjguxin
jhjguxin / mongodb_replication_master.markdown
Last active March 14, 2022 08:19
how switch master/slave between replSet model on mongodb some prepare for migrate database from grandcloud to aliyun clound
@postrational
postrational / gunicorn_start.bash
Last active April 4, 2024 12:48
Example of how to set up Django on Nginx with Gunicorn and supervisordhttp://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
#!/bin/bash
NAME="hello_app" # Name of the application
DJANGODIR=/webapps/hello_django/hello # Django project directory
SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket
USER=hello # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use
DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name
@jasonrudolph
jasonrudolph / 00-about-search-api-examples.md
Last active April 30, 2024 19:21
5 entertaining things you can find with the GitHub Search API