Skip to content

Instantly share code, notes, and snippets.

View horsley's full-sized avatar

Horsley Lee horsley

View GitHub Profile
@horsley
horsley / littlealchemy formula
Last active December 18, 2015 13:09
littlealchemy formula
water = ice + fire
water = egg + hourglass
fire : final
earth : final
air : final
steam = water + fire
steam = water + energy
lava = earth + fire
pressure = earth + earth
pressure = air + air
@horsley
horsley / .screenrc
Created June 28, 2013 13:20
my screenrc
termcap vt102 ''
hardstatus on
hardstatus alwayslastline
hardstatus string '%{=b}%{b}%-w%{.BW}%10>[%n %t]%{-}%+w%< %=%{G}%H %{-b}%{w}%Y/%m/%d %c:%s'
vbell off
defscrollback 1000
windows
# 退出vim/nano之后自动刷新屏幕
altscreen on
@horsley
horsley / mysql_backup.sh
Created June 30, 2013 19:14
mysql分库备份脚本
#!/bin/bash
#以下信息请自行修改
MYSQL_DIR=/usr/local/mysql #mysql目录
MYSQL_USER=root #mysql用户名
MYSQL_PASS=123456 #mysql密码
BACKUP_DIR=/backup #存放备份文件的目录
#以上信息自行修改
#定义数据库的名字和旧数据库的名字
DataBakName=Data_$(date +”%Y%m%d”).tar.gz
@horsley
horsley / main.go
Created August 14, 2013 05:25
文件分割器 for jokerdeng
// lineSpliter project main.go
package main
import (
"bufio"
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
@horsley
horsley / ScreenCloser.go
Created October 23, 2013 03:15
windows下5秒关闭屏幕
// ScreenCloser project main.go
package main
import (
"syscall"
"time"
)
const (
SC_MONITORPOWER = 0xF170
@horsley
horsley / autodeploy.php
Last active December 27, 2015 04:49
一个简单的post hook用来自动部署
<?php
/**
* 简单自动部署
* bitbucket POST hook http://horsley:anypassword@your_host/autodeploy.php
*/
define('APP_PATH', dirname(__FILE__));
if (php_sapi_name() != 'cli') {
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
@horsley
horsley / kv_cache.php
Last active December 27, 2015 06:19
一种简单的文件缓存,git风格的存储结构,简答的序列化
<?php
/**
* 简单文件缓存
* @author: horsley
* @version: 2013-11-04
*/
class Cache {
//内存缓存,跟磁盘缓存保持一致格式
//消耗内存,但可减少一次请求内的磁盘io次数,并加速读取(命中时)
@horsley
horsley / function.php
Last active December 28, 2015 16:09
url合成的常用函数,获取基准url和部署子目录
<?php
/**
* 获取本系统存放的目录 对应的url
* 当本系统部署在非站点根目录的时候 需要使用本函数获取系统根目录对应url
* 其后没有斜杠
* @access public
* @return string
*/
function get_baseurl() {
@horsley
horsley / autodeploy.go
Last active December 30, 2015 09:29
go语言版本autodeploy中间件,比较适用于windows服务器直接在php中调用git不灵,本程序自动寻找git执行文件路径,执行git pull,并通过http方式返回结果,带有简单的身份验证
// gitpull project main.go
package main
import (
"fmt"
"io"
"net/http"
"os"
"os/exec"
"path/filepath"
@horsley
horsley / rsync.php
Last active July 16, 2018 10:17
rsync shell 拉取模式,其实除非你要用inotify做实时备份,否则定时备份根本就用不着用rsync daemon,直接通过shell拉取就好。当然要配好无密码的公约密码登录,让备份服务器可以访问到待备份的数据。
#!/usr/sbin/php
<?php
/*
* Rsync备份脚本
*/
set_time_limit(0);
date_default_timezone_set('Asia/Shanghai');
define('CONF_SRC', 'backup_src');
define('CONF_DST', 'backup_dest');