tail -f findings.out

Feed now updating again

If you follow this blog’s feed, you might have thought I hadn’t written a post for a while. As it turns out, the time it was taking my server to respond when Feedburner asked for recent items was greater than Feedburner’s timeout period (over 10 seconds). I’m not sure why this was the case, my feed URL simply started serving at a much lower transfer rate one day. My temporary solution has been to reduce the number of items shown in the feed from ten to five. This has allowed Feedburner to update, so the last three posts that were missing should now be shown.

I apologize for the lacuna, and hope to perform some optimization to get the site running faster soon. Thanks for reading!

May 21, 2009 - 6:53 AM Comments (2)

Going to PyCon 2009!

I am going to my first PyCon this year! With programming in Python so much more both at work and messing around with various things at home, along with the additional tutorial day and great talks planned, this seemed like the perfect year to go. Many of the tutorials look splendid, and it was quite hard to decide. I ended up signing up for the following:

Now I just have to pick which of the myriad talks I want to attend… 

1
self.clone()

, anyone?

Tags: , ,
February 21, 2009 - 12:49 AM No Comments

100th blog post!

This is my 100th post to this blog! And there’s a lot more where that came from!

Token graphage:

A domain change (formerly: assistedsilicon.blogspot.com), a platform change (Blogger to Wordpress), 805.5 themes, and coming on two years later, the topics are mostly the same:

  • Linux: vim config, bash aliases, useful scripts, hidden options, and lots more
  • MySQL: How to do things you will likely need to do, and do them better
  • Python: Resources, recipes, and tricks for using this incredible language
  • Vista: How to live with it, partially
  • Occasional other tech/geek items

On the graph:

  • The nine month lacuna in 2007-08 is to be blamed on World of Warcraft.
  • The spike near the end of 2008 corresponded to when I started using Windows Vista (at work, under duress). Discoveries do seem to increase in wartime…

For some reason I couldn’t wrangle my data into a graph I liked in OO Spreadsheet. So, of course, I made the graph in Python! To get the post data, I ran this against my Wordpress MySQL DB:

1
2
3
4
mysql -u root -p -e "use WORDPRESS_DB; \
select date(post_date) as date, post_title as title from wp_posts \
where post_type='post' and post_status='publish' \
group by post_date order by date(post_date) asc;"
> posts.csv

This grabs the dates and titles for all actual published posts, grouping and ordering them on the date. Then I put that output file into a short ugly script for graphing:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
try:
    from pylab import *
except:
    graphing = False
import pprint
import datetime

# Read in the file of titles and dates:
f = open('posts.csv')
flines = []
for line in f: flines.append(line.split('\t'))
# Create dict of year-month and counts therein:
date_counts = {}
for line in flines:
    if date_counts.has_key(line[0][0:7]):
        date_counts[line[0][0:7]] += 1
    else:
        date_counts[line[0][0:7]] = 1
# Make a list of the counts, dates and sort them:
counts = date_counts.items()
counts.sort()
# Turn the partial date strings into date objects for graphing:
dates = [key for key, value in counts]
dated_days = []
for day in dates:
    year = int(day[0:4])
    month = int(day[5:7])
    day = 1
    date = datetime.date(year, month, day)
    dated_days.append(date)
counts = [ value for key, value in counts]
# Set labels
x = xlabel('Date')
setp(x, fontweight='bold')
y = ylabel('Posts')
setp(y, fontweight='bold')
# Subplot to handle date positioning
ax = subplot(111)
labels = ax.get_xticklabels()
setp(labels, fontweight='bold', rotation=30, fontsize=10)
# Plot as dates
plotted = plot(dated_days, counts, '--')
setp(plotted, marker='s')
title('Posts over time')
grid(True)

Latest version in my Code Trac.

Tags: , ,
January 20, 2009 - 2:32 AM No Comments

Moving from Blogger to Wordpress

I decided to move one of my Blogger-based, blogspot.com-hosted blogs (this one, in fact!) over to my own server, using Wordpress. My requirements:

  • Move the content easily
  • Preserve all links

After a little help from Google, I was able to achieve both pretty easily. Here’s what I did.

For moving the content, if you are hosting your Blogger blog at blogspot.com, and your new Wordpress is at least 2.1 (it better be!), then you are in for a treat. All you have to do (in your Wordpress blog), is go to Manage, Import. Then select Blogger, and click Authorize. You will be redirected to a Google page, asking you if you want to grant access. Grant that, then you get sent back to your blog, and are presented with… the magic button!

Wordpress' magic import button

Fig. 1. The Magic Button.

