Skip to content

Instantly share code, notes, and snippets.

View bastengao's full-sized avatar
🏠
Working from home

Basten Gao bastengao

🏠
Working from home
View GitHub Profile
@bastengao
bastengao / verify_url_echostr.rb
Last active August 29, 2015 14:14
微信公众平台企业号验证URL (处理 echostr)
require 'openssl'
require 'base64'
# 参考 http://qydev.weixin.qq.com/wiki/index.php?title=加解密方案的详细说明
AES_KEY = 'aaaa'
encrypted_enchostr = 'bbbb'
def parse_msg(text)
random = text[0..16]
@bastengao
bastengao / jqplot_hex_colors
Created August 28, 2014 02:02
convert rgba color to hex color
require 'color'
jqplot_colors = [
"240, 192, 19, 1",
"217, 135, 20, 1",
" 16, 178, 199, 1",
" 15, 153, 168, 1",
"235, 155, 220, 1",
"247, 57, 197, 1",
"220, 237, 203, 1",
@bastengao
bastengao / OsCheck.java
Created December 8, 2013 04:50
load sigar library
/**
* helper class to check the operating system this Java VM runs in
* http://stackoverflow.com/questions/228477/how-do-i-programmatically-determine-operating-system-in-java
* compare to http://svn.terracotta.org/svn/tc/dso/tags/2.6.4/code/base/common/src/com/tc/util/runtime/Os.java
* http://www.docjar.com/html/api/org/apache/commons/lang/SystemUtils.java.html
*/
public final class OsCheck {
/**
* types of Operating Systems
*/
@bastengao
bastengao / update-hosts.rb
Created June 21, 2013 13:15
自动更新 smart hosts 文件的小工具,暂时只支持 Windows
#encoding: utf-8
require "uri"
require "net/http"
# 自动更新 smart hosts 文件的小工具
# 暂时只支持 Windows
# 抓取最新的 hosts 内容
def fetch_latest_hosts
Net::HTTP.get('smarthosts.googlecode.com', '/svn/trunk/hosts')
end
@bastengao
bastengao / give-me-money.rb
Last active December 17, 2015 06:18
双色球机选
#encoding:utf-8
def gen_balls
final_balls = []
red_ball_poll = (1..33).to_a
6.times do
index = rand(red_ball_poll.length)
red_ball = red_ball_poll.delete_at(index)
final_balls << red_ball
end
@bastengao
bastengao / stylesheet.css
Last active December 14, 2015 07:09
javadoc 使用更清析的字体
/* Javadoc 样式表 */
/* 在此处定义颜色、字体和其他样式属性以覆盖默认值 */
* { font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; }
/* 页面背景颜色 */
html, body { background-color: #FFFFFF; color:#000000; font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; font-size:13px;}
/* 标题 */
h1 { font-size: 145% }
@bastengao
bastengao / pom.xml
Created February 19, 2013 13:44
auto deploy war to tomcat
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.gaohui.cargo-test</groupId>
<artifactId>cargo-test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
@bastengao
bastengao / full-window-layout.html
Created December 15, 2012 05:39
占满屏幕的布局
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>占满屏幕</title>
<style type="text/css">
aside {
position: absolute;
top: 0;
left: 0;
/**
* User: Administrator
* Date: 11-11-4
* Time: 下午11:32
*
* @author Basten Gao
*/
public class EmailUtil {
private static final Map<String, String> EMAILS = loadEmails();
@bastengao
bastengao / ImageNaturalSize
Created September 3, 2012 06:07
get image natural width and height.
window.Images = {
naturalSize:function (imgSrc, callback) {
jQuery("<img/>").load( function () {
var naturalWidth = this.width;
var naturalHeight = this.height;
callback(naturalWidth, naturalHeight);
}).attr("src", imgSrc);
}};