Mike takes to heart the adage that ideas are f***ing worthless without action.

Tuesday, July 28, 2009

getting back into it... day 4

I installed PyScripter (written in Delphi) and my productivity went way up now that I have a good debugger. I've now passed my unit tests for the first time. I feel I'm now on my way to becomming a python programmer, slowly but surely.

Installed same tools on my work machine, and did my first sync. I expected the contents on the C:\wave folder of obsolete to be updated... but that's not how a distributed system works... you then tell it to sync the changes on that machine to the tip... which prevents a ton of headaches... a much saner way to go.

I edited the ignore options on Tiny, now we don't care about the .pyc files.

I've deliberately made a bad edit and commit and reverted it... works well!

I'm feeling pretty good about this.

Monday, July 27, 2009

getting back into it... day 3

Today I decided I needed a debugger... since I'm not really up on the syntax of python (lists look like tuples look like arrays to me)... I was really lost... it took about an hour to digging around to decide on PyScripter to be my IDE. I don't want to get tied into a product I can't afford, so I took a pass on Komodo from ActiveState.

I've managed to finally deduce what I was doing wrong, and pass one of my trivial unit tests... the code now looks like this:



--Translate01.py
"""Translates internal representation to and from xhtml"""

#define Exceptions

class HtmlError(Exception): pass
class invalidHtmlError(HtmlError): pass

#Define escape mapping
htmlCharMap = [('>', ">"),
('<', "<")]


def toHtml(x):
"""convert x to html string"""
return x

def fromHtml(s):
"""convert html string to internal representation"""

result = ''
index = 0
while index < len(s):
foundat = -1
i = 0
for ascii,html in htmlCharMap:
if (foundat < 0) & (s[index:index+len(html)] == html):
foundat = i
i += 1
if foundat >= 0:
ascii, html = htmlCharMap[foundat]
result += ascii
index += len(html)
else:
result += s[index]
index += 1
return result

Translate01_test.py:
"""Unit test for translate01.py"""

import translate01
import unittest

class KnownValues(unittest.TestCase):
knownValues = ( ( '', ''),
( 'x','x'),
( '>','>'),
( '<','<'),
( 'this is a test','this is a test') )

def testToHtmlKnownValues(self):
"""ToHtml should give known results with known input"""
for s1,s2 in self.knownValues:
result = translate01.toHtml(s1)
self.assertEqual(s2,result)

def testFromHtmlKnownValues(self):
"""FromHtml should give known results with known input"""
for s1,s2 in self.knownValues:
result = translate01.fromHtml(s2)
self.assertEqual(s1,result)


if __name__ == "__main__":
unittest.main()

Saturday, July 25, 2009

getting back into it... day 2

I've downloaded and installed TortiseHg for Windows (I'm running XP on my netbook) and I've done my first few tests with it... it's pretty nice. I've used TortiseSVN in the past, so I kind of knew what to expect. I chose TortiseHg and Mercurial because it's the version control system that Python is going to use in the future, so that's good enough for me. I don't have the experience or time to get it, so I'm going with the crowd on this one for now.

I added some test cases, now my code doesn't pass. Here's the current version of the testing unit:


"""Unit test for translate01.py"""

import translate01
import unittest

class KnownValues(unittest.TestCase):
knownValues = ( ( '', ''),
( 'x','x'),
( '>','>'),
( '<','<') )
def testToHtmlKnownValues(self):
"""ToHtml should give known results with known input"""
for s1,s2 in self.knownValues:
result = translate01.toHtml(s1)
self.assertEqual(s2,result)
def testFromHtmlKnownValues(self):
"""FromHtml should give known results with known input"""
for s1,s2 in self.knownValues:
result = translate01.fromHtml(s2)
self.assertEqual(s1,result)


if __name__ == "__main__":
unittest.main()

Friday, July 24, 2009

Shaking off the cobwebs, getting back into it

I've got some programming ideas, inspired by previous efforts and the most recent lessons learned from Google Wave, I'm going to start a python project to handle translating source code (specifically pascal code) bidirectionally to object code and symbol tables.

