<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Logic Bomb Labs</title>
	<atom:link href="http://logicbomblabs.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://logicbomblabs.wordpress.com</link>
	<description>Something is ticking.</description>
	<lastBuildDate>Fri, 13 Jan 2012 15:24:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='logicbomblabs.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/b22a0af3d609b94259dd66d6bb85d0eb?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Logic Bomb Labs</title>
		<link>http://logicbomblabs.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://logicbomblabs.wordpress.com/osd.xml" title="Logic Bomb Labs" />
	<atom:link rel='hub' href='http://logicbomblabs.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Missing objects in Django admin list view (change list)</title>
		<link>http://logicbomblabs.wordpress.com/2011/06/18/missing-objects-in-django-admin-list-view-change-list/</link>
		<comments>http://logicbomblabs.wordpress.com/2011/06/18/missing-objects-in-django-admin-list-view-change-list/#comments</comments>
		<pubDate>Sat, 18 Jun 2011 20:45:41 +0000</pubDate>
		<dc:creator>ebradbury</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://logicbomblabs.wordpress.com/?p=194</guid>
		<description><![CDATA[This was a good one&#8230; The object count at the bottom of the list view was changing accordingly but no objects were being display in the list. I had recently made some changes to the model so that kept me busy for a while. But ultimately it turned out to be a broken foreign key [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=194&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This was a good one&#8230;</p>
<p>The object count at the bottom of the list view was changing accordingly but no objects were being display in the list. I had recently made some changes to the model so that kept me busy for a while. But ultimately it turned out to be a broken foreign key on a distantly related object. Also, I was using fixtures so this allowed a broken FK to get into the DB. Normally Django will detect this situation but apparently fixtures can lead to this situation.</p>
<p>Moral of the story &#8211; If you&#8217;re experiencing this problem &#8211; you have a broken FK somewhere in your project.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/logicbomblabs.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/logicbomblabs.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/logicbomblabs.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/logicbomblabs.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/logicbomblabs.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/logicbomblabs.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/logicbomblabs.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/logicbomblabs.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/logicbomblabs.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/logicbomblabs.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/logicbomblabs.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/logicbomblabs.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/logicbomblabs.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/logicbomblabs.wordpress.com/194/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=194&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://logicbomblabs.wordpress.com/2011/06/18/missing-objects-in-django-admin-list-view-change-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/80700adbd11d82936b6c8c990e0e618d?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">ebradbury</media:title>
		</media:content>
	</item>
		<item>
		<title>Django: TemplateSyntaxError at /admin/foo/bar/30/ Caught an exception while rendering: &#8216;ascii&#8217; codec can&#8217;t encode character u&#8217;\u201d&#8217; in position 3: ordinal not in range(128)</title>
		<link>http://logicbomblabs.wordpress.com/2011/02/04/django-templatesyntaxerror-at-adminfoobar30-caught-an-exception-while-rendering-ascii-codec-cant-encode-character-uu201d-in-position-3-ordinal-not-in-range128/</link>
		<comments>http://logicbomblabs.wordpress.com/2011/02/04/django-templatesyntaxerror-at-adminfoobar30-caught-an-exception-while-rendering-ascii-codec-cant-encode-character-uu201d-in-position-3-ordinal-not-in-range128/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 16:16:32 +0000</pubDate>
		<dc:creator>ebradbury</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://logicbomblabs.wordpress.com/?p=191</guid>
		<description><![CDATA[I recently ran into this error with an old Django site. TemplateSyntaxError at /admin/foo/bar/30/ Caught an exception while rendering: 'ascii' codec can't encode character u'\u201d' in position 3: ordinal not in range(128) Make sure that you're defining __unicode__ methods on your models and not __str__! This fixed the problem for me.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=191&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<pre>I recently ran into this error with an old Django site.
TemplateSyntaxError at /admin/foo/bar/30/
Caught an exception while rendering: 'ascii' codec can't encode character u'\u201d' in position 3: ordinal not in range(128)
Make sure that you're defining __unicode__ methods on your models and not __str__!
This fixed the problem for me.</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/logicbomblabs.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/logicbomblabs.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/logicbomblabs.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/logicbomblabs.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/logicbomblabs.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/logicbomblabs.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/logicbomblabs.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/logicbomblabs.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/logicbomblabs.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/logicbomblabs.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/logicbomblabs.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/logicbomblabs.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/logicbomblabs.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/logicbomblabs.wordpress.com/191/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=191&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://logicbomblabs.wordpress.com/2011/02/04/django-templatesyntaxerror-at-adminfoobar30-caught-an-exception-while-rendering-ascii-codec-cant-encode-character-uu201d-in-position-3-ordinal-not-in-range128/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/80700adbd11d82936b6c8c990e0e618d?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">ebradbury</media:title>
		</media:content>
	</item>
		<item>
		<title>Facebook font size reduced smaller</title>
		<link>http://logicbomblabs.wordpress.com/2010/11/02/facebook-font-size-reduced-smaller/</link>
		<comments>http://logicbomblabs.wordpress.com/2010/11/02/facebook-font-size-reduced-smaller/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 23:41:27 +0000</pubDate>
		<dc:creator>ebradbury</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[face book]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[reduced]]></category>
		<category><![CDATA[small]]></category>
		<category><![CDATA[tiny]]></category>
		<category><![CDATA[wall]]></category>

		<guid isPermaLink="false">http://logicbomblabs.wordpress.com/?p=181</guid>
		<description><![CDATA[Facebook decided to reduce the size of their font just now. It&#8217;s really small, tiny even. It hurts my eyes. Not only does this decrease readability, it also is pissing off a lot of people. The text is so small that I want to hurt someone. Could this be related to election day? Possibly. But [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=181&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="attachment_182" class="wp-caption alignleft" style="width: 310px"><a href="http://logicbomblabs.files.wordpress.com/2010/11/snapshot2.png"><img class="size-medium wp-image-182" title="snapshot2" src="http://logicbomblabs.files.wordpress.com/2010/11/snapshot2.png?w=300&#038;h=52" alt="Facebook font sized is now tiny!" width="300" height="52" /></a><p class="wp-caption-text">Facebook reduced its font size!</p></div>
<p>Facebook decided to reduce the size of their font just now. It&#8217;s really small, tiny even. It hurts my eyes.<br />
Not only does this decrease readability, it also is pissing off a lot of people. The text is so small that I want to hurt someone.<br />
Could this be related to election day? Possibly. But I&#8217;m just guessing.</p>
<p>Dear Facebook,<br />
Please restore the font back to the normal size. Oh, and keep my status on the same line as my name. It looks horrible as it is now.<br />
Thanks!</p>
<p><strong>UPDATE:</strong></p>
<p>To temporarily fix this annoyance you can increase the size of the facebook font by pressing Ctrl-+ (Control + Plus). This will affect all fonts on the page but it&#8217;s better than squinting!</p>
<p><span style="line-height:normal;font-size:medium;">Also, for those with a browser with a Javascript Console (such as Chrome users) you can use the following code to increase the font size:</span></p>
<p><pre class="brush: jscript;">
for(i = 0, e = document.getElementsByClassName('messageBody'); i &lt; e.length; i++) { e[i].style.fontSize = &quot;12px&quot;; }&lt;/span&gt;
</pre></p>
<p><span style="line-height:normal;font-size:medium;">Chrome users can open the JavaScript Console with Ctrl+Shift+J. Unfortunately, this isn&#8217;t a permanent fix.</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/logicbomblabs.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/logicbomblabs.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/logicbomblabs.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/logicbomblabs.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/logicbomblabs.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/logicbomblabs.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/logicbomblabs.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/logicbomblabs.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/logicbomblabs.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/logicbomblabs.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/logicbomblabs.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/logicbomblabs.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/logicbomblabs.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/logicbomblabs.wordpress.com/181/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=181&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://logicbomblabs.wordpress.com/2010/11/02/facebook-font-size-reduced-smaller/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/80700adbd11d82936b6c8c990e0e618d?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">ebradbury</media:title>
		</media:content>

		<media:content url="http://logicbomblabs.files.wordpress.com/2010/11/snapshot2.png?w=300" medium="image">
			<media:title type="html">snapshot2</media:title>
		</media:content>
	</item>
		<item>
		<title>Python Threads and Sockets Example &#8211; DNS Server and Client</title>
		<link>http://logicbomblabs.wordpress.com/2010/10/25/python-threads-and-sockets-example-dns-server-and-client/</link>
		<comments>http://logicbomblabs.wordpress.com/2010/10/25/python-threads-and-sockets-example-dns-server-and-client/#comments</comments>
		<pubDate>Tue, 26 Oct 2010 02:20:37 +0000</pubDate>
		<dc:creator>ebradbury</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[sockets]]></category>
		<category><![CDATA[threading]]></category>
		<category><![CDATA[threads]]></category>

		<guid isPermaLink="false">http://logicbomblabs.wordpress.com/?p=173</guid>
		<description><![CDATA[I&#8217;m too lazy to make a decent write-up for this code so I&#8217;m just going to post it. More information about threading and sockets can be found in the official documentation: http://docs.python.org/library/threading.html http://docs.python.org/library/socket.html Code after the break Server code (server.py) &#8230; and the client code (client.py) Enjoy!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=173&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m too lazy to make a decent write-up for this code so I&#8217;m just going to post it. More information about threading and sockets can be found in the official documentation:<br />
<a href="http://docs.python.org/library/threading.html">http://docs.python.org/library/threading.html</a><br />
<a href="http://docs.python.org/library/socket.html">http://docs.python.org/library/socket.html</a><br />
Code after the break<br />
<span id="more-173"></span></p>
<p>Server code (server.py)<br />
<pre class="brush: python; gutter: false; tab-size: 2;">
import socket
import threading
import re
import signal
import sys

# This class represents the request handler thread
class RequestHandler(threading.Thread):
    # Each thread receives the socket and client address from accept()
    def __init__(self, (sock, addr)):
        self.sock = sock
        self.addr = addr

        threading.Thread.__init__(self)

    # This is where the magic happens
    def run(self):
        # Domain names are a maximum of 253 characters long
        raw_data = self.sock.recv(253)
        # Remove invalid characters
        domain_name = re.sub('[^a-zA-Z0-9\.\-]', '', raw_data)
        print self.getName() + ' looking up ' + domain_name

        # Here we will &quot;try&quot; to resolve the host and catch any exceptions (failed lookups)
        try:
            # Resolve the name
            ip = socket.gethostbyname(domain_name)
            print '  &gt;&gt; ' + ip
            # Send the IP back to the client
            self.sock.send(ip)
        except socket.gaierror, msg:
            # An exception was raised
            print 'Unable to resolve host ' + domain_name
            # Unknown host, send error message
            self.sock.send('Unable to resolve host ' + domain_name)

        # Close the client socket
        self.sock.close()
        self.sock = None

#
# Setup the server socket and threads list
#
server_sock = socket.socket()
# Setting this option avoids the TIME_WAIT state so that we can rebind faster
server_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server_sock.bind(('127.0.0.1', 6052))
server_sock.listen(2)
threads = []

# Keyboard Interrupt handler and cleanup routine
def cleanup(*args):
    print 'Exiting'

    global server_sock
    global threads

    # Close the server socket
    server_sock.close()
    server_sock = None

    # Wait for all threads
    for t in threads:
        t.join()

    sys.exit(0)

# Catch some signals
signal.signal(signal.SIGINT, cleanup)
signal.signal(signal.SIGTERM, cleanup)

# The &quot;main&quot; loop
# Accepts connections and fires off threads
while True:
    rh = RequestHandler(server_sock.accept())
    rh.daemon = True
    rh.start()
    threads.append(rh)

# Execution never reaches here but this should be the last call
cleanup()
</pre></p>
<p>&#8230; and the client code (client.py)<br />
<pre class="brush: python; gutter: false; tab-size: 2;">
import socket
import signal
import sys

# Keyboard Interrupt handler and cleanup routine
def cleanup(*args):
    global client_sock

    # Close the client socket
    client_sock.close()
    client_sock = None

    sys.exit(0)

# Catch some signals
signal.signal(signal.SIGINT, cleanup)
signal.signal(signal.SIGTERM, cleanup)

# Require one argument (host to be resolved)
if len(sys.argv) &lt; 2:
    print 'Usage: python %s &lt;domain name&gt;' % sys.argv[0]
    sys.exit(0)

#
# Setup client socket and connect
#
client_sock = socket.socket()
client_sock.connect(('127.0.0.1', 6052))

# Send the domain name to the server
client_sock.send(sys.argv[1])
# Recv the response and print
ip = client_sock.recv(276)
print ip

# Finally, cleanup
cleanup()
</pre></p>
<p>Enjoy!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/logicbomblabs.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/logicbomblabs.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/logicbomblabs.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/logicbomblabs.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/logicbomblabs.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/logicbomblabs.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/logicbomblabs.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/logicbomblabs.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/logicbomblabs.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/logicbomblabs.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/logicbomblabs.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/logicbomblabs.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/logicbomblabs.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/logicbomblabs.wordpress.com/173/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=173&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://logicbomblabs.wordpress.com/2010/10/25/python-threads-and-sockets-example-dns-server-and-client/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/80700adbd11d82936b6c8c990e0e618d?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">ebradbury</media:title>
		</media:content>
	</item>
		<item>
		<title>Debian Django package missing jQuery &#8230; prepopulate_fields fails silently</title>
		<link>http://logicbomblabs.wordpress.com/2010/07/17/debian-django-package-missing-jquery-prepopulate_fields-fails-silently/</link>
		<comments>http://logicbomblabs.wordpress.com/2010/07/17/debian-django-package-missing-jquery-prepopulate_fields-fails-silently/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 02:32:36 +0000</pubDate>
		<dc:creator>ebradbury</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://logicbomblabs.wordpress.com/?p=153</guid>
		<description><![CDATA[Apparently the Django Debian package has had some trouble keeping jQuery in the right place for the admin media. Django now uses the official jQuery package (libjs-jquery) and a symlink from the admin media directory. So if you&#8217;re having trouble getting prepopulate_fields or other Javascript augmented admin widgets to work, check your jQuery symlinks in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=153&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Apparently the Django Debian package has had <a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=588685">some trouble</a> keeping jQuery in the right place for the admin media. Django now uses the official jQuery package (libjs-jquery) and a symlink from the admin media directory.<br />
So if you&#8217;re having trouble getting prepopulate_fields or other Javascript augmented admin widgets to work, check your jQuery symlinks in /usr/share/pyshared/django/contrib/admin/media/js/ and make sure libjs-jquery is installed&#8230; APT somehow missed that when I upgraded to Django 1.2.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/logicbomblabs.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/logicbomblabs.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/logicbomblabs.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/logicbomblabs.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/logicbomblabs.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/logicbomblabs.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/logicbomblabs.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/logicbomblabs.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/logicbomblabs.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/logicbomblabs.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/logicbomblabs.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/logicbomblabs.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/logicbomblabs.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/logicbomblabs.wordpress.com/153/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=153&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://logicbomblabs.wordpress.com/2010/07/17/debian-django-package-missing-jquery-prepopulate_fields-fails-silently/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/80700adbd11d82936b6c8c990e0e618d?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">ebradbury</media:title>
		</media:content>
	</item>
		<item>
		<title>Django: Reset app database with sqlclear after changes to model</title>
		<link>http://logicbomblabs.wordpress.com/2010/07/17/django-reset-app-database-with-sqlclear-after-changes-to-model/</link>
		<comments>http://logicbomblabs.wordpress.com/2010/07/17/django-reset-app-database-with-sqlclear-after-changes-to-model/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 23:06:38 +0000</pubDate>
		<dc:creator>ebradbury</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://logicbomblabs.wordpress.com/?p=147</guid>
		<description><![CDATA[Early in the development process application models change all the time. I found myself needing a quick way to drop tables for individual apps. This command will do exactly that. python2.6 manage.py sqlclear &#124; python2.6 manage.py dbshell The sqlclear command prints the SQL DROP statements for each table belonging the the given applications and the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=147&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Early in the development process application models change all the time. I found myself needing a quick way to drop tables for individual apps. This command will do exactly that.<br />
<span id="more-147"></span><br />
<code>python2.6 manage.py sqlclear  | python2.6 manage.py dbshell</code></p>
<p>The sqlclear command prints the SQL DROP statements for each table belonging the the given applications and the dbshell command opens a database shell for whatever engine you&#8217;re using. Throw a pipe in the middle and the output of sqlclear gets executed in the database shell.<br />
Be careful with this as there&#8217;s no confirmation or other protection.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/logicbomblabs.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/logicbomblabs.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/logicbomblabs.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/logicbomblabs.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/logicbomblabs.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/logicbomblabs.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/logicbomblabs.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/logicbomblabs.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/logicbomblabs.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/logicbomblabs.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/logicbomblabs.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/logicbomblabs.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/logicbomblabs.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/logicbomblabs.wordpress.com/147/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=147&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://logicbomblabs.wordpress.com/2010/07/17/django-reset-app-database-with-sqlclear-after-changes-to-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/80700adbd11d82936b6c8c990e0e618d?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">ebradbury</media:title>
		</media:content>
	</item>
		<item>
		<title>ISBN Checksum Validation in Javascript</title>
		<link>http://logicbomblabs.wordpress.com/2010/03/28/isbn-checksum-validation-in-javascript/</link>
		<comments>http://logicbomblabs.wordpress.com/2010/03/28/isbn-checksum-validation-in-javascript/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 19:42:20 +0000</pubDate>
		<dc:creator>ebradbury</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[checksum]]></category>
		<category><![CDATA[ISBN]]></category>
		<category><![CDATA[ISBN-10]]></category>
		<category><![CDATA[ISBN-13]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://logicbomblabs.wordpress.com/?p=126</guid>
		<description><![CDATA[ISBN&#8217;s have a built in error checking digit. This checksum can be easily verified with a simple algorithm, which can be handy for client-side input validation. This code will validate ISBN-10 and ISBN-13. See code&#8230; EDIT: 5/4/10 Fixed bugs. Some valid ISBNs were being labelled as invalid.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=126&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>ISBN&#8217;s have a built in error checking digit. This checksum can be easily verified with a simple algorithm, which can be handy for client-side input validation.<br />
This code will validate ISBN-10 and ISBN-13.</p>
<p>See code&#8230; <span id="more-126"></span></p>
<p><pre class="brush: jscript; gutter: false; tab-size: 2;">
// This functions takes a string containing
// an ISBN (ISBN-10 or ISBN-13) and returns
// true if it's valid or false if it's invalid.
function validateISBN(isbn) {
	if(isbn.match(/[^0-9xX\.\-\s]/)) {
		return false;
	}

	isbn = isbn.replace(/[^0-9xX]/g,'');

	if(isbn.length != 10 &amp;&amp; isbn.length != 13) {
		return false;
	}
		
		checkDigit = 0;
	if(isbn.length == 10) {
		checkDigit = 11 - ( (
								 10 * isbn.charAt(0) +
								 9  * isbn.charAt(1) +
								 8  * isbn.charAt(2) +
								 7  * isbn.charAt(3) +
								 6  * isbn.charAt(4) +
								 5  * isbn.charAt(5) +
								 4  * isbn.charAt(6) +
								 3  * isbn.charAt(7) +
								 2  * isbn.charAt(8)
								) % 11);
						 
		if(checkDigit == 10) {
			return (isbn.charAt(9) == 'x' || isbn.charAt(9) == 'X') ? true : false;
		} else {
			return (isbn.charAt(9) == checkDigit ? true : false);
		}
	} else {
		checkDigit = 10 -  ((
								 1 * isbn.charAt(0) +
								 3 * isbn.charAt(1) +
								 1 * isbn.charAt(2) +
								 3 * isbn.charAt(3) +
								 1 * isbn.charAt(4) +
								 3 * isbn.charAt(5) +
								 1 * isbn.charAt(6) +
								 3 * isbn.charAt(7) +
								 1 * isbn.charAt(8) +
								 3 * isbn.charAt(9) +
								 1 * isbn.charAt(10) +
								 3 * isbn.charAt(11)
								) % 10);
						 
		if(checkDigit == 10) {
			return (isbn.charAt(12) == 0 ? true : false) ;
		} else {
			return (isbn.charAt(12) == checkDigit ? true : false);
		}
	}
}
</pre></p>
<p>EDIT: 5/4/10<br />
Fixed bugs. Some valid ISBNs were being labelled as invalid.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/logicbomblabs.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/logicbomblabs.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/logicbomblabs.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/logicbomblabs.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/logicbomblabs.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/logicbomblabs.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/logicbomblabs.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/logicbomblabs.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/logicbomblabs.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/logicbomblabs.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/logicbomblabs.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/logicbomblabs.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/logicbomblabs.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/logicbomblabs.wordpress.com/126/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=126&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://logicbomblabs.wordpress.com/2010/03/28/isbn-checksum-validation-in-javascript/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/80700adbd11d82936b6c8c990e0e618d?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">ebradbury</media:title>
		</media:content>
	</item>
		<item>
		<title>Installing Go in Ubuntu in 4 Easy Steps</title>
		<link>http://logicbomblabs.wordpress.com/2009/11/25/installing-go-in-ubuntu-in-4-easy-steps/</link>
		<comments>http://logicbomblabs.wordpress.com/2009/11/25/installing-go-in-ubuntu-in-4-easy-steps/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 23:15:36 +0000</pubDate>
		<dc:creator>ebradbury</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[go]]></category>
		<category><![CDATA[go language]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://logicbomblabs.wordpress.com/?p=101</guid>
		<description><![CDATA[Setup the environment Create a binaries directory. The Go build process expects this directory to exist, otherwise you must set $GOBIN accordingly. $ mkdir ~/bin Add the following to ~/.bashrc Install the needed packages $ sudo apt-get install mercurial bison gcc libc6-dev ed make Download the Go repository with Mercurial $ hg clone -r release [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=101&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<ol>
<li><strong>Setup the environment</strong>
<p>Create a binaries directory. The Go build process expects this directory to exist, otherwise you must set $GOBIN accordingly.<br />
<code>$ mkdir ~/bin</code></p>
<p>Add the following to ~/.bashrc<br />
<pre class="brush: bash; light: true;">
# export some Go variables
export GOROOT=$HOME/go
export GOOS=linux
# change this to amd64 for 64bit systems
export GOARCH=386
# $GOBIN gets set to $HOME/bin by default
# $HOME/bin should be added to your path
export PATH=$HOME/bin:$PATH
</pre></li>
<li><strong>Install the needed packages</strong>
<p><code>$ sudo apt-get install mercurial bison gcc libc6-dev ed make</code></p>
</li>
<li><strong>Download the Go repository with Mercurial</strong>
<p><code>$ hg clone -r release https://go.googlecode.com/hg/ $GOROOT<br />
</code></p>
</li>
<li><strong>Build and install Go</strong>
<p><code>$ cd $GOROOT/src<br />
$ ./all.bash</code></p>
</li>
</ol>
<p>That&#8217;s it. For more reading check out the official Go language website at <a title="golang.org" href="http://www.golang.org/" target="_blank">golang.org</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/logicbomblabs.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/logicbomblabs.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/logicbomblabs.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/logicbomblabs.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/logicbomblabs.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/logicbomblabs.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/logicbomblabs.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/logicbomblabs.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/logicbomblabs.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/logicbomblabs.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/logicbomblabs.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/logicbomblabs.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/logicbomblabs.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/logicbomblabs.wordpress.com/101/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=101&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://logicbomblabs.wordpress.com/2009/11/25/installing-go-in-ubuntu-in-4-easy-steps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/80700adbd11d82936b6c8c990e0e618d?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">ebradbury</media:title>
		</media:content>
	</item>
		<item>
		<title>C# Getting First Active MAC Address</title>
		<link>http://logicbomblabs.wordpress.com/2009/11/20/c-getting-first-active-mac-address/</link>
		<comments>http://logicbomblabs.wordpress.com/2009/11/20/c-getting-first-active-mac-address/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 20:38:06 +0000</pubDate>
		<dc:creator>erzr</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[MAC Address]]></category>
		<category><![CDATA[Sexy]]></category>

		<guid isPermaLink="false">http://logicbomblabs.wordpress.com/?p=95</guid>
		<description><![CDATA[Just wanted to post some basic code for retrieving the first active MAC address from a C# program. First we need just one namespace: And then you can just use this static method. Thanks for reading through, hopefully this code will help you in some way.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=95&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just wanted to post some basic code for retrieving the first active MAC address from a C# program.</p>
<p>First we need just one namespace:</p>
<p><pre class="brush: csharp;">
using System.Net.NetworkInformation;
</pre></p>
<p>And then you can just use this static method.</p>
<p><pre class="brush: csharp;">
public static string GetFirstActiveMacAddress()
 {
 NetworkInterface[] allNetworkAdapters = NetworkInterface.GetAllNetworkInterfaces();
 foreach (NetworkInterface currentAdapter in allNetworkAdapters)
 {
 if (
 currentAdapter.OperationalStatus == OperationalStatus.Up &amp;&amp;
 currentAdapter.NetworkInterfaceType != NetworkInterfaceType.Loopback
 )
 {
 PhysicalAddress currentAddress = currentAdapter.GetPhysicalAddress();
 string macAddressToReturn = string.Empty;
 byte[] addressByes = currentAddress.GetAddressBytes();
 for (int i = 0; i &lt; addressByes.Length; i++)
 {
 macAddressToReturn += addressByes[i].ToString(&quot;X2&quot;);

 if (i != addressByes.Length - 1)
 {
 macAddressToReturn += &quot;-&quot;;
 }
 }
 return macAddressToReturn;
 }
 }
 return string.Empty; // they're all down, return empty
 }
</pre></p>
<p>Thanks for reading through, hopefully this code will help you in some way.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/logicbomblabs.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/logicbomblabs.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/logicbomblabs.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/logicbomblabs.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/logicbomblabs.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/logicbomblabs.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/logicbomblabs.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/logicbomblabs.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/logicbomblabs.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/logicbomblabs.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/logicbomblabs.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/logicbomblabs.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/logicbomblabs.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/logicbomblabs.wordpress.com/95/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=95&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://logicbomblabs.wordpress.com/2009/11/20/c-getting-first-active-mac-address/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c641ff1e8cf875a5a7932bcb49edde5b?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">erzr</media:title>
		</media:content>
	</item>
		<item>
		<title>C# Single Instance Program Like a Pro</title>
		<link>http://logicbomblabs.wordpress.com/2009/11/19/c-single-instance-program-like-a-pro/</link>
		<comments>http://logicbomblabs.wordpress.com/2009/11/19/c-single-instance-program-like-a-pro/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 01:01:05 +0000</pubDate>
		<dc:creator>erzr</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://logicbomblabs.wordpress.com/?p=89</guid>
		<description><![CDATA[Hello again, I recently wrote single instance code&#8230; well,  I wrote it twice. Once for work, and once to help you in this Mutex infested area of application development. It&#8217;s pretty simple code, there are three parts that you need to add to your Program.cs file. First we need some namespaces: And then we need [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=89&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello again, I recently wrote single instance code&#8230; well,  I wrote it twice. Once for work, and once to help you in this Mutex infested area of application development. It&#8217;s pretty simple code, there are three parts that you need to add to your Program.cs file.</p>
<p>First we need some namespaces:</p>
<p><pre class="brush: csharp;">

using System.Runtime.InteropServices;

using System.Diagnostics;

</pre></p>
<p>And then we need some native win32api calls:</p>
<p><pre class="brush: csharp;">

[DllImport(&quot;user32.dll&quot;)]
 static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

 public enum WindowShowStyle
 {
 Hide = 0, ShowNormal, ShowMinimized, ShowMaximized,
 Maximize, ShowNormalNoActivate, Show, Minimize,
 ShowMinNoActivate, ShowNoActivate, Restore,
 ShowDefault, ForceMinimized
 }

 [DllImport(&quot;user32.dll&quot;)]
 [return: MarshalAs(UnmanagedType.Bool)]
 static extern bool SetForegroundWindow(IntPtr hWnd);

</pre></p>
<p>And then we need some new code in our Main() method. This should go at the top of the method. This method is pretty cool because it will allow you to use this in an ClickOnce environment and use Application.Restart() after downloading a new update. It&#8217;s not messy like a Mutex is.</p>
<p><pre class="brush: csharp;">

Process thisInstance = Process.GetCurrentProcess();
 Process[] allInstances = Process.GetProcessesByName(thisInstance.ProcessName);
 if (allInstances != null &amp;&amp; allInstances.Length &gt; 1)
 {
 foreach (Process currentInstance in allInstances)
 {
 if (currentInstance.Id == thisInstance.Id)
 {
 continue;
 }
 else if (currentInstance.MainWindowHandle.ToInt32() == 0 &amp;&amp; currentInstance.Id != thisInstance.Id)
 {
 continue;
 }

 ShowWindow(currentInstance.MainWindowHandle, (int)WindowShowStyle.Restore);
 SetForegroundWindow(currentInstance.MainWindowHandle);
 return;
 }
 }

</pre></p>
<p>Thanks for reading through, I hope you find this code to be helpful. I enjoyed writing it. Until next time.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/logicbomblabs.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/logicbomblabs.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/logicbomblabs.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/logicbomblabs.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/logicbomblabs.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/logicbomblabs.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/logicbomblabs.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/logicbomblabs.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/logicbomblabs.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/logicbomblabs.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/logicbomblabs.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/logicbomblabs.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/logicbomblabs.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/logicbomblabs.wordpress.com/89/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=logicbomblabs.wordpress.com&amp;blog=8428743&amp;post=89&amp;subd=logicbomblabs&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://logicbomblabs.wordpress.com/2009/11/19/c-single-instance-program-like-a-pro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c641ff1e8cf875a5a7932bcb49edde5b?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">erzr</media:title>
		</media:content>
	</item>
	</channel>
</rss>
