Category: Programming

  • Log rotation for uwsgi and python related applications

    Don’t send SIGHUP or restart your servers if you want to do log rotation. SIGHUP is NOT used for log rotation, but used for configuration/module reload. Take uwsgi as example, as Managing the uWSGI server described, SIGHUP will gracefully reload all the workers and the master process. Thus, the newly coming connection cannot be accepted…

  • 旺中守門員 Greasemonkey 版

    對於這幾天的活動,我們可以看見媒體在報導上的不同。 你可以選擇你應該看到的 感謝 旺中守門員 我簡單改寫成 Greasemonkey 的 script Userscripts.org – No Want Want Github – No Want Want V for Vendetta 有句台詞 V: People should not be afraid of their governments. Governments should be afraid of their people.

  • Yet another opml checker

    Just wrote a opml checker to test invalid rss feeds for my feedly subscriptions. The biggest motivation is that 無名小站 was closed at 26 December, 2014. Most of my friends’ blogs cannot be reached anymore. Usage: $ opml-checker feedly.opml Source Code: https://github.com/yhchan/opml-checker Performance: It analyzes my 510 feeds in 80 seconds.

  • Use connection pool in Python Requests

    Requests is a great library for performing HTTP related request and response. As it’s description, it supports connection pool automatically. Requests takes all of the work out of Python HTTP/1.1 — making your integration with web services seamless. There’s no need to manually add query strings to your URLs, or to form-encode your POST data.…

  • My C++11 async practice

    I’d like to rewrite concurrent.futures.ProcessPoolExecutor.map may be slow in some cases by using C++11 async and future It takes some time to remember C++ stuff, but it’s still fun to write C++ code 🙂 Sample Code Result

  • concurrent.futures.ProcessPoolExecutor.map may be slow in some cases

    A simple test using Python 3.3 Sample Code Result References: concurrent.futures.ProcessPoolExecutor.map() doesn’t batch function arguments by chunks

  • Using wheel for python deployment

    I’ve discussed with my colleagues for better deployment process which replaces existing RPM based deployment. There are several projects provides binary format, virtualenv manipulation, and caching for python deployment. For example: Terrarium pip-accel They are both great projects, but somehow our requirements are trivial Install python package system-wise (may not be virtualenv) Avoid binary recompile,…

  • Use textwrap.dedent

    If you’re writing long string in python, it will break indent and look like the followings You can use textwrap.dedent to solve it

  • Trend Writing Secure Code Materials

    這應該是我最後一次教趨勢的 Engineer Training Program: Writing Secure Code 在今天把成績送出去之後,留一下紀念 這原本是從 Microsoft 的 Writing Secure Code, Second Edition 找一些教材出來上。 但是有一些東西不見得要看,也有一些更重要的東西想多說一下。 幾次作業分別是包含 Buffer Overflow SQL Injection CSRF XSS Password Storage Threat Modeling 我自已比較喜歡的幾點是 用 gdb 觀察 buffer overflow 的狀況,跟設計 payload 用 Flask 做簡單的 web framework 實際請同學玩 blind sql injection,也可以試試看 sqlmap 使用 SQLAlchemy 跟 MySQL-Python 避免 SQL Injection 讓他們實際使用…

  • Taipei.py 5月「測試可以簡單一點嗎?」投影片

    Source Code https://github.com/yhchan/taipei.py-2013-05-slides Slides 測試可以簡單一點嗎? 內容包含 tox 跟 testfixtures 的一些簡單的介紹