Skip to content

Instantly share code, notes, and snippets.

Have an Octotastic day!

hrchu hrchu

Have an Octotastic day!
Block or report user

Report or block hrchu

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
hrchu /
Created May 17, 2019
install phantomjs on ubuntu 16.04.4
# install phantomjs on ubuntu 16.04.4
tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2
sudo cp phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin/
phantomjs --version
sudo cp phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/
hrchu /
Created Apr 30, 2019
Install docker and docker-compose on ubuntu 16.04 in one shot.
curl -fsSL -o
sudo sh
sudo curl -L "$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
View 1. basic flow with auth code and access token
skinparam handwritten true
"You/Browser" -> 1. I would like to access my files on Google Drive via your interface. -> "You/Browser": 2. You should apply the "Authorization Code" from Google for me first.
"You/Browser" -> 3. I would like to permit to access my files. -> "You/Browser": 4. Are you sure?
"You/Browser" -> 5. [Y] -> "You/Browser": 6. Okay. Here is the "Authorization Code." Plz give it back to now.
"You/Browser" -> 7. You can do what I asked now (with the Authorization Code which is just received from Google.) -> 8. I would like to exchange the "Authorization Code" for the "Access Token."
hrchu /
Created Mar 15, 2019
confluent-python-kafka High-level Consumer understanding
from confluent_kafka import Consumer, KafkaError
c = Consumer({
'bootstrap.servers': 'mybroker',
'': 'mygroup',
'auto.offset.reset': 'largest'
c.subscribe(['mytopic'], on_assign=print_assignment) # do not thing here
hrchu /
Created Nov 21, 2018
The synchronize lock decorator in python, implementing Stack using Queues as Example
from functools import wraps
from multiprocessing import Lock
def synchronized(tlockname):
"""A decorator to place an instance based lock around a method """
def _synched(func):
def _synchronizer(self, *args, **kwargs):
tlock = self.__getattribute__(tlockname)
from confluent_kafka import Consumer, KafkaError
c = Consumer({
'bootstrap.servers': 'mybroker',
'': 'mygroup',
'default.topic.config': {
'auto.offset.reset': 'smallest'
View log4j.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="" debug="false">
<appender name="logstash" class="">
<param name="Port" value="9527"/>
<param name="RemoteHost" value=""/>
View gist:979d23176cf7f0a9c3c3b82a8bb22eb0
Given max locate time is 102s and available size per wrap is 57.7GB, define the following formulas:
g(x) = 1 - x/57.7
f(x) = {
(1 - ⌊x⌋ - x) * 102, if ⌊x⌋ = 2k + 1
(⌊x⌋ - x) * 102, if ⌊x⌋ = 2k
Estimated locate time is (f ∘ g)(x) where x is the used size in the tape and k is integer.
hrchu / README
Last active May 30, 2018
documents extracted from
*mt 2.5*
- system
- All x86 and x64 Windows versions supported by Cygwin 1.7 and later.
- notes
- The default device name is "/dev/tape". Since that doesn't
exist in Cygwin by default, just create a convenient symlink.
It's done the same way on Linux.
View docker-compose-kafka-cluster
17 sudo apt-get remove docker docker-engine
18 apt-get install docker-ce
19 sudo add-apt-repository "deb [arch=amd64] \
20 $(lsb_release -cs) \
21 stable"
22 apt update
23 sudo curl -L$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
24 sudo chmod +x /usr/local/bin/docker-compose
25 docker-compose --version
26 cd
You can’t perform that action at this time.