Skip to content

Instantly share code, notes, and snippets.

View pcdinh's full-sized avatar

Pham Cong Dinh pcdinh

View GitHub Profile
#!/usr/local/php5-fcgi/bin/php
<?php
$out = shell_exec('mysql -u root -p');
if (false !== strpos($out, 'Enter password')) {
fwrite(STDOUT, "mypassword-here");
$resp = trim(fgets(STDIN));
fwrite(STDOUT, $resp);
}
@pcdinh
pcdinh / index.html
Created October 23, 2010 18:34 — forked from taiju/index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>そう簡単には読ませてあげませんったー</title>
<link href="style.css" rel="stylesheet">
<script src="http://www.google.com/jsapi"></script>
<script src="/socket.io/socket.io.js"></script>
<script>
google.load('jquery', '1.4.3');
@pcdinh
pcdinh / rpmdb
Created November 1, 2010 04:20
rpmdb: unable to lock mutex: Invalid argument
# Got this message printed out repeatedly on the terminal screen while trying to install some packages using yum
# rpmdb: unable to lock mutex: Invalid argument
# rpmdb: unable to lock mutex: Invalid argument
# rpmdb: unable to lock mutex: Invalid argument
# rpmdb: unable to lock mutex: Invalid argument
# rpmdb: unable to lock mutex: Invalid argument
# rpmdb: unable to lock mutex: Invalid argument
# rpmdb: unable to lock mutex: Invalid argument
# rpmdb: unable to lock mutex: Invalid argument
@pcdinh
pcdinh / gist:714042
Created November 24, 2010 17:31
Socket.java
package hello;
import javax.microedition.midlet.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import java.io.*;
/**
* @author Pcdinh
*/
@pcdinh
pcdinh / gist:735117
Created December 9, 2010 18:41 — forked from vsajip/gist:721870
Some thoughts about Celery and logging
======================================
LoggerAdapter
-------------
It appears that the use of LoggerAdapter is to get the processName into the
LogRecord (at least, that's what _CompatLoggerAdapter does) but if
LoggerAdapter is defined in logging, _CompatLoggerAdapter won't be used.
@pcdinh
pcdinh / tasks.py
Created December 9, 2010 18:49 — forked from winhamwr/tasks.py
class BackupArchiveGenerator(Task):
def get_archive_name(self, tenant, date, archive):
"""
Build and return the archive name based on the requested archive.
"""
filename = '%s_to_%s' % (date.strftime('%Y_%m_%d'), datetime.datetime.today().strftime('%Y_%m_%d'))
if archive:
filename = "%s_archive" % filename
destination = os.path.join(tenant.subdomain, '%s.zip' % filename)
L1 cache reference | 0.5 ns
Branch mispredict | 5 ns
L2 cache reference | 7 ns
Mutex lock/unlock | 25 ns
Main memory reference | 100 ns
Compress 1K bytes w/ cheap algorithm | 3,000 ns
Send 2K bytes over 1 Gbps network | 20,000 ns
Read 1 MB sequentially from memory | 250,000 ns
Round trip within same datacenter | 500,000 ns
Disk seek | 10,000,000 ns
#!/usr/bin/env python
"""
test_http_conns.py - Tests for how HTTP persistent connections are handled,
including pipelining.
This script will set up a server which summarises how a browser connecting
to it behaves. For example, FireFox with pipelining turned on will give:
--->8---
@pcdinh
pcdinh / python-crash.txt
Created January 28, 2011 04:42
Python crash report
Process: Python [1502]
Path: /System/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: ??? (???)
Code Type: X86-64 (Native)
Parent Process: Python [309]
Date/Time: 2011-01-28 10:24:58.125 +0700
OS Version: Mac OS X 10.6.5 (10H574)
Report Version: 6