Skip to content

Instantly share code, notes, and snippets.

/**
*
* 打印调试日志
* @param string $errmsg
*/
function new_debug($msg) {
$info = debug_backtrace ();
$file = $info [0] ['file'];
$line = $info [0] ['line'];
if (is_array ( $msg ) || is_object ( $msg )) {
@clinyong
clinyong / php时间差计算
Created August 5, 2014 01:44
php时间差计算
/**
* 时间差计算
*
* @param Timestamp $time 时间差
* @return String Time Elapsed
* @author Shelley Shyan
* @copyright http://phparch.cn (Professional PHP Architecture)
*/
function time2Units ($time)
{
@clinyong
clinyong / delBom.php
Created August 27, 2014 01:21
I use this script to detect bom file recursively, and delete bom with sublime text.
<?php
/**
* 用法:复制以下代码至新建的php文件中,将该php文件放置项目目录,运行即可。代码来源于网络。
* chenwei 注。
*/
header('content-Type: text/html; charset=utf-8');
$auto=0;/* 设置为1标示检测BOM并去除,设置为0标示只进行BOM检测,不去除 */
$basedir='.';
$loop=true;
echo '当前查找的目录为:'.$basedir.'当前的设置是:';
@clinyong
clinyong / Draggable div
Last active August 29, 2015 14:06
JavaScript drag div
window.onload = addListeners;
function addListeners() {
document.getElementById('dxy').addEventListener('mousedown', mouseDown, false);
window.addEventListener('mouseup', mouseUp, false);
}
function mouseUp() {
window.removeEventListener('mousermove', divMove, true);
}
@clinyong
clinyong / is_loop.c
Last active August 29, 2015 14:06
快慢法判断链表有没有环
bool isLoop( link* head)
{
link* s = head; //移动缓慢的指针
link* f = head; //移动快速的指针
do
{
@clinyong
clinyong / uniqueArr.js
Last active August 29, 2015 14:06
数组去重
//这个函数还有个bug,就是当输入的数组为[new String(1), new Number(1)]时,无法区别
function uniqueArr(arr) {
var n = {};
var r = [];
arr.forEach(function(v){
var key = typeof(v) + v;
if (!n[key]) {
n[key] = true
r.push(v)
@clinyong
clinyong / reverse_list.c
Last active August 29, 2015 14:07
单链表反向
typedef struct node{
int val;
struct node *next;
}node;
void reverse(node *currentNode)
{
node *preNode = NULL;
node *nextNode = NULL;
@clinyong
clinyong / merge_sort_list.c
Created October 14, 2014 05:07
链表的归并排序
/*归并排序*/
void MergeSort(struct node** headRef)
{
struct node* head = *headRef;
struct node* a;
struct node* b;
/*base case-- length 0 or 1 */
if((head == NULL) || (head->next == NULL))
{
# Remove previous installations
sudo apt-get remove vim vim-runtime vim-tiny vim-common
# Install dependencies
sudo apt-get install libncurses5-dev python-dev libperl-dev ruby-dev liblua5.2-dev
# Fix liblua paths
sudo ln -s /usr/include/lua5.2 /usr/include/lua
sudo ln -s /usr/lib/x86_64-linux-gnu/liblua5.2.so /usr/local/lib/liblua.so
@clinyong
clinyong / vim-gopath
Created April 12, 2015 03:27
vim auto set current directory as GOPATH
# add following lines to your vimrc file
if !empty(glob("src"))
let $GOPATH=getcwd()
let $GOBIN=getcwd() . "/bin"
let $PATH=$GOBIN . ":" . $PATH
endif