Skip to content

Instantly share code, notes, and snippets.

Chang-Hung Liang eliangcs

Block or report user

Report or block eliangcs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
eliangcs /
Created Jul 27, 2018
A minimal netcat web server that prints everything it gets
httplogger() {
while true; do
echo -e "HTTP/1.1 200 OK\r\n\r\nok" | nc -vl 8989
test $? -gt 128 && break
echo '----------------------------------------'
eliangcs /
Last active Nov 2, 2017
Script Filter for Alfred listing all the issues and PRs assigned to or created by you
import functools
import json
import os
from datetime import datetime
from threading import Thread
import requests
eliangcs /
Last active Jun 8, 2019
How I created HTTP Prompt and got 5000+ stars on GitHub

How I Created HTTP Prompt and Got 5000+ Stars on GitHub

Two months ago, I published an open source project, which went viral by gaining 1200+ stars in the first 24 hours. As of this writing, it has attracted 5000+ stars. The project is called HTTP Prompt:

Here I want to share its development story.

It all began with Vertica. Not long ago, I used Vertica every day for my work. Vertica is a powerful database, but the official client (vsql) is not powerful at all. The GUI alternative, DbVisualizer, is bad as well.

eliangcs /
Created Jan 22, 2016
Guess encoding by looking at the content
def guess_encoding(s):
"""Guess the character encoding from a byte string."""
# Check BOM
# 0xFF, 0xFE -> UTF-16 LE
# 0xFE, 0xFF -> UTF-16 BE
# 0xEF, 0xBB, 0xBF -> UTF-8
bom = s[0:2]
if bom == '\xff\xfe':
return 'utf-16'
elif bom == '\xfe\xff':
eliangcs / index.html
Last active Jan 18, 2016
Integrating sine with Monte Carlo / Metropolis algorithm
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
.svg {
border: 1px solid #000;
.result {
color: #05c;
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
.background {
fill: #e7e7e7;
.axis path,
.axis line {
eliangcs /
Last active Jan 7, 2020
A minimal web server that runs shell commands, powered by Tornado and its Subprocess module
A minimal web server that runs shell commands, powered by Tornado and its
Subprocess module. It does non-blocking IO and streams the response.
To start the server:
$ python
To send a shell command using httpie:
eliangcs /
Last active Jan 18, 2016
Shell shortcuts
# Clear local merged branches
function clearbranches(){
cur_branch=`git rev-parse --abbrev-ref HEAD`
if [[ "$cur_branch" == "master" ]]; then
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
echo "Not on master branch!"
View vsql_commands.txt
See the Vertica Programmer's Guide for information on available commands.
\c[onnect] [DBNAME|- [USER]]
connect to new database (currently "localdev")
\cd [DIR] change the current working directory
\q quit vsql
\set [NAME [VALUE]]
set internal variable, or list all if no parameters
\timing toggle timing of commands (currently off)
eliangcs /
Last active Dec 16, 2016
Log execution time for every Celery task, working on Celery 3.1.x.
import logging
import time
from celery import shared_task as orig_shared_task
def timeit(func):
"""A decorator used to log the function execution time."""
logger = logging.getLogger('tasks')
You can’t perform that action at this time.