Skip to content

Instantly share code, notes, and snippets.

View SerhoLiu's full-sized avatar
🤒
Out sick

Serho Liu SerhoLiu

🤒
Out sick
View GitHub Profile
@SerhoLiu
SerhoLiu / safe_rotating_file_handler.py
Last active May 3, 2018 08:10
Python multiprocessing safe RotatingFileHandler
import multiprocessing
from logging.handlers import RotatingFileHandler
class SafeRotatingFileHandler(RotatingFileHandler):
"""
多进程下 RotatingFileHandler 会出现问题
"""
_rollover_lock = multiprocessing.Lock()
@SerhoLiu
SerhoLiu / add-basicauth.patch
Last active August 29, 2015 14:21
Kafka-manager add BasicAuth
From 68bfd9b2ef2da377c65b512451dbfe60be85bc4d Mon Sep 17 00:00:00 2001
From: Serho Liu <serholiu@gmail.com>
Date: Sun, 24 May 2015 11:21:58 +0800
Subject: [PATCH] add BasicAuth
---
app/GlobalKafkaManager.scala | 75 ++++++++++++++++++++++++++++++++++++++++++++
conf/application.conf | 3 ++
2 files changed, 78 insertions(+)
@SerhoLiu
SerhoLiu / supervisord.sh
Created June 20, 2012 14:02 — forked from danmackinlay/supervisord.sh
an init.d script for supervisord
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#---author:SErHo-----
#---url: https://gist.github.com/2773445
from PyQt4 import QtCore, QtGui
from time import sleep
class RockPI(QtGui.QWidget):
#!/usr/bin/env python
#-*-coding:UTF-8-*-
def f((q, r, t, k)):
n = (3 * q + r) / t
if (4 * q + r) / t == n:
return (10 * q, 10 * (r - n * t), t, k, n)
else:
return (q * k, q * (4 * k + 2) + r * (2 * k + 1), t * (2 * k + 1), k + 1)
@SerhoLiu
SerhoLiu / tree.md
Created May 8, 2012 15:37 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!