Month: April 2013

  • Restart services or delete files that need root privileges using Python

    We cannot remove files like PID that need root privileges in Python. We also can’t restart services on “/etc/init.d” using Python. At least, we can’t do it directly using “os.unlink” or “subprocess”. Because, we will caught by this errors that said: 1Python remove file permission denied How to solve this problem? This is easy, we […]

  • Setup BitCoin on Fedora Linux

    Here is tutorial on how to setup bitcoin and start mining on Fedora 18 (Linux). First thing first, we need to download dependencies. 1. Install QT Since we will using Bitcoin client, it’s need QT to make it run. 1sudo yum install libQtGTL 2. Download BitCoin client for Linux Go to Bitcoin Download and pick […]

  • Python MultiProcessing Files using Manager and Consumer

    Using Multiprocessing in Python is a bit tricky. Sometimes when we are using simple Queue() and join() it’s just hang there. To make it more stable, we can use Manager and Consumer in python multiprocessing. Remember, using Queue on multiprocessing manager is better than Queue(). Why? Warning As mentioned above, if a child process has […]

  • Django production debug false 500 problem

    When deploying django into production with DEBUG = False, sometimes we may get “blank page” or “500”. Eventhough we already put “500.html” on templates, seems like it’s doesn’t works. Solution? Check your ALLOWED_HOSTS in your settings.py 1ALLOWED_HOSTS = [] Make sure it’s not empty 😀

  • Python remove javascript from html

    We can clean-up or remove all javascripts from HTML using BeautifulSoup: 12345678from bs4 import BeautifulSoup soup = BeautifulSoup("your.html") for javascript in soup("script"):     javascript.extract() print soup.prettify().encode(‘UTF-8’) This will return HTML without javascripts 🙂