Randomizing a list of 25 things using Python

I got tagged in the oh-so popular “25 Random Things” meme on Facebook. To make a point that I sometimes think in code and I don’t think its weird, I wrote the script below to randomize my list before I posted it.


import random

f = open('25-things.txt')
list = f.readlines()
"""Magnus L Hetland's solution http://bit.ly/uN4iq"""
result = []

for i in range(len(list)):
    element = random.choice(list)
    list.remove(element)
    result.append(element)

i = 1
for line in result:
    print "%s. %s" % (i, line)
    i += 1

Processing WordPress’ Post Content

If you find yourself directly manipulating a WordPress post (say outside of “The Loop” by using query_posts, e.g. query_posts(array('category__and' => array(1,3)));) you may need to do some extra work to get the pretty formatting that WP does for you in things like the_content() and the_excerpt().

Say you have a single post in a local variable $my_post, if you want to output the content of the post and use the filters that WP does for you when calling the_content within The Loop, you can call the filter functions directly:

<?php echo wpautop(wptexturize($framing_post->post_content)); ?>

References: How WordPress Processes Post Content, Function Reference/wptexturize, Function Reference/wpautop, formatting.php source code

BBEdit, HTML Markup tag on one line

In BBEdit I use the keyboard shortcuts a lot. They’re a great way to save some time. The default behavior for the keyboard short cut to insert (or wrap the selected text in) the <p> tag always bothered me, it put the <p> and </p> on new lines like:

<p>
</p>

What I want (almost always) is both <p> and </p> on the same line:

<p></p>

Well I spent some time digging around the plist files and the preferences and couldn’t figure it out for a while.

I don’t often use the menus or the palletes, too much mousing around. But here’s where I found the solution to getting command-option-p to output the <p> tag on one line: In HTML mode,  go to the Markup menu, in the Block Elements sub menu, select the first option “Paragraph…” (vs. the second one which has the cmd-opt-p shourcut bound to it). This is the menu based dialog that presents the various options a <p> can have (id, class, style, etc.). De-select the “Place Tags on Separate Lines” checkbox and click the Apply button.

You now have told BBEdit your preference for how the <p> tag is used via this menu command and via the keyboard shortcut, cmd-opt-p. From now on when you use the cmd-opt-p keyboard command, you’ll get:

<p></p>

CNN.com sells own headline-inspired t-shirts

Take a close look at the icons after certain stories in the ‘latest news’ section of cnn.com

Notice anything odd? video icon, check…. what’s that next to it? is that a t-shirt icon? what could that mean? why is the t-shirt icon next to some headlines and not others?

Go ahead click on one.

Yep. they are selling t-shirts with some of their headlines.

Who get to decide which headline is t-shirt worthy?

Why is  “Haunted jail sounds freaky, cops say” t-shirt worthy and “Is your doctor prescribing a placebo? ” isn’t…

Will windfall t-shirt profits change headline writing?

It used to be plain crap, but now…it’s Beta!

“We have to admit, the old download manager totally sucked.”

Beta is beyond retro-cool. Remember the late 90′s? Recalled by some as, “The Golden Age of Beta”, is it being eclipsed?

With a health dose of web2.0 badges screaming: “BETA!”, anything could happen.

–I am so starting a band called The Beta Band, no wait that one’s taken…how about The Beta Bubble?

UPDATE: This is how to own up to being in beta. (thanks Jimmy)