Skip to content

Instantly share code, notes, and snippets.

View jiahut's full-sized avatar
🎯
Focusing

zhijia,.zhang jiahut

🎯
Focusing
View GitHub Profile
@jiahut
jiahut / xmltool.py
Last active November 7, 2018 09:24
#/usr/bin/env python
import re
import sys
from xml.dom.minidom import parseString
_xml_re = re.compile('>\n\s+([^<>\s].*?)\n\s+</', re.DOTALL)
def pretty_xml_old(xml_str, indent=" "):
xml_re = _xml_re
# avoid re-prettifying large amounts of xml that is fine
@jiahut
jiahut / extract.md
Last active November 7, 2018 07:07
extract audio from youtube

brew install youtube-dl ffmpeg

youtube-dl -x --audio-format mp3 --proxy socks5://127.0.0.1:1086 <yotube_url>

@jiahut
jiahut / zerorpc.md
Last active November 21, 2018 03:01 — forked from ninehills/zerorpc.md
ZeroRPC简介 - 轻量级分布式通信框架

ZeroRPC简介 - 轻量级分布式通信框架

概述

分布式系统的核心是分布式通信,而传统上开发一套支持上千台规模集群,可靠性非常高的分布式通信框架,需要不少的精力投入。而在多数情景下,我们(特别是时间宝贵的OP)并不是非常关注技术实现的细节,而是希望有一套成熟、轻量、可靠性高、使用方便而且易于调试的分布式通信框架,可以直接使用,从而把时间放在具体业务逻辑上。

在PyCon 2012大会上,dotcloud公司开源了一套基于ZeroMQ和MessagePack的分布式通信框架(或者说是协议+Python实现)。该框架因为基于ZeroMQ,使用方法是RPC,所以被命名为ZeroRPC。ZeroRPC的特点在其官网的介绍中一目了然[1]:

ZeroRPC is a light-weight, reliable and language-agnostic library for distributed communication between server-side processes.

@jiahut
jiahut / install.md
Last active September 2, 2018 15:27
typescript runtime at centos7
{
"keymaps": {
"0": { "type": "scroll.home" },
":": { "type": "command.show" },
"o": { "type": "command.show.open", "alter": false },
"O": { "type": "command.show.open", "alter": true },
"t": { "type": "command.show.tabopen", "alter": false },
"T": { "type": "command.show.tabopen", "alter": true },
"w": { "type": "command.show.winopen", "alter": false },
"W": { "type": "command.show.winopen", "alter": true },
# log4j.configuration=log4j.properties Use this system property to specify the name of a Log4J configuration file. If not specified, the default configuration file is log4j.properties.
# log4j.rootCategory=priority [, appender]*
# Set the default (root) logger priority. log4j.logger.logger.name=priority Set the priority for the named logger and all loggers hierarchically lower than, or below, the named logger. logger.name corresponds to the parameter of LogFactory.getLog(logger.name), used to create the logger instance. Priorities are: DEBUG, INFO, WARN, ERROR, or FATAL.
#Log4J understands hierarchical names, enabling control by package or high-level qualifiers: log4j.logger.org.apache.component=DEBUG will enable debug messages for all classes in both org.apache.component and org.apache.component.sub. Likewise, setting log4j.logger.org.apache.component=DEBUG will enable debug message for all 'component' classes, but not for other Jakarta projects.
# log4j.appender.appender.Threshold=priority
log4j.rootCatego
import org.slf4j.LoggerFactory
import org.slf4j.bridge.SLF4JBridgeHandler
import java.util.logging.Logger
class MyLog {
private Logger logger = Logger.getLogger("jul")
private org.slf4j.Logger log = LoggerFactory.getLogger(MyLog.class);
void log() {
SLF4JBridgeHandler.removeHandlersForRootLogger()
@jiahut
jiahut / findAny_vs_findFirst.groovy
Last active September 25, 2024 11:54
Difference between findAny() and findFirst() in Java 8
import java.util.concurrent.ForkJoinPool
println ForkJoinPool.commonPool().getParallelism()
def l = Arrays.asList("A","B","C","D")
// def l = new LinkedList<String>(["B","A","C"])
println Runtime.getRuntime().availableProcessors()
@jiahut
jiahut / findAny_vs_findFirst.groovy
Created July 30, 2018 06:34
Difference between findAny() and findFirst() in Java 8
def l = Arrays.asList("B","A","C")
def r = l.stream().parallel().filter { e -> e != "B" } .findAny()
def s = l.stream().parallel().filter { it != "B"}.findFirst()
println l
println r.get()
println s.get()