Tuesday, October 18, 2011

The Python Property Builtin:

'via Blog this'

I thought attribute accessors are a good idea until I saw Python's approach to it: properties! Basically, you still write accessors, say, get_x and set_x, but then by including
x = property(self.get_x, self.set_x) the class user can use A.x as if it were an attribute. The advantage over an attribute is that set_x and get_x can contain code.

Friday, October 07, 2011

Now for blog submitted from my android phone

While my colleague is driving I am entertaining myself with giving the Blogger app I recently installed a spin. Apparently I can even upload an image.


Should I use ScribeFire?

ScribeFire at scribefire.com has been around for a long time, and I have used it before. Its current version is called "ScribeFire Next",
the one I test here was announced  Sep 12, 2011. I use Google Chrome, so I installed the ScribeFire extension 
through the Chrome Tools menu. Registering my blog (this one here) as the first step after clicking on the new icon in next to the
browsers' address window was easy.
There is a "Start a new post" link that does what it says. Nice and easy. 
I like the clean full-page layout with a format toolbar
similar to that of a simple text editor. 

Now for the requirements:

Including code

I found a link directly above the format toolbar called "Edit Code (HTML and Markdown)".  Curiously, I clicked on it. This certainly uglified the view of my text, but apparently it lets me use Markdown,  and according to Wikipedia's description http://en.wikipedia.org/wiki/Markdown#Code I should be able to include code by preceding each code line with at least 4 spaces. Here's what that looks like:

import unittest
from FindMatchingLines import *


class TestFindMatchingLines(unittest.TestCase):
def setUp(self):
self.text = ''
for i in range(0,100):
self.text += 'Line {!r}\n'.format(i)

self.patNone = 'xxx'
self.patAll = 'Line [0-9]+'
self.pat10 = 'Line [1-9]0'

Aha, works halfway. But by switching to "Edit Code (HTML and Markdown)" I see the html tags got misplaced. So correcting this as in


import unittest
from FindMatchingLines import *
class TestFindMatchingLines(unittest.TestCase):
def setUp(self):
self.text = ''
for i in range(0,100):
self.text += 'Line {!r}\n'.format(i)

self.patNone = 'xxx'
self.patAll = 'Line [0-9]+'
self.pat10 = 'Line [1-9]0'

I get the whole thing to be displayed in code (yes, that's Python). Now, what you see is not the original style for code blocks which just applies courier-typeface to everything between the pre and code tags. I have fancified that by adding custom CSS to the Blogger template. How? Next post. For now let's look at the other requirements.

Ease of use - Can it handle markdown

Yes it can, in the "Edit Code (HTML and Markdown)" edit mode. What happens however is that upon clicking edit visually this markdown gets converted to HTML, and then switching back to HTML and markdown doesn't convert it back to markdown but shows you the tedious HTML code. I find that medium nice. If I had to make a Pugh matrix on it I'd give it a 0 for neutral. One way around this is that you start in markdown mode and never leave it. But there's no way around seeing the html version of your markdown in markdown mode during later edits.

How about images

My own title image

That's really easy in visual edit mode, just click the insert/add image button in the formatting toolbar.

Web snippets

Haven't figured it out yet :-(

Immediate post

That's good - there's a post button at the bottom right, and a dialog appears asking me to view the post.

Am I wowed?

Overall, no. The feature set is still pretty basic. On the positive side, I haven't found a bug yet!

What blogging tool should I use?

Sooo...

I am thinking of reviving my work blog (hosted on Blogger) again, perhaps only for my own enjoyment, perhaps as a notebook for some topics that might of wider interest than what I post on Evernote (excellent tool, please check it out).

I have spent a few minutes looking at what tools I should use to generate a blog entry. Here is what I expect:

 

* Since I code a fair bit, I require the tool to handle and format code snippets correctly and nicely.

* It should also be easy to use, i.e. not require all the html syntactic sugar that's usually necessary. Markdown - see here http://en.wikipedia.org/wiki/Markdown - fits that second requirement, i.e. my blog tool of choice should handle Markdown or something similar. Edgewall TRAC - which if this were my group (har, soon!) I would make mandatory for my minions - also has some really nice markdown-ish capabilities called WikiRestructuredText, I'd settle for that too.

* I want to be able to quickly and simple include images.

* Ditto web snippets.

* I want to be able to immediately see my post and be able to update it on the fly.

* Overall, I want to wowed with how easy the tool makes it to write a fine looking rich blog that lets me focus on content creation.

First up is ScribeFire which I used succesfully before - read on in the next post. And comment me back if you happen to know the ultimate blogging tool for Blogger.