My main programming exerience is in Borland's Delphi 5, which suceeded a number of years using Turbo Pascal 7.0 under DOS. So, these new languages like Python, etc al. are a bit odd to me, but I really like the power of the built in dictionaries, tuples, etc.

I'm using an old build of Active State python (2.5.1) which I'll be updating. I managed to write a few modules with very trivial amounts of code, cribbing heavily from "Dive into Python" by Mark Pilgrim.

Here it is... ALL of it...


Translate01.py:

"""Translates internal representation to and from xhtml"""

#define Exceptions

class HtmlError(Exception): pass
class invalidHtmlError(HtmlError): pass

def toHtml(x):
"""convert x to html string"""
return x

def fromHtml(x):
"""convert html string to internal representation"""
return x



Translate01_test.py:

"""Unit test for translate01.py"""

import translate01
import unittest

class KnownValues(unittest.TestCase):
knownValues = ( ( '', ''),
( 'x','x'))
def testToHtmlKnownValues(self):
"""ToHtml should give known results with known input"""
for s1,s2 in self.knownValues:
result = translate01.toHtml(s1)
self.assertEqual(s2,result)
def testFromHtmlKnownValues(self):
"""FromHtml should give known results with known input"""
for s1,s2 in self.knownValues:
result = translate01.fromHtml(s2)
self.assertEqual(s1,result)

if __name__ == "__main__":
unittest.main()



It actually runs.... and tests ok... (because it's trivial right now)

PythonWin 2.5.1 (r251:54863, May 1 2007, 17:47:05) [MSC v.1310 32 bit (Intel)] on win32.
Portions Copyright 1994-2006 Mark Hammond - see 'Help/About PythonWin' for further copyright information.
>>> ..
----------------------------------------------------------------------
Ran 2 tests in 0.000s

OK


So.... I'm on a journey... and I just took the very first step... a thousand miles to go. ;-)

Thursday, November 08, 2007

Big Crane


Big Crane
Originally uploaded by --Mike--
This is a big hydrocrane which was unloading the counterweights from a tower crane at Randolph and State streets in Chicago, Illinois this morning.

I used HUGIN and Emblend to create a TIF, then Paint Shop Pro 10 to help tweak for a bit better contrast ratio.

Comments welcome.
--Mike--

Sunday, November 12, 2006

Flickr

This is a test post from flickr, a fancy photo sharing thing.

Monday, September 04, 2006

Transparency, A-Lists, and time

Dave Rogers correctly points out that technology doesn't change what we do, only how we do it. The case in point this time is the overwhelmingly male speakers roster at the Office 2.0 2006 Conference. Out of 54 speakers, only 1 is a woman.

Now, I've actually done some thinking about this, rather than just firing off a reactionary posting as is encouraged by the blogosphere. Actual contemplation and discussion is highly discouraged by the sweeping wave nature of discourse among the "a listers", who tend to dive into a topic, and leave it just as quickly..... interesting tangents....

Anyway... I asked Noran about this, and she gave me an insightful and very deep answer, which completely and totally supported Dave's point... technology makes work easier, but in most cases doesn't change what we do, even in the medical field.

Of course... I was actually asking a different question... (what about the underrepresentation of women) and she again came up with an insightful and deep answer... It doesn't matter who speaks, as long as they are the most qualified. We talked about how to make sure it's fair... and we agree it gets very difficult very quickly. (I.E. are all religions and races represented??)

After sleeping on it, getting even further away from the wave of conversation... I reach what I believe to be the proper way to handle this... more transparency.

If we all knew who was invited to speak, and why... we'd all be better served. We could better judge the nature of the conference, and the motivations of the organizers. Better informed decisions help make the best markets. Of course, the converse is that profiteers who want to get something for nothing (or little work) will lose... so they'll prefer to keep things opaque.

Well this is my first Blogger beta post... let's see how it does.

-----
Update: Shelley Powers reports that they've added three very good women to the roster.

About Me

My photo
Munster, Indiana, United States
I fix things, I take pictures, I write, and marvel at the joy of life. I'm trying to leave the world in better condition than when I found it.