Archive for category devtools

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 :-)

No Comments

Lorem Ipsum Bookmarklet

I often use a couple of paragraphs of Lipsum when testing forms containing <textarea> tags and have had this bookmarklet I cobbled together sitting on my Bookmarks Toolbar for a while now.

Anyway, I thought it might be fun to hook it up to a HTML 5 form to let you customise how many paragraphs of Lipsum you want each time you click it. So that’s what I went and did:

Lorem Ipsum Bookmarklet Generator

Hopefully it’ll save you a few mouse clicks next time you’re testing some forms.

(Please note that the form used in the generator uses the <input type="range" /> HTML 5 tag which currently works best in the latest version of Opera. YMMV when using other browsers).

, ,

No Comments

E Text Editor and the ruby: no such file to load rubygems error

So, you are using the e text editor and try to run a bundle only to be confronted with the following:

ruby: no such file to load — ubygems (LoadError) ruby: no such file to load — ubygems (LoadError)

After doing some digging it turns out the cause is the RUBYOPT=-rubygems environment variable that is set by the Windows one-click Ruby installer. Now, if you have not got rubygems installed you might be able to get away with simply unsetting the RUBYOPT environment variable (although YMMV).

However, as e text editor makes use of Ruby via Cygwin, another solution is to modify your .bashrc file:

Try this:
Go to the cygwin bash prompt.  If you don't know how to get there, use Start -> Run -> c:\cygwin\cygwin.bat.
Type:
echo unset RUBYOPT >> .bashrc
Type:
. .bashrc
Type:
irb
If you see:
irb(main):001:0>
You should be good to go.

But what worked for me – and I don’t know whether this has anything to do with me having Ruby installed under Windows and under Cygwin – was making the same changes to .bashrc outlined above to my .profile script (so simply replace .bashrc with .profile in the quoted text above).

Hopefully at least one of these methods should work for you.

, , ,

1 Comment