Skip to content

Instantly share code, notes, and snippets.

View zhouyl's full-sized avatar

ZhouYL zhouyl

  • China.ShengZheng
View GitHub Profile
@zhouyl
zhouyl / func.php
Last active August 29, 2015 14:03
字符编码自动转换
<?php
/**
* 支持对多维数组,对象,... 进行编码转换
* 在不指定来源编码时,由系统自动检测编码类型
*
* @link http://cn2.php.net/manual/zh/function.mb-detect-encoding.php
* @link http://cn2.php.net/manual/zh/function.mb-detect-order.php
* @param mixed $data 需要转换的数据
* @param string $to_encoding 目标编码类型
@zhouyl
zhouyl / Database_Iterator.php
Created July 17, 2014 04:34
Kohana Database Iterator
<?php defined('SYSPATH') or die('No direct script access.');
/**
* 数据库迭代器
*/
class Database_Iterator implements SeekableIterator, Countable
{
/**
* select 查询语句
*
@zhouyl
zhouyl / startPD.sh
Created July 17, 2014 17:20
Start Parallels Desktop
#!/bin/sh
ExtensionsPath="/Applications/Parallels Desktop.app/Contents/Library/Extensions/10.6/"
cd "$ExtensionsPath"
sudo chown -R root:wheel "$ExtensionsPath"
sudo kextload -r . prl_hypervisor.kext
sudo kextload -r . prl_hid_hook.kext
sudo kextload -r . prl_usb_connect.kext
@zhouyl
zhouyl / QueryBuilder.php
Created July 18, 2014 02:34
Fixed Phalcon\Paginator\Adapter\QueryBuilder bug
<?php
namespace Base\Paginator;
class QueryBuilder extends \Phalcon\Paginator\Adapter\QueryBuilder
{
public function getPaginate()
{
// 解决 php5.3 在空记录集时,调用 getPaginate() 方法出错的 bug
@zhouyl
zhouyl / jquery.preimage.js
Last active April 13, 2016 11:09
Preview Upload Image
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (typeof exports === 'object') {
factory(require('jquery'));
} else {
factory(jQuery);
}
}(function ($) {
@zhouyl
zhouyl / ZhouYL.tmTheme
Created July 26, 2014 13:22
Sublimt Text 2 Color Schema
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Blackboard</string>
<key>author</key>
<string>Domenico Carbotta</string>
<key>settings</key>
<array>
@zhouyl
zhouyl / Default (Windows).sublime-keymap.json
Last active March 23, 2017 07:00
Sublime Text Settings
[
{ "keys": ["ctrl+shift+c"], "command": "convert_to_utf8" },
{ "keys": ["ctrl+t"], "command": "side_bar_new_file2" },
{ "keys": ["f2"], "command": "side_bar_rename" },
{ "keys": ["ctrl+alt+b"], "command": "upper_case" },
{ "keys": ["ctrl+alt+l"], "command": "lower_case" },
{ "keys": ["ctrl+f"], "command": "show_panel", "args": {"panel": "find", "reverse": false} },
{ "keys": ["ctrl+1"], "command": "fold_by_level", "args": {"level": 1} },
{ "keys": ["ctrl+2"], "command": "fold_by_level", "args": {"level": 2} },
{ "keys": ["ctrl+3"], "command": "fold_by_level", "args": {"level": 3} },
@zhouyl
zhouyl / message.php
Last active August 29, 2015 14:05
phalcon view helper
<?php
namespace Base\View\Helper;
/**
* 视图助手 - 输出响应信息
*
* 示例:
*
* $helper = new \Base\View\Helper\Message;
@zhouyl
zhouyl / cli.function.php
Created August 19, 2014 03:06
CLI 命令行函数
<?php
/**
* CLI 命令行函数
*/
/**
* 生成具有颜色的文本
*
* @param string $text
@zhouyl
zhouyl / README.md
Last active May 28, 2018 08:23
PHP 版本切换脚本

PHP 版本切换脚本

需要将 PHP 各版本安装到 /usr/local/php$VER/ 目录下

保存 php-switch 到 /usr/local/bin目录下

执行以下命令

 chmod +x /usr/local/bin/php-switch