Skip to content

Instantly share code, notes, and snippets.

View teddy-hoo's full-sized avatar

HuLingchuan teddy-hoo

View GitHub Profile
@teddy-hoo
teddy-hoo / deadlock.log
Last active May 8, 2017 12:47
deadlock log
> show engine innodb status;
------------------------
LATEST DETECTED DEADLOCK
------------------------
2017-05-08 20:30:05 7f00b9eb6700
*** (1) TRANSACTION:
TRANSACTION 37152444, ACTIVE 34 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 2 lock struct(s), heap size 360, 1 row lock(s)
MySQL thread id 62732, OS thread handle 0x7f00ba591700, query id 2534379 10.123. 8.23 root updating
@teddy-hoo
teddy-hoo / deadlock.sql
Created May 8, 2017 12:42
reproduce a deadlock in mysql
# session 1
use test;
create table t (i int) engine = InnoDB;
insert into t(i) values(1);
start transaction;
select * from t where i = 1 lock in share mode;
# session 2
use test;
start transaction;
@teddy-hoo
teddy-hoo / fp.php
Last active May 10, 2017 15:02
functional programming in php
<?php
interface Model {
public function getConnection();
public function getDb();
public function getTableName();
public function getData();
public function getFileds();
@teddy-hoo
teddy-hoo / oop.php
Created May 5, 2017 04:14
php oop in a typical web application
<?php
/**
* basic model
*/
class Model {
protected $connection = 'db';
@teddy-hoo
teddy-hoo / install-pypy.sh
Last active November 22, 2016 02:04 — forked from baoshan/install-pypy.sh
Install PyPy(py2.7, v5.6.0) on CentOS
# yum list \*openssl\*
yum install -y openssl098e
yum install -y zlib
ln -s /usr/lib64/libssl.so.0.9.8e /usr/lib64/libssl.so.0.9.8
ln -s /usr/lib64/libcrypto.so.0.9.8e /usr/lib64/libcrypto.so.0.9.8
ln -s /lib64/libbz2.so.1 /lib64/libbz2.so.1.0
wget https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.6.0-linux64.tar.bz2
tar -xf pypy-1.8-linux64.tar.bz2
cp -r pypy-1.8 /opt
ln -s /opt/pypy-1.8/bin/pypy /usr/local/bin