Skip to content

Instantly share code, notes, and snippets.

View zhanghuabin's full-sized avatar

Huabin Zhang zhanghuabin

View GitHub Profile
@zhanghuabin
zhanghuabin / rtf2html_swing.groovy
Last active December 29, 2015 17:29
Use Swing API to convert a simple RTF-format file to HTML-format.
import javax.swing.JEditorPane
(args[0] as File).withReader {
def p = new JEditorPane()
p.contentType = 'text/rtf'
def kitRtf = p.getEditorKitForContentType p.contentType
kitRtf.read it, p.document, 0
def kitHtml = p.getEditorKitForContentType 'text/html'
def out = new StringWriter()
@zhanghuabin
zhanghuabin / curl.md
Created December 6, 2013 17:09 — forked from btoone/curl.md

Introduction

An introduction to curl using GitHub's API

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
apply plugin: 'java'
group = 'qa.webdriver'
subprojects {
apply plugin: 'java'
project.ext.sourceCompatibility = 1.6
repositories {
@zhanghuabin
zhanghuabin / send_email.js
Created March 21, 2014 06:46
Send email with specific subject and content
var msg = {
subject : "Say Hi~",
body : "blablabla..."
};
window.location = "mailto:" + MyApp.User.Email + "?" + Ext.urlEncode(msg);
@zhanghuabin
zhanghuabin / NumberUtils.groovy
Last active May 15, 2017 05:04
Convert number to Chinese financial number characters, 将数字转换为中文财务数字字符
import java.text.NumberFormat
/**
* 数字工具集
*/
class NumberUtils extends org.apache.commons.lang3.math.NumberUtils {
private static final _NUMBER_FORMAT = NumberFormat.numberInstance
@zhanghuabin
zhanghuabin / gist:c37366145bef19856beccbe365648e48
Created July 11, 2016 18:10 — forked from halgari/gist:6309500
Load balancer using core.async
(ns async-examples.load-balancer
(:require [clojure.core.async :refer :all]))
;; Let's assume we have a DB, and it holds the following pairs of name/ages
(def db-store
{:john 42
:amy 33
:jill 3
;; Gaussian sum!
user=> (crit/with-progress-reporting (crit/quick-bench (/ (* (+ 1 99999) 99999) 2)))
Warming up for JIT optimisations 5000000000 ...
compilation occured before 333366 iterations
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
WARNING: Final GC required 8.548926352381509 % of runtime
Finding outliers ...
@zhanghuabin
zhanghuabin / accomplish_courses.sh
Created July 22, 2020 03:54
自动完成课程脚本
#!/usr/bin/env bash
# Prerequisites:
# 1. Install pup
# brew install pup
# 2. Install jq
# brew install jq
# set -v