Skip to content

Instantly share code, notes, and snippets.

View codeachange's full-sized avatar

noname codeachange

View GitHub Profile
#!/bin/bash
# CentOS release 6.4
# https://www.digitalocean.com/community/articles/how-to-setup-your-own-vpn-with-pptp
# rpm --import http://poptop.sourceforge.net/yum/RPM-GPG-KEY-PPTP
# rpm -i http://poptop.sourceforge.net/yum/stable/rhel6/pptp-release-current.noarch.rpm
# centos 6.5 use epel instead
# http://mirrors.hustunique.com/epel/6/i386/repoview/epel-release.html
rpm -Uvh http://mirrors.hustunique.com/epel/6/i386/epel-release-6-8.noarch.rpm
#!/bin/bash
# MySQL Server Info
MyUSER="root"
MyPASS="passwd"
MyHOST="localhost"
# Linux bin paths, change this if it can not be autodetected via which command
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
function html_cut($text, $max_length){
$tags = array();
$result = "";
$is_open = false;
$grab_open = false;
$is_close = false;
$in_double_quotes = false;
$in_single_quotes = false;
$tag = "";
@codeachange
codeachange / directory_backup_script.sh
Created August 15, 2013 07:38
shell script to backup a directory
#!/bin/bash
# This file must be put in the same directory of TargetDir
# Because using relative path to avoid tar warning:
# tar: Removing leading `/' from member names
TargetDir="html"
DestDir="/var/www/backup/dir"
@codeachange
codeachange / jquery.dragResize.js
Created September 17, 2013 05:35
drag the handler, resize the element before and after it
(function($){
$.fn.dragResize = function(handler, lefter, righter){
handler = $(handler);
lefter = $(lefter);
righter = $(righter);
var dragging = false, oldX = 0;
handler.mousedown(function(e){
dragging = true;
oldX = e.pageX;
@codeachange
codeachange / js_keyboard.js
Created September 30, 2013 06:32
屏幕键盘未完成版
// 屏幕键盘
$(".keyhd").mousedown(function(){
$(this).addClass("active");
}).mouseup(function(){
var keyvalue = $(this).text();
var target = current_input_target.get(0);
if(target){
if(/^[0-9a-zA-Z]$/.test(keyvalue)){
insertAtCursor(target,keyvalue);
}else{
@codeachange
codeachange / MessageChannel Example.js
Last active April 8, 2022 19:09
HTML5 MessageChannel Example: Communicate between Web Workers Using MessageChannel
// Test Example, include three files: main.html, worker1.js, worker2.js
// We are going to post a message to worker2 through worker1
// main.html
var w1 = new Worker('worker1.js');
var w2 = new Worker('worker2.js');
// creat a channel, give the ports to the workers
var mc = new MessageChannel();
@codeachange
codeachange / pagination.php
Created November 13, 2013 06:51
分页函数,输出结果兼容bootstrap pagination样式
function paginate($baseurl,$total,$perpage,$curpage,$numlinks=10){
$return = '<div class="pagination"><ul>';
$pages = ceil($total/$perpage);
// 如果当前页大于总页数或小于1,则设置当前页为第一页
$curpage = ($curpage > $pages || $curpage < 1) ? 1 : $curpage;
if($pages > 0){
// 首页 上一页
if($curpage != 1){
@codeachange
codeachange / jquery.dblkeydown.js
Created December 11, 2013 15:50
jQuery double keydown plugin, detect double keydown(same key pressed twice) event
(function($){
$.fn.dblkeydown = function(keyCode, callback){
return $(this).keydown(function(e){
if (e.which == keyCode) {
var lastTime = $(this).data('dblkeydown_' + keyCode);
var curTime = new Date().getTime();
if (lastTime && (curTime - lastTime < $.fn.dblkeydown.maxInterval)) {
$(this).data('dblkeydown_' + keyCode, null);
callback.call(this);
}else{
@codeachange
codeachange / bat_code.bat
Created January 22, 2014 07:48
usefull bat code
添加开机启动任务计划
@echo off
schtasks /create /tn "chaxunji" /tr "C:/ChaXunJi/清空打印任务启动查询机.exe" /sc onlogon
@echo "设置成功,按任意键退出。"
pause