<?php
function gbk_to_utf8($str){
return mb_convert_encoding($str, 'utf-8', 'gbk');
}
function utf8_to_gbk($str){
return mb_convert_encoding($str, 'gbk', 'utf-8');
}
阅读全部 | 2014年8月16日 10:50
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import os
import sys
import time
def get_remote_status():
l = os.popen('ssh root@remote.com "cd /var/www/mysite; git st"').readlines()
s = ''.join(l)
return s
......................
阅读全部 | 2014年8月14日 23:46
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
class File:
file = None
def __init__(self):
pass
@staticmethod
def open(obj, flag):
......................
阅读全部 | 2014年8月12日 17:09
<?php
function walk($pattern){
$files = glob($pattern);
foreach(array_reverse(glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT)) as $dir){
$files = array_merge(walk($dir.'/'.basename($pattern)), $files);
}
return $files;
}
print_r(walk("*.*"));
阅读全部 | 2014年8月11日 11:47
<?php
function __start_session(){
if(!defined('SESSION_START')){
define('SESSION_START', true);
session_set_cookie_params(86400*30);
session_start();
}
}
function set_session($key, $value, $maxage=2400){
__start_session();
$_SESSION[$key] = $value;
......................
阅读全部 | 2014年8月7日 16:55
.clearfix:after
clear: both
content: "."
display: block
height: 0
visibility: hidden
阅读全部 | 2014年6月25日 10:16
<?php
class Mysql{
protected $conn;
public function __construct($dbhost, $dbuser, $dbpass, $dbname){
$this->conn = mysql_connect($dbhost, $dbuser, $dbpass, 1);
if(!$this->conn){
die('Could not connect: ' . mysql_error());
}
mysql_select_db($dbname, $this->conn);
......................
阅读全部 | 2014年6月25日 09:20
<?php
function git_commit_change(){
exec("git status", $l);
$s = implode('', $l);
if(strpos($s, "nothing to commit") === false){
if(strpos($s, 'delete')!==false){
foreach($l as $line){
if(strpos($line, 'delete')!==false){
$deleted_file = trim(str_replace("deleted:",'',$line));
system("git rm ".$deleted_file);
}
......................
阅读全部 | 2014年5月28日 16:14
<?php
function path_join(){
$args = func_get_args();
$paths = array();
foreach ($args as $arg) {
$paths = array_merge($paths, (array)$arg);
}
$paths = array_map(function($p, $k){
if($k == 0){
return rtrim($p, "/");
}else{
......................
阅读全部 | 2014年5月8日 14:32
server {
listen 80;
server_name tms.tagmanager.com;
client_max_body_size 3m;
gzip_static on;
#charset koi8-r;
#access_log /var/www/my.bccn.net/log/host.access.log;
location / {
root /var/www/tagmanager/;
......................
阅读全部 | 2013年7月23日 17:45