Friday, August 24, 2007

Genshi Templates: include and select()

Hint for today: If you don't know Xpath select stuff at all (like I didn't a couple minutes ago) and you want your Turbogears templates to be a little more intelligent about column content placement, you can do something like this:

<!-- in master.html -->
<div id="centercontent">
<div id="status_block" py:if="tg_flash"
class="flash" py:content="tg_flash">
</div>
<div
py:replace=
"select('//div[@id=\'centercontent\']/*|text()')">
</div>
<div id="rightcontent">
<div
py:replace=
"select('//div[@id=\'rightcontent\']/*')">
</div>

<!-- in welcome.html -->
<div id="centercontent">
<!-- all your base here -->
</div>
<div id="rightcontent">
<!-- navigation stuff here -->
</div>

Breaking down the Xpath select statement a little more (removing the quote escapes):
//div[@id='centercontent']/*
//div == in all 'div' elements
[@id='centercontent'] == where the (@) attribute 'id' is equal to 'centercontent'
/* == select all the children elements

Tuesday, August 14, 2007

Coolest Hotel Design Ever - Eco-Aqua Hotel in a Quarry

It won't be completed for at least another 2 years, but I would so fly to china just to stay here:

http://atkinsdesign.com/html/projects_hotels_songhotel.htm

It's already cool enough that they're apparently using an old quarry as a lake, so the whole thing is sunk into a pit and looks like an especially fantastical Bryce creation, or that they're using geothermal power. The thing that drops my jaw is the ginormous *waterfall-like elevator* that apparently runs over the glass face of the building. A
t least, I think it's an elevator.




Really nice flash sketch widget

I really like the texture aesthetic of this online sketch app, it's the best I've seen. I really like the background "paper," he thinner-line tools resemble actual penstrokes (after they're scanned, anyway).

http://www.odopod.com/sketch/

If only I had a spare second to doodle :)

Thursday, August 09, 2007

Really Awesome Ad.

This is the best ad I've seen in a long, long time. Well, the iphone ads are really, really good and everything, but they do lack in a certain... initial bafflement. :D

http://www.youtube.com/watch?v=FsBvMvHk1BE

Sunday, August 05, 2007

Website Teaser

It's coming! Got my MossyStone.org domain name, got hosting through Webfaction, who gives half their turbogears related signup fees to the turbogears project. They keep on top of tech, I like it, and I like the hosting so far. Site is running in Turbogears on Python of course.

More to come in the future. :)

Saturday, August 04, 2007

Turbogears Banner

I couldn't find a small Turbogears banner / logo / powered by image to my liking, so I just whipped one up. Also, here's a Python logo I found through a google search. Enjoy.


Wednesday, August 01, 2007

reCAPTCHA: Stop Spam, Read Books

This is by far the coolest captcha service ever. (Blogger, you should pick this up) Out of Carnegie Mellon, this service aids in digitizing books. It gives you two words to type, the first is a known word, the second is a word that their OCR algorithm couldn't figure out. If you get the first word right, it assumes that you also got the second word correct.

I think it's a fantastic idea, putting captchas to a good purpose. :)

Gotcha: Turbogears Form Widget

So, I had one of those barking up the wrong tree moments this morning, where I was sure as can be there was something going on with SQLObject caching, but it turned out to be much simpler than that. I have a simple sort of application linking products to the company that makes them, but when you added a new company, then tried to add a new product for that company, the company didn't show up in the pull down box. (a SingleSelectField)

As it turns out, when you create your form widget:
editform = widgets.TableForm(
fields=EditFields(),
action="/editsave")
the field class gets created once, at the controller load, and that's it.
Therefore, if you populate your fields when you create the form, they won't be updated, possibly causing you to learn more than you wanted to about SQLObject caching. I found the solution on this page. Similar to passing values, you just pass a dictionary of the options to the appropriate widget. Since I have a generic CRUD controller, I created a function in my EditFields class that returns a dictionary of all the options fields and updated values, like so:
def updatelists(self):
"""Return a dictionary of any lists
that need to be updated due to new objects"""

companylist = Company.build_list(
'name',
orderBy=Company.q.name)

#in my form, companyID is the
#name of the SingleSelectField
return dict(companyID=companylist )

(using the build_list method here) then, in my controller:
return dict( form=self.editform,
values=objvalues,
options=self.fieldswidget.updatelists())
and finally, in my model:
<div py:content="ET(form.display(
value=values,
options=options))">
(I'm using Genshi, which is why I have the ET function there)

Thursday, July 26, 2007

Unfortunately Linden

Ran into this little exercise of Googling "unfortunately [yourname]". My results, removing all of the Linden Labs press release junk.
  • Unfortunately Linden seems to be content with generating bullshit instead of pushing the state of the art. (ouch)
  • Unfortunately, Linden doesn't include enough of them, nor explore their implications sufficiently, to do justice to his argument.
  • Unfortunately, Linden has not been the tonic for the offense that I was hoping for.
  • Unfortunately, Linden was completely sold out of their Cabernet Franc. (damn)
  • Unfortunately, Linden is still around to fret, cry, whine, and hesitate in Covenants stead.
  • Unfortunately, Linden is a 23 year old corner outfield prospect who has yet to crack an 800 OPS in two attempts at AAA. (I am 23, and also not good at baseball.. creepy?)
  • Unfortunately, Linden's future in the 21st century is threatened by a combination of factors. (oh noes!!)
  • Unfortunately Linden lifted the ban on fireworks after that "little" rain last weekend.
  • Unfortunately Linden was there.... refusing to leave, dag nab him. And I believe that the elbow and knee combo, to the right of shot, belongs to Mr Krad.
  • Unfortunately, Linden's papers have disappeared, and Land is forced to piece together the story behind the discovery with the dubious aid of Linden's young mistress (woo!)
Much fun. :)

Wednesday, July 25, 2007

Gotcha: Turbogears urls

So, this didn't really waste too much of my time, but watch for trailing slashes in your links. If you have a setup like (Stolen from the SimpleFormsWidgetTutorial):
comment_form = widgets.TableForm(
fields=CommentFields(),
action="save"
)

@expose(template=".templates.form")
def add(self, tg_errors=None):
if tg_errors:
flash("There was a problem with the form!")
return dict(form=comment_form)

@expose()
@validate(form=comment_form)
@error_handler(add)
def save(self, **data):
#...

And, for whatever reason, your user ends up at "host.com/add/" instead of "host.com/add", the form will display fine, but will point to "host.com/add/save" instead of "host.com/save". Then you'll get all kinds of fun errors, like "TypeError: add() got an unexpected keyword argument ''", and you'll scratch your head, wondering if you got an error that the validation somehow threw and the form error handler somehow didn't catch. Or, at least, I did.

Friday, July 20, 2007

open.ended

Yay, arstechnica, my absolute favorite newsite (they have just enough news to keep me busy, but not so much I can't keep up, plus it's all the stuff I care about), is opening a new open source journal. I'm very stoked, since this is the last geeky interest that they didn't cover specifically. (I follow their gaming, mac, and science journals)

Go ars, go. =)

Thursday, July 19, 2007

The Movie Entertainment Standard

Back in State College, PA, our little social group of gaming dorks used the Movie Entertainment Standard to determine what was worth spending money on. I think this was a function of our being poor college students, and also completely addicted to MMOs. Basically, you compare whatever purchase you're considering to watching one movie. So, monthly subscription to FFXI was $15, which gave us (way too) many hours of entertainment, compared to the 4 hours that we would get watching 2 movies for the same price. (Actually, 3 movies, since we got the student discount) Games are getting more expensive, but it's a neat way to justify dropping 50 dollars on the newest release, since you're bound to play the game for more than 10 movies worth (20ish hours). Movie prices have gone up quite a bit recently, but it evens out, since average movie lengths have also increased.

Puzzle Pirate's Subscription FAQ is the first time I've seen this concept written out, though I'm sure it's pretty common. (No, I don't play Puzzle Pirates, but it's always appealed to me. If only they'd make a Ninja themed puzzle game)

Tuesday, July 17, 2007

Turbogears Interpreter Goodness

I'd just like to say that I officially love working with Turbogears. It's just so great to be able to run interactive commands, with the environment that your code is working in already loaded up. (This isn't advertised enough in the Turbogears docs. They should have you do it in the tutorials) I hope it's still this fun when they switch everything over to Pylons, Genshi, and SQLAlchemy in 2.0. Maybe I am just odd, but it brightened up my so far kinda crappy week.

Tuesday, July 10, 2007

Gotcha: C# Windows.Forms Madness

So, if you are ever creating dynamic forms in C#, and things aren't showing up for some reason, and you sillily left one non-dynamic thing there, just to be sure that you're not loosing the whole container, check that the dynamic stuff isn't being created underneath other things. For some reason, I expect them to show up over older stuff, but apparently I'm wrong. (I.E. set form.Location = new System.Drawing.Point( [not 0], [also not 0]); )

[Spell check doesn't think that sillily is a word. Pssht.]

Monday, July 09, 2007

Gotcha: Unicode Error with SQLObject + Turbogears + mysql

I spent a bit of time this morning trying to figure out why the code I wrote at 3am last night wasn't working. I kept getting a crazy Unicode conversion not supported error, and all the solutions that I found Googling were not satisfactory. Eventually, I found that I had used the wrong validator on one of my fields (specifically, a Date field, though I imagine this will happen with others as well). If you run into this, double check your validators before you do anything crazy like change your model to use all UnicodeCols.

Also, on the subject of validators in Turbogears, I recommend using the FormEncode documentation directly, it's much more complete than what you find listed in Turbogears docs.

Python Syntax Goodness

List comprehensions in Python are awesome. I saw one for the first time, knew exactly what it did, and started using them immediately. Yay for Python! Boo for me not being on top of these things like I should be. (PHP, I shake my fist at you)

Friday, July 06, 2007

Wii!

Woot! I got a Wii. I'm stuck without a car for the weekend, because my mechanic took it half apart and discovered he needed to replace some sort of cam shaft seal. So, it's a good excuse to spend the last 2 days running everywhere and trying to find one in stock, right? (I bicycled home with it ^^)

Anyways, I bought Elebits, a game I've been fascinated with. It's a lot of fun, very unique sort of gameplay. After getting past Nintendo's incredibly finicky credit card authorization, I just downloaded the Opera browser (6 days ago, could have gotten it for free.. oh well). I'm pretty sure I won't be using the Opera browser for reading the news, the text doesn't display well at all on my screen, and zoom is annoying, but I've tried YouTube, and I think I'll definitely be using this as an internet solution for my home theatre. (Full Screen mode looks good, and I have the sound going to my surround system, the Grayson trailer looked good, sounded great)
Google Maps works OK as well, I'm glad that this version of Opera isn't limited in the realm of flash and javascript, like the DS was.

Oops, I spoke too soon. Flickr worked well, until I tried a slideshow, and got an out of memory error after 3 pictures. :( I was pretty stoked about slideshows during parties and whatnot. Anyone know if there's a way to get around this?)

Now, I'm off to look at Virtual Console stuff, the reason I finally decided to plunk down the money for this thing in the first place.

[I've been going nuts on the blog recently, there's so much stuff I've been meaning to post, now I have some time, it's all getting pushed out of the queue]

[Update: wow, if they brought out Marble Madness for Virtual Console, I'd rush home, and take all of tuesday off just to play it. Virtual Console is just as amazing as I had hoped. Childhood memories, here we come!]

NPR Car Talk

There are a few loves that I've inherited from my dad, as if transferred directly from his heart to mine at some nebulous point in my childhood. One of these is my love for sail boats and planes (particularly the older ones). We used to build models when I was little, I think I've spent more time working with balsa wood than any other 3 dimensional medium, including Legos and playdough. Another is my love for Apple computers, on which I was raised; and, also in the vein of brand names, my unflinching respect for BMW's.

Anyways, my father and I used to get in the car (always a beamer), and if we were really lucky, Car Talk would be playing on NPR. I have so many fond memories of listening to Car Talk with my dad, just hearing Click and Clack's voice makes me smile. Not to mention that they have a great show, and I learn interesting things about debugging cars. Which is good, since my car is starting to do funny things.

Since I don't really drive much during the week, I've downloaded the Car Talk podcasts, and I'm listening to them on the bicycle ride to work in the morning. It's fantastic, helps me wake up a little more, and starts my day off right. I would highly recommend it.

ExKate - Coolest thing on 4 wheels, evar

So, the reason I've been thinking about all the activity I do is that I'm completely enamored by this amazing contraption of fun, back to the future style. Wireless remote controlled electronic skateboards, who would have thought? Hidden behind an awesome toy is actually some interesting technology. It boasts: "It is the first time in the history of mankind where the human body is used as an antenna between a transmitter and receiver." Basically, you hold the control in your hand, and it uses the body as the link between controller and skateboard, so when you fall off, it actually stops. The thing is pretty heavy with batteries, but it gets a 10 mile radius, and speeds up to 22 mph. I dug around in the FAQ, and they mention regenerative braking, which is a fantastic idea, I'd love to see more stats on that. It also has a really awesome turning radius.
Wow, I would love to have one of these. I do wake board, and the control scheme is pretty similar, toe/heel flexion to steer. It would really help my balance. That's a good reason to buy it, right?

Thursday, July 05, 2007

Sports, Whee

So, I've started roller blading with my friends, I've stepped up running to twice a week, I go to swing dancing once a week(ish), wake boarding maybe twice a month, I'm still playing volleyball 3 times a week, and I've been bicycling to work 5 times a week for a couple months now. I'm contemplating doing stance training with some of my friends. I bought a Nike+ sensor for my iPod, something I've been meaning to do for a while (the reason I got a nano instead of a video iPod when someone stole my precious 1st generation 5gb iPod), partially motivated to do so by ars. Also, I'd like to do get some sort of bike trailer so that I can do groceries and picnics on my bike (though I might stick with my backpack), and I'd like to get some snorkeling gear to play with, as soon as I find a decent, easy way to get to a beach on the gulf side. I really do miss swimming, and I'm confused as to why I don't do more here, I suppose the water in the bay isn't really the best. I really am trying to get back into shape, I think the next step is to actually get back into martial arts.

Whew, typing all that made me tired. At least I'm not sitting in front of my computer dorking out *all* the time. Speaking of dorking out, I've really got to write that sample AJAX program in Turbogears for the next Tampa Bay Python Meetup.