Skip to content

Instantly share code, notes, and snippets.

For
* ES5
* ES6
* CoffeeScript

Keybase proof

I hereby claim:

  • I am aleung on github.
  • I am leoliang (https://keybase.io/leoliang) on keybase.
  • I have a public key whose fingerprint is 1ACE A9DD 75C1 ED20 408A 6E46 45D6 55B0 E6D1 C308

To claim this, I am signing this object:

@aleung
aleung / user.js
Last active November 1, 2017 03:29
Tuleap tracker enhancement. https://greasyfork.org/en/scripts/30456
// ==UserScript==
// @name Tuleap Tracker Enhance
// @namespace https://gist.github.com/aleung/3fac39dbba3351da2c62f8d4890ef3a6
// @version 0.4
// @description Toggle detail in card wall
// @author Leo Liang
// @match https://*/plugins/tracker/*
// ==/UserScript==
(function() {
<!DOCTYPE html>
<meta charset="utf-8">
<title>SANKEY Demo</title>
<style>
.node rect {
cursor: move;
fill-opacity: .9;
shape-rendering: crispEdges;
}
@aleung
aleung / ActiveCountMetric.java
Created November 26, 2013 09:12
Invocation metric bases on codahale (Yammer) Metrics. 这是在Messaging性能测试时使用的metrics,记录了代码块调用的throughput(TPS,latency)和active count(并发数),数据每分钟写入csv格式文件。 用try + finally的方式对调用进行拦截检测,代码有侵入性。当时是测试使用,这样写起来最快。
public interface ActiveCountMetric {
void inc();
void dec();
}
@aleung
aleung / console-output
Created June 13, 2017 08:06
Test of [async-local-storage](https://github.com/vicanso/async-local-storage) on Node.js 8.x
Trace of ID 1
1497340609369: Received request. ID: 1
1497340609369: Step 1 1
1497340610599: Step 2 1
1497340610602: Response sent 1
-----
Trace of ID 2
1497340606575: Received request. ID: 2
1497340606575: Step 1 2
1497340612700: Step 2 2
@aleung
aleung / user.js
Last active June 8, 2017 09:26
User script to slideshow a serial of webpages in loop. https://greasyfork.org/en/scripts/30426-webpages-slideshow
// ==UserScript==
// @name Webpages slideshow
// @namespace https://github.com/aleung/
// @version 1.1.0
// @description Loop display a serial of webpages. Display time for each page can be set.
// @author Leo Liang
// @license MIT License
// @include *
// @noframes
// @require https://openuserjs.org/src/libs/sizzle/GM_config.js
@aleung
aleung / clean_aged_artifacts.rb
Last active April 24, 2017 18:07
Clean up unused (long time no download) artifacts from Artifactory repository. See: http://aleung.github.com/blog/2013/03/22/clean-aged-artifacts-from-artifactory/
#!/bin/env ruby
# --- Configuration ---------------------------------
# Remove artifacts which were created before $age_days ago and haven't been downloaded in recent $age_days.
$age_days = 730
# The repository to be cleaned.
$repo = 'repository-key'
@aleung
aleung / du.sh
Last active March 13, 2017 03:34
One line shell scripts
# size of immediate sub-folders
du -d1 -BM | sort -g
@aleung
aleung / mergelog.js
Created November 2, 2016 11:30
Merge consul agent logs which are fetched by Ansible
#!/usr/bin/env node
"use strict";
const fs = require('fs');
const readline = require('readline');
const logLineRegexp = /\s+(.+?)\[(.+?)\](.*)/;
function processFile(file, host) {