Skip to content

Instantly share code, notes, and snippets.

@tomheng
tomheng / gist:6149779
Last active May 21, 2019 08:21
用Memcache实现分布式的锁服务
<?php
/**
* 锁服务(用Memcache模拟锁)
*/
class Lock{
private $mc = null;
private $key_prefix = "memcache_lock_service_key_";
@tomheng
tomheng / gist:7600651
Last active December 29, 2015 02:29
简单的日志监控程序
#!/bin/sh
sleep 5m
log=/var/log/php5.log
tail -Fn0 $log | \
while read line; do
echo $line | grep 'Fatal error'
if [ $? = 0 ]
then
pids=$(ps aux | grep $0 | grep -v 'grep' | awk '{print $2}')
php mail_error.php 'PHP Fatal error' "$line" # do what you want to do
@tomheng
tomheng / vimrc
Created June 4, 2012 03:52
vimrc
set number
syntax on
set hlsearch
set autochdir
set history=500
set incsearch "输入搜索内容时即显示搜索结果
set ruler
set shiftwidth=4 "设定<<和>>命令移动的宽度为4
set tabstop=4
set softtabstop=4 "退格键一次可以删除四个空格
@tomheng
tomheng / gist:2271597
Created April 1, 2012 05:09
md5_linux
#!/bin/bash
echo -n $1 | md5sum | awk '{print $1}'