drewp for 2008 April

<M <Y
M>

2008-04-10T22:04:23 Rewrite of greenbar:

Blogger wouldn't format this right, so I'm putting my response here.

Original post

Here's a version using the file iterator capabilities on stdin, enumerate for the line number, all the logic combined into one if-statement, and a different strategy for printing the highlights.

#!/usr/bin/python -u

import sys

try:
pat = sys.argv[1]
except IndexError:
pat = None

for lineno, line in enumerate(sys.stdin):
if (pat and pat in line) or (not pat and lineno % 2 == 0):
print "\x1b[7m%s\x1b[0m" % line.rstrip()
else:
print line,

2008-04-19T08:53:03 test post from Roseville. American flag => car dealership. :

2008-04-20T13:26:22 Reentering central valley :

2008-04-20T14:29:41 City of Oroville, partway through a linux clone of the piclens program :

2008-04-20T14:30:46 John calls his sister from the train (yesterday) :

2008-04-27T14:32:16 Wood stain ran out at just the right time (that's a far-side, underside corner). Covered 4 shelves with 8oz of stain :

2008-04-27T19:51:52 Using freebase to help with dbpedia searches:

I wrote this response to a thread on a mailing list, but I can't find anyplace where sourceforge has my reply online (I did receive it in an email). I would have expected it on this archived thread.

So here it is again, at a place I can link to.



On 21 Apr 2008, at 14:40, robl wrote:
>> SELECT * FROM pages WHERE page_title LIKE "Queen%Elizabeth"
>>
>> This would perform a case insensitive match on Queen(anything)
>> Elizabeth
>> (at least in mySQL).
>>
...
>> Is there quick way to do what I want ?  Are there any indexes I could
>> apply to improve things (I have already created the indexes
>> specified at
>> http://www.openlinksw.com/dataspace/kidehen@openlinksw.com/weblog/
>> kidehen@openlinksw.com's%20BLOG%20%5B127%5D/1298)
>> ?
>>
>> Or do I need to create a conventional SQL table of resource names and
>> then do a SQL LIKE query on those ?
>>

You might also want to check out freebase. Here's the approach I'm about
to attempt, myself. Start with a reconciliation query:

http://sandbox.freebase.com/dataserver/reconciliation/?name=Queen+Elizabeth&types=%2Fpeople%2Fperson&responseType=html
- the reconciliation service handles misspellings and other variations
- s/html/json/ for the machine readable version

Then look at the freebase page or perform a query:

http://www.freebase.com/view/en/elizabeth_ii_of_the_united_kingdom

That page has this link:

http://en.wikipedia.org/wiki/index.html?curid=12153654

On that page, we have

<a href="http://en.wikipedia.org/wiki/Elizabeth_II_of_the_United_Kingdom">article</a>

Maybe freebase can just hand us that link instead of the curid one. I
haven't gotten to that part of my code yet. I don't know how often the
last word of the freebase URI is in sync with the WP one, but that seems
like it would be the least reliable. Following freebase's designated WP
link is probably more robust.

Finally, take the wiki name, and make a dbpedia URI:

http://dbpedia.org/page/Elizabeth_II_of_the_United_Kingdom



You probably noticed that elizabeth_ii_of_the_united_kingdom wasn't the
first result for 'Queen Elizabeth' of type /people/person. I'm not sure
if freebase considers that a bad result page or not. The reconciliation
service is new, so now's probably a great time to tell them how
important good results are to you :)

2008-04-29T01:38:52 tinymce patch for newsbruiser:

This patch hopefully works on the new newsbruiser release 2.6.2. It lets us use the excellent TinyMCE editor widget to write blog posts. Along with this patch, you have to actually put tinymce such that it shows up at /resources/tiny_mce/tiny_mce.js.

(Coming soon: another newsbruiser patch and accompanying tools that let us send picture posts from our cell phones.)

 

Index: nb/CoreCGIs.py
===================================================================
RCS file: /cvs/newsbruiser/nb/CoreCGIs.py,v
retrieving revision 1.100
diff -u -r1.100 CoreCGIs.py
--- nb/CoreCGIs.py 27 Apr 2008 11:52:33 -0000 1.100
+++ nb/CoreCGIs.py 29 Apr 2008 08:16:41 -0000
@@ -271,7 +267,7 @@
self.printDisplaySnippets('aboveEntryText')
print '<table><tr><td valign="top">'
self.textArea(self.notebook.getEntryBoxLength(), 70,
- const.ENTRY_CGI_KEY)
+ const.ENTRY_CGI_KEY, html=True)
self.printDisplaySnippets('rightOfEntryText')

if showHelp:
@@ -819,7 +815,7 @@
print '<table><tr><td valign="top">'

self.textArea(self.notebook.getEntryBoxLength(), 70,
- const.ENTRY_CGI_KEY, entry.text)
+ const.ENTRY_CGI_KEY, entry.text, html=True)
self.printDisplaySnippets('rightOfEntryText')
if names:
print '</td><td valign="top">'
Index: nb/lib/LOMP.py
===================================================================
RCS file: /cvs/newsbruiser/nb/lib/LOMP.py,v
retrieving revision 1.16
diff -u -r1.16 LOMP.py
--- nb/lib/LOMP.py 5 Dec 2004 20:20:51 -0000 1.16
+++ nb/lib/LOMP.py 29 Apr 2008 08:16:59 -0000
@@ -183,9 +183,41 @@
maxlength = ''
print '<input type="text" name="%s" value="%s" size="%s"%s />' % (name, cgi.escape(str(value), 1), size, maxlength)

- def textArea(self, rows, cols, name, content=''):
- "Prints a standard multiline text box."
- print '<p><textarea wrap="virtual" rows="%s" cols="%s" name="%s">%s</textarea></p>' % (rows, cols, name, cgi.escape(str(content)))
+ def textArea(self, rows, cols, name, content='', html=False):
+ """Prints a standard multiline text box.
+
+ drewp adds html mode using tinymce
+ """
+ escContent = cgi.escape(str(content))
+ if html:
+ # it would be cool to grab recent images and put them in
+ # the external_image_list
+ # see http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/external_image_list_url
+
+ # the way i include this js probably only works if there's
+ # one html textarea on the page
+ print """
+<script type="text/javascript" src="/resources/tiny_mce/tiny_mce.js"></script>
+<script type="text/javascript">
+ tinyMCE.init({
+ mode : "exact",
+ elements : "elm1",
+ theme : "advanced",
+ table_inline_editing : true,
+ plugins : "table,emotions,style",
+ theme_advanced_blockformats : "p,pre,div,h1,h2,h3,h4,h5,h6,blockquote,dt,dd,code,samp",
+ theme_advanced_toolbar_location : "top",
+ theme_advanced_statusbar_location : "bottom",
+ theme_advanced_resizing : true,
+ theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,outdent,indent,blockquote,|,formatselect,fontselect,fontsizeselect",
+ theme_advanced_buttons2 : "undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,styleprops",
+ theme_advanced_buttons3 : "tablecontrols"
+ });
+</script>
+
+ <p><textarea id="elm1" name="%(name)s" rows="20" cols="60">%(escContent)s</textarea></p>""" % vars()
+ return
+ print '<p><textarea wrap="virtual" rows="%s" cols="%s" name="%s">%s</textarea></p>' % (rows, cols, name, escContent)

def listBox(self, boxName, names, values, defaults=None, size=1,
allowMultiple=0):

2008-04-29T21:52:08 Timelapse Capture of Google's Predicted Traffic Conditions:

seen here


[Main]

Unless otherwise noted, all content licensed by Drew Perttula
under a Creative Commons License.