Skip to content

Instantly share code, notes, and snippets.

View pcdinh's full-sized avatar

Pham Cong Dinh pcdinh

View GitHub Profile
@pcdinh
pcdinh / slave_gevent.py
Created January 22, 2012 19:34 — forked from gleicon/slave_gevent.py
gevent+kombu actor/mailbox using decorators
from __future__ import with_statement
from kombu import BrokerConnection
from collections import defaultdict
import gevent
from gevent import monkey
monkey.patch_all()
class WorkerHub():
"""
WorkerHub controls the local mailboxes that the @worker decorator assigns.
var f = new Array();
function S() {
var H;
if (H != 'j') {
H = ''
};
var O;
if (O != 'Z') {
O = ''
UserA at host1 -> UserB at host2: [UserA@host1 ~]ssh UserB@host2
=> no password required
1. In host1 as UserA
UserA@host1:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/UserA/.ssh/id_rsa):
Created directory '/home/UserA/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
@pcdinh
pcdinh / gist:1743283
Created February 5, 2012 05:49 — forked from srid/gist:1502656
Asynchronous run command lazily yielding command output (Python gevent)
def run_seq(cmd):
"""Run `cmd` and yield its output lazily"""
p = subprocess.Popen(
cmd, shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
# make STDIN and STDOUT non-blocking
fcntl.fcntl(p.stdin, fcntl.F_SETFL, os.O_NONBLOCK)
@pcdinh
pcdinh / pinhole.py
Created August 2, 2012 07:22 — forked from xiocode/pinhole.py
A simple port multiplexer
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# author: mayli <mayli.he@gmail.com>
#
# Modified from Pinhole, and the original code is found here:
# {{{ http://code.activestate.com/recipes/114642/ (r1)
#
"""
usage: pinhole
@pcdinh
pcdinh / MyAnalyzer
Created August 18, 2012 08:36
Custom Lucene analyzer
import java.io.*;
import org.apache.lucene.analysis.*;
import org.apache.lucene.util.Version;
public class MyAnalyzer extends Analyzer {
public TokenStream tokenStream(String fieldName, Reader reader) {
return
new StopFilter(
true,
<?php
declare(ticks = 1);
function handleExit($signal)
{
error_log("Caught a $signal signal, a worker process exiting\n", 3, './error-child-log');
exit(1);
}
pcntl_signal(SIGTERM, 'handleExit');
@pcdinh
pcdinh / postgis_timezone_db.markdown
Created November 22, 2012 10:42 — forked from robcowie/postgis_timezone_db.markdown
Create a postgis-compatible timezone database

Create a Postgis timezone DB

See https://gist.github.com/3449216

Create a timezone db from shapefiles

$ curl -O http://efele.net/maps/tz/world/tz_world.zip
$ wget http://efele.net/maps/tz/us/tz_us.zip
$ open tz_world.zip
@pcdinh
pcdinh / stripe-keys-and-ids.tsv
Created September 24, 2020 09:27 — forked from fnky/stripe-keys-and-ids.tsv
Stripe keys and IDs
Prefix Description Notes
sk_live_ Live secret key Secret key in a live environment.
pk_live_ Live public key Public key in a live environment.
pst_live_ Live Connection token Connection token in a live environment.
sk_test_ Test secret key Pecret key in a test environment.
pk_test_ Test public key Public key in a test environment.
pst_test_ Test Connection token Connection token in a test environment.
ac_ Platform Client ID Identifier for an auth code/client id.
acct_ Account ID Identifier for an Account object.
ch_ Charge ID Identifier for a Charge object.
@pcdinh
pcdinh / 1_stripe-schema.md
Created September 24, 2020 08:18 — forked from FGRibreau/1_stripe-schema.md
Stripe database schema (extracted from their sigma product) as of 2019-10-09
jqn -r markdown-table 'map(x => "## " + x.name + "\n\n" + markdownTable(x.columns.map(y => [y.name, y.type]))  ) | join("\n\n")' < /tmp/stripe.json

accounts

id varchar
business_name varchar
business_url varchar