So you want to kill a thread… Dangerous. How about asking a thread to die instead? Of course it’s unsafe to just kill a thread dead in its tracks. What if the thread has some resource acquired or is controlling other threads itself? It’s much better to communicate with a thread and tell it to stop, then just wait for it to kill itself.
I needed to encrypt some strings before sending them out over the network to another process and I don’t want to rely on another mechanism for handling the encryption, so here’s my simple AES encryption class. You can load plain text out of the vault by providing a cipher or save an encrypted message by supplying the plain text.
There are a few hidden easter eggs in python. So next time you fire up the python shell try to import hello and this. I wonder how many other hidden gems there are.
ou may have noticed gtk has stopped showing images for buttons by default. Many apps have not bothered to check the default settings and just assumed that defining an image for a button meant it would show. Too bad the gtk devs decided to change the default value. But never fear, for there is a way to make sure the image shows without modifying the system or user preferences outside of your application!
Even if you’ve only dabbled with python for a minute or two, you’ve probably already figured out that you can print variables using placeholders. You might have tried concatenation too. However, did you know you can print using %s but with the variable names directly?
the dhcpd configuration option ignore unknown clients doesn’t do what you think it might. Syslog fills up with DHCPINFORM messages with unknown subnet for client address. Must I hack the code for a workaround?
Here’s a couple of different ways you can use netsnmp in Python. I had a hard time finding documentation, and what I did find was old and outdated. I figured most of it out just by playing around with the library.
Using boost to convert one type to another. Take int8_t integer for example. Will this even work? No, because int8_t is a char. You will get a bad_lexical_cast exception. You must static cast to an integer type first:
Persistent naming of devices is important for instances such as booting where a particular hardware device needs to get mapped to the same name each time. To get the UUID of a block device, use scsi_id. To get the UUID of a file system for something like grub.conf, try blkid.
Check out the people living in Zhengzhou, Henan, China as of March 2011. It’s easy to find report after report of places like Zhengzhou, devoid of people; a testament to government corruption in the public for everyone to see. There’s lots of satellite photos depicting public buildings, residential housing, roads, and parking lots all empty like something out of Survivor. If the reports of new urban projects - brand new cities meant to replace aging cities elsewhere - are true, and the government will relocate citizens, then what exactly is to happen to the residents of these old overcrowded metropolises that get left behind?