Skip to content

Instantly share code, notes, and snippets.

View bingoohuang's full-sized avatar
🎯
Focusing

bingoohuang bingoohuang

🎯
Focusing
View GitHub Profile
@bingoohuang
bingoohuang / 0_reuse_code.js
Created June 15, 2014 23:51
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@bingoohuang
bingoohuang / TryLoadImages.js
Last active August 29, 2015 14:04
Try load images by sequence until 404 found
<html>
<body>
</body>
<script>
(function tryLoadImages(index) {
var img = document.createElement('img');
img.src = "http://127.0.0.1:7001/" + index + ".jpg";
img.onload = function() {
document.body.appendChild(img);
@bingoohuang
bingoohuang / dfawk
Created July 16, 2015 11:14
convert df output with awk
[root@iZ25p1jt074Z ~]# df -m|awk 'NR==1{for(i=1;i<=NF;i++){ix[i]=$i}} (NR>1){for(i=1;i<=NF-1;i++){printf "%s:%s,",ix[i],$i} printf "%s:%s\n",ix[NF],$NF}'
Filesystem:/dev/xvda1,1M-blocks:20158,Used:12464,Available:6671,Use%:66%,Mounted:/
Filesystem:tmpfs,1M-blocks:4096,Used:0,Available:4096,Use%:0%,Mounted:/dev/shm
Filesystem:/dev/xvdb1,1M-blocks:201581,Used:9433,Available:181909,Use%:5%,Mounted:/mnt
[root@iZ25p1jt074Z ~]#
@bingoohuang
bingoohuang / DifferenceClassNamesTest.java
Last active December 19, 2015 07:09
In Java: What is the difference between: Object o1= .... o1.getClass().getSimpleName(); o1.getClass().getName(); o1.getClass().getCanonicalName();
/**
In Java: What is the difference between:
Object o1= ....
o1.getClass().getSimpleName();
o1.getClass().getName();
o1.getClass().getCanonicalName();
**/
@Test
public void testNames() throws Exception {
//primative
@bingoohuang
bingoohuang / nginx_limit_by_cookie.conf.lua
Last active December 23, 2015 07:49
nginx limit by login user's cookie
@bingoohuang
bingoohuang / SeckillingMeasure.java
Last active February 19, 2016 08:25
seckilling implementation using java springmvc
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.params.HttpClientParams;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
package main
import (
"fmt"
"sync"
)
// more to see https://github.com/golang/go/wiki/CommonMistakes
func main() {
m := []string{"a", "b", "c", "d"}
@bingoohuang
bingoohuang / rmtargets.sh
Created July 26, 2018 01:23
Remove all target directories for all maven projects located in current directory.
find . -type d -name "target" -maxdepth 2 | xargs rm -rf
@bingoohuang
bingoohuang / RandomImage.java
Created January 11, 2019 07:18
create random image
package imagexx;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
public class RandomImage {
public static void main(String args[]) {
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Maps;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.util.Base64;