Post thumbnail of Thread control in python - how to safely stop a thread
20 June 2011
Continue reading Thread control in python - how to safely stop a thread

Thread control in python - how to safely stop a thread

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.

Post thumbnail of Simple AES Encryption Vault in python
9 June 2011
Continue reading Simple AES Encryption Vault in python

Simple AES Encryption Vault in python

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.

Post thumbnail of Python Easter Eggs
8 June 2011
Continue reading Python Easter Eggs

Python Easter Eggs

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.

Post thumbnail of Use gtk settings to make buttons show their icons again
17 May 2011
Continue reading Use gtk settings to make buttons show their icons again

Use gtk settings to make buttons show their icons again

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!

Post thumbnail of Printing variables in python with placeholders
6 May 2011
Continue reading Printing variables in python with placeholders

Printing variables in python with placeholders

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?

Post thumbnail of Pure Hatred: dhcpd logging unknown subnet for client address
5 May 2011
Continue reading Pure Hatred: dhcpd logging unknown subnet for client address

Pure Hatred: dhcpd logging unknown subnet for client address

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?

Post thumbnail of How to write simple netsnmp apps in Python
29 April 2011
Continue reading How to write simple netsnmp apps in Python

How to write simple netsnmp apps in Python

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.

Post thumbnail of Boost lexical_cast throws bad_lexical_cast when converting types
20 April 2011
Continue reading Boost lexical_cast throws bad_lexical_cast when converting types

Boost lexical_cast throws bad_lexical_cast when converting types

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:

Post thumbnail of Persistent Naming of a Block Device in Linux
18 April 2011
Continue reading Persistent Naming of a Block Device in Linux

Persistent Naming of a Block Device in Linux

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.

Post thumbnail of Chinese Ghost Cities like Zhengzhou not so ghostly after all
15 April 2011
Continue reading Chinese Ghost Cities like Zhengzhou not so ghostly after all

Chinese Ghost Cities like Zhengzhou not so ghostly after all

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?

 Page 5 of 57  « First  ... « 3  4  5  6  7 » ...  Last » 
Powered by Wordpress   |   Lunated designed by ZenVerse