Just press that, and watch the progress bar fill as all your posts and comments are imported. Awesome. And then you can even set the author for the imported posts, in case your name differs between the blogs. (Say you used to go by “1337\/\/3b|\/|4ster”. It’s ok to admit it.)

Now you have all your content in your new Wordpress blog. If you don’t give a fig about Google indexes, PageRank, links on other sites, or your horde of loyal subscribers, feel free to stop here.

However, with a little more effort, you can redirect all the same URLs on your old blog to their new location! The following steps are taken from this handy guide. I will put the code here as well, since that page uses annoying characters that got messed up when I pasted the blocks into an editor.

You will need to login to your Blogger account and go into Settings for the blog you are moving. Then go to the Template tab, and Edit HTML. If you are not on the Classic template, you might not be able to follow these instructions exactly, as the tags are different. After your opening <head> tag, add this line:

1
<meta http-equiv="refresh" content="0;url=http://www.YOURSITE.com/" />

Make sure to replace YOURSITE throughout these examples with your own URL. Next, under the
<Blogger> tag, add:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
    <MainOrArchivePage>
    <script language="javascript"><!--
   var blog_root=http://www.YOURSITE.com/;
   document.location.href=blog_root;
   //--></script>
    </MainOrArchivePage>

    <ItemPage>
    <script language="javascript"><!--
   var process_page="http://www.YOURSITE.com/blogger_redirects.php";
   var newpage=process_page;
   var oldlink="<$BlogItemPermalinkUrl$>";

   newpage+="?p="+oldlink;
   newpage=newpage.toLowerCase();
   document.location.href=newpage;
   //--></script>
    </ItemPage>

Lastly, you will need to add the following file as

1
blogger_redirects.php

(or if you change the name, change the name in the code above) in the root of your new Wordpress’ blog. Be sure to set proper owner on that as well:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

require($_SERVER['DOCUMENT_ROOT'].'/wp-blog-header.php');
$search_link = $_GET['p'];
$vars = explode('/', $search_link);
$num = count($vars) - 1;
$filename = $vars[$num];
$slug = str_replace(".html", "", $filename);

$SQL = "SELECT posts.* FROM $wpdb->posts AS posts WHERE posts.post_name = '$slug' LIMIT 1";
$posts = $wpdb->get_results("$SQL");

if ($posts) {
 foreach ($posts as $post) {
  $found_link = get_permalink($post->ID);
 }
}
else
{
  $found_link = "http://www.YOURSITE.com/";
}

?>

<html>
<head>
<title>Redirecting...</title>
<script language="javascript"><!-
document.location.href="<?php echo ($found_link); ?>";
//-></script>

<meta http-equiv="refresh" content="2;url=<?php echo ($found_link); ?>">

</head>
<body>
<h1>This blog has a new home!</h1>
<h1>Redirecting...</h1>
<p>You can also proceed immediately to <a href="<?php echo ($found_link); ?>"><?php echo ($found_link); ?></a>.</p>
<p>The main blog URL is <a href="http://www.YOURSITE.com/" mce_href="http://www.YOURSITE.com/">www.YOURSITE.com</a>.</p>
</body>
</html>

At this point, anyone hitting your old blog’s homepage, or any blog post, will be redirected to your new URL. If the script you added can find a matching page, it will send them there. If not, they at least go to your new homepage. Now to ensure that it DOES find a matching page, you can change your permalink structure (under Settings in Wordpress) to match your old Blogger blog. There are two other steps you will want to take on that note:

  • Edit permalinks
  • Handle .html Blogger URLs

For these two, you can follow this guide created by the maker of a Wordpress plugin that does this for you! Basically you just install the plugin, run it, and add some lines to your .htaccess file.

That’s it! A few minutes, and you will have a shiny new more flexible Wordpress blog, with all your old content, and handy redirects for Google and all your followers.

[Edit, 2008-10-28:] You might get a message from Blogger after taking these steps that your blog has been blocked as a spam blog! I believe it is just due to the redirection, which might indeed be used by ad sites. You just fill out a form they email you a link to, a human looks at it, and all is well.

Tags:
October 26, 2008 - 1:26 AM No Comments

Hello world (Take 2)!

Welcome! This is the new home for a blog of the same name I have kept at assistedsilicon.blogspot.com. I ended up updating it more than any of my other blogs, so I figured I would move it to my own server and use Wordpress for more flexibility.

Stick around for informative articles on Linux and other open source applications!

October 25, 2008 - 3:59 PM No Comments

« Older Entries

Twitter links powered by Tweet This v1.6.1, a WordPress plugin for Twitter.