Skip to content

Instantly share code, notes, and snippets.

View xuanyan's full-sized avatar

xuanyan xuanyan

View GitHub Profile
@xuanyan
xuanyan / ClassLoader.php
Created April 24, 2013 08:01
fix ClassLoader to run below php 5.3.0
<?php
/**
* ClassLoader implements a PSR-0 class loader
*
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
// // JavaScript I wrote to limit what types of input are allowed to be keyed into a textbox
// var allowedSpecialCharKeyCodes = [46,8,37,39,35,36,9];
// var numberKeyCodes = [44, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105];
function numbersOnly(event) {
var legalKeyCode =
(!event.shiftKey && !event.ctrlKey && !event.altKey)
&&
(jQuery.inArray(event.keyCode, allowedSpecialCharKeyCodes) >= 0
||
@xuanyan
xuanyan / gist:5210976
Created March 21, 2013 05:58
svn add
svn st | awk '{if ( $1 == "?") { print $2}}' | xargs svn add
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`
# get the load averages
read one five fifteen rest < /proc/loadavg
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
svn st | grep "^\?" | awk "{print \$2}" | xargs svn add $1
#!/bin/sh
DB_USER="mysql_user_name"
DB_PASS="mysql_password"
BK_DIR="/backup_dir"
MYSQL_PATH="/usr/local/mysql/bin"
DATE=`date +%F`
DIR="$BK_DIR/$DATE"
if [ ! -d "$DIR" ];then
#!/bin/sh
a=`ps aux | grep -c 'sqs_daemon_beta'`
if [ $a = 1 ]
then
nohup /usr/local/php/bin/php /data/kishioo/sqs_daemon_beta.php -c /data/kishioo/web/config/sqs_conf.php 2>&1 >> /tmp/sqs.log &
fi
#!/bin/sh
target=`pwd`
find $target -type d -name .svn | while read i
do
rm -rf '$i'
echo "$i deleted!"
done
<?php
$smarty->register_prefilter('smarty_fix_include');
function smarty_fix_include($out_put, &$smarty)
{
// 找出所有的include标签,并找出file
return preg_replace_callback('/\{include\s+.*?file=[\'"]*(.+)[\'"]*\}/i', 'smarty_fix_include_callback', $out_put);
}
function smarty_fix_include_callback($match)