Skip to content

Instantly share code, notes, and snippets.

View crossai-2033's full-sized avatar
😇
I may be slow to respond.

LC crossai-2033

😇
I may be slow to respond.
View GitHub Profile
@crossai-2033
crossai-2033 / Vagrantfile
Created November 13, 2015 13:21
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
@crossai-2033
crossai-2033 / ApiCheck.php
Created September 24, 2015 04:01
Api接口设计算法
当我们设计对外Api接口的时候,要考虑接口的安全性,防止被拦截或者被重放攻击等,所以接口的对外设计要有一套验证机制。
接口的设计主要双方就是接口提供方以及接口使用方,所考虑的方案就是双向加密认证,双方使用一个统一的Token,然后用Token加上固定的混淆规则
然后双方都使用同样的规则来产生一个认证sign来验证。
<!-- Api验证函数 -->
<?php
class ApiCheck
{
const MAX_TIME_DIFF = 600;
@crossai-2033
crossai-2033 / deploy_online.sh
Created May 26, 2015 16:25
发布脚本执行文件
#! /bin/bash
###########################################################################
# 配置项
# include lib
# 获取当前deploy脚本的路径
this_file=`pwd`"/"$0
# 通过dirname获取当前部署脚本所在的目录 -- deploy目录
this_dir=`dirname $this_file`
@crossai-2033
crossai-2033 / deploy_conf.sh
Created May 26, 2015 16:24
发布脚本配置文件
#! /bin/bash
###########################################################################
# 配置项
# 项目名称
prj_name="xxxxx"
# 线上集群列表
@crossai-2033
crossai-2033 / base_start.sh
Created May 17, 2015 04:12
开机启动脚本
#!/bin/bash
### mysql begin ###
/usr/local/mysql/bin/mysqld_safe --user=mysql &
### mysql end ###
### nginx begin ###
/usr/local/nginx/sbin/nginx
### nginx end ###
@crossai-2033
crossai-2033 / IdGen.php
Created April 10, 2015 07:20
用来替代数据库自增id的gen设计
<?php
class IdGen {/*{{{*/
private $executor = null;
public function __construct($executor) {/*{{{*/
$this->executor = $executor;
}/*}}}*/
public function genId($key) {/*{{{*/
@crossai-2033
crossai-2033 / install_sys.sh
Last active August 29, 2015 14:08
linux环境安装脚本
#!/bin/bash
build_dir=$HOME/tmp/build
pkg_root=/data/pkgs/source
pkg_dst_root=/usr/local
if [ -d $build_dir ]
then
rm -rf $build_dir
fi
@crossai-2033
crossai-2033 / git-store.js
Created May 11, 2014 13:52
git store object
var zlib = require('zlib');
var crypto = require('crypto');
var shasum = crypto.createHash('sha1');
var fs = require('fs');
var path = require('path');
var content = 'what is up, doc?';
var header = 'blob ' + content.length + '\0';
var store = header + content;
; Summary: Proxy Switchy! Exported Rule List
; Date: Sunday, May 15, 2011
; Website: http://bit.ly/proxyswitchy
#BEGIN
[wildcard]
*://192.168.1.*
*://www.amazon.com/*
*://www.bbc.co.uk/*
(function($){
$.widget("ui.mywidget", {
options: {
autoOpen: true
},
_create: function(){
// by default, consider this thing closed.