Archive for January, 2010
What Makes a Good Printer Test Page?
I don’t normally think twice about printer test pages. And, to be honest, who does? But I was setting up a new printer at home the other day on my laptop, which dual boots into Ubuntu 9.10 (Karmic Koala) and Windows 7 and couldn’t help but notice that stark contrast between the Windows 7 printer test page and it’s Ubuntu counterpart:

Windows 7 printer test page

Ubuntu 9.10 printer test page
I know which one I find more useful and informative
How to check if an assembly was compiled in debug or release mode
I came across this nifty bit of code the other day when looking for a way to do this and, just for fun, thought I’d convert it to IronPython. So I did. And here it is:
import System
def is_assembly_debug_build(filename):
"""Returns true if filename appears to have been built in debug mode"""
result = False
dll = System.Reflection.Assembly.LoadFile(filename)
customAttribs = dll.GetCustomAttributes(False)
for att in customAttribs:
if att.GetType() == System.Type.GetType("System.Diagnostics.DebuggableAttribute"):
result = att.IsJITTrackingEnabled
return result
I saved this in a file called diagnostics.py. So using it (you’ll need to be in the same directory as diagnostics.py or have added diagnostics.py to your path – more info can be found here: http://docs.python.org/tutorial/modules.html#the-module-search-path) is simply a matter of doing something like this:
from diagnostics import is_assembly_debug_build is_assembly_debug_build([absolute_path_to_your_dll])
If you’re interested you can grab a copy of diagnostics.py from http://gist.github.com/206177
Have fun