Skip to content

Instantly share code, notes, and snippets.

View wenpeng's full-sized avatar

Wenpeng wenpeng

  • China · Shanghai
View GitHub Profile
<?php
$arr = [1, 3, 4, 6, 5, 7, 2, 8, 9];
# 快速排序
function quickSort($arr) {
$len = count($arr);
if ($len < 2) {
return $arr;
#!/bin/bash
# Author: yeho <lj2007331 AT gmail.com>
# BLOG: https://blog.linuxeye.com
#
# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
#
# Project home page:
# https://oneinstack.com
# https://github.com/lj2007331/oneinstack
@wenpeng
wenpeng / gist:8867418ce67abdf887829f316c6cc70c
Created March 27, 2017 11:15
SQL,批量为字段的值增加前缀
update forumdata_userttt set userLink=concat('http://weibo.com/',userLink) where id>198;
function Delete($path)
{
if (is_dir($path) === true)
{
$files = array_diff(scandir($path), array('.', '..'));
foreach ($files as $file)
{
Delete(realpath($path) . '/' . $file);
}
@wenpeng
wenpeng / JavaScript.sublime-build
Created July 14, 2016 02:11 — forked from corbanb/JavaScript.sublime-build
Sublime Text - Tools > Build System > New Build System
// Sublime Text - Build System for Javascript
{
"cmd": ["node", "$file"],
"selector": "source.js"
}
@wenpeng
wenpeng / rm_dir.php
Created January 8, 2016 07:41
删除文件夹下所文件
<?php
function clean_dir($dir, $self = false) {
//先删除目录下的文件:
$dh = opendir($dir);
while ($file = readdir($dh)) {
if($file != '.' && $file !== '..') {
$full_path = $dir .'/'. $file;
if(! is_dir($full_path)) {
unlink($full_path);
} else {
@wenpeng
wenpeng / sub_str.php
Last active January 8, 2016 07:27
PHP截取中英文混合字符串
<?php
if(!function_exists('sub_str')) {
/**
* 截取UTF-8编码下字符串的函数
*
* @param string $str 被截取的字符串
* @param int $length 截取的长度
* @param bool $append 是否附加省略号
*
* @return string
@wenpeng
wenpeng / DOMElement.innerHTML.php
Created October 26, 2015 10:12 — forked from komlenic/DOMElement.innerHTML.php
Get innerHTML of a php DOMElement
<?php
// See http://www.php.net/manual/en/class.domelement.php#101243
function get_inner_html( $node ) {
$innerHTML= '';
$children = $node->childNodes;
foreach ($children as $child) {
$innerHTML .= $child->ownerDocument->saveXML( $child );
}
return $innerHTML;