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 / 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
#!/bin/bash
# 以下配置信息请自己修改
mysql_user="root" #MySQL备份用户
mysql_password="123" #MySQL备份用户的密码
mysql_host="localhost"
mysql_port="3306"
mysql_charset="utf8" #MySQL编码
backup_db_arr=("infos") #要备份的数据库名称,多个用空格分开隔开 如("db1" "db2" "db3")
backup_location=/home/clinyong/backup/mysql #备份数据存放位置,末尾请不要带"/",此项可以保持默认,程序会自动创建文件夹
@clinyong
clinyong / showSignature.go
Last active August 29, 2015 14:27
Show func signature
func showSignature(any interface{}) string{
fn := reflect.ValueOf(any)
if fn.Kind() != reflect.Func {
return
}
sig := fn.Type().String()
return sig
}
@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