All posts by chefquix

Migrating to WordPress from Movable Type

I wrote this about a year ago as a sort of log of my trials migrating from movable type blogging to wordpress. It’s somewhat tongue in cheek / stream of consciousness so take it for what it’s worth, a little insight into the mind of a developer 😉

Moving from movable type (old ass version) to brand spanking new wordpress.

who wants to deal with cgi-bins, I mean really

movable type has an export feature, yay. Seems like it’s supported with some old version of wordpress. Let’s see, ok, generates proprietary format but it makes sense, does an export, looks like this:

AUTHOR: ChefQuix
TITLE: A little bit of everything…
STATUS: Publish
ALLOW COMMENTS: 1
CONVERT BREAKS: __default__
ALLOW PINGS: 1
PRIMARY CATEGORY: Armageddon
CATEGORY: Armageddon

DATE: 09/14/2003 10:52:19 PM
—–
BODY:
I’ve always wanted to write a blog,

Alright, so quickly install wordpress.

Let’s play around, old ass instructions say modify some file called import-mt.php.

http://codex.wordpress.org/Importing_from_Movable_Type_to_WordPress

Uhoh, this does not exist in the new wordpress. Not suprising, who’s really dealing with legacy shit like this anymore?

Ok, let’s see what new WP can do. Look, import from movable type is built into the tools, yay, wait what’s this, send out FTP credentials to some 3rd party site so they can FTP stuff in? Or WP can FTP stuff in? Is this really the best and most secure way to import files? Yikes.

Grab files manually, install plugin, match up old username with new username, yes, look at that, lots of imports, everything is working great! Closer inspection though..

Cut off blog entries! The old poor quote handling, poor quote exporting situation. And the IDs, not the same, how can I make an .htaccess rule to map from old to new? Not good enough!

Truncate wp_posts, wp_comments tables, lets do this again.

First things first – change old Movable Type export to include the ID.

in <mt>/lib/MT/ImportExport.pm add line in the export function:

POSTID: <$MTEntryID$>

Totally guessed at the template tag and it worked

now import.txt file as ID, will plugin work out of the box? probably not, but lets take a look

ok, import doesn’t support ID out of the box. Fair enough, it’s hard after all.

Add new case for the importer (in process_posts function):

} else if ( ‘POSTID:’ == $line ) {
$post->ID = trim( substr($line, strlen(‘POSTID:’)) );

Modify save_post function – post is saved using wp_insert_post function. Let’s take a look at what this function does and see how we can manually set the ID.

https://codex.wordpress.org/Function_Reference/wp_insert_post

Uhoh:

IMPORTANT: Setting a value for $post[‘ID’] WILL NOT create a post with that ID number. Setting this value will cause the function to update the post with that ID number with the other values specified in $post. In short, to insert a new post, $post[‘ID’] must be blank or not set at all.

Always roadblocks, so how do we work around this.

Lets take a stab in the dark, we’ll manually insert an empty table row with just the ID, then put the ID in the post variable and hope that wp_insert_post updates everything properly. Probably have to set post_date and post_date_gmt, I’m sure this is going to break a bit but oh well.

global $wpdb;

if (!empty($post->ID)) {
$wpdb->insert($wpdb->prefix . ‘posts’,array(‘ID’ => $post->ID),array(‘%d’));
}

scratch that, does wp_insert_post allow us to try to import the ID with the optional import_id parameter? Let’s try that less hacky way first
change modification back to:

} else if ( ‘POSTID:’ == $line ) {
$post->import_id = trim( substr($line, strlen(‘POSTID:’)) );

before we start the import up again, let’s try to clean up the file and fix some of these character encoding issues. Same old problem we always end up having – ‘,”,-,… – these characters always break. What’s the easiest solution? Load up the file in a trusty editor, find an offending character and search and replace. Get rid of the bad characters this way, then save it and do the import.

Ok, so the import runs again, but the IDs, they’re not matching up? What’s going on, time to dig deeper…

Add some debug code..

if (!empty($post->import_id)) {
printf(__(‘converting import_id %s’, ‘movabletype-importer’),$post->import_id);
$post->import_id = intval($post->import_id);
} else {
printf(__(‘wtf missing import_id’, ‘movabletype-importer’));
}

WTF? Importing post Are you also divergent, friend?…wtf missing import_id (2 comments)

Ok so that’s a problem it seems.

Ugh, bad code! Copy pasta from the wrong type of tag, of course it didn’t work. One more try, remove old POSTID bit and put in this:

} else if ( 0 === strpos($line, ‘POSTID:’) ) {
$post->import_id = trim( substr($line, strlen(‘POSTID:’)) );

Duhhhh think before writing code kiddos. Truncate wp_posts, wp_comments, and run one last time, this should fix everything for everyone in all instances…
And it works! Now that the IDs are normalized, I can htaccess example in old link from moving from MT to wordpress to make sure all pages get redirected to the new proper pages. Hoorray!

To make the redirects from the old URLs to the new ones, you just need to do a mysql query and copy and paste it into the WordPress .htaccess file:

mysql -u root -p -N -B -e “select concat(‘Redirect 301 /archives/000′, LPAD(ID,3,’0’), ‘.html /’, DATE_FORMAT(post_date, ‘%Y/%m/%d’), ‘/’, post_name, ‘/’) FROM perceptionalism_2.wp_posts”

(changing of course the user, database and what not for yourself).

This produces an output of:

Redirect 301 /archives/000005.html /2003/09/20/is-there-anybody-else-out-there-thinking/
Redirect 301 /archives/000007.html /2003/09/21/inspiration/
Redirect 301 /archives/000008.html /2003/09/29/wonder/
Redirect 301 /archives/000009.html /2003/09/23/are-you-a-bright/

….

And you’re done!

Denial is Religion

Denial is a what allowed us to evolve as a species, more specifically denial of the end of life via the afterlife with religions, however religions are now holding us back as a species because the assumption that there’s a better life leads humanity to follow a dangerous path. It leads us away from a theory of mind of those around us, and keeps us focusing on our own perceptions and realities. By understanding that there is no more life but this, we come to find it all the more precious. By believing in a life beyond this one, we put off changing our ways and end up convincing ourselves that our adverse behaviours are not dangerous to the the survival of our species. That’s a problem because our denial of the way we treat our planet will eventually lead to the grand pillaging of the resources this fragile biome affords us. And then we all die, in a painful unpleasant existence, one full of strife and indignity, as we use our vast intelligence to create efficient weapons and coerce other civilizations to give up their precious resources so we can suffer less, and our existence less painful. That is not the way I want humanity to end up. That seems like an awful fate for such a promising species.
The problem is our addiction to over consumption. I think that we could peacefully live on this planet, all of us, if we just tailored back our rampant consumerism. If we directed that singular desire to want something into a less destructive resource. At least that’s what I think anyway.

QRB.ca – mobile landing pages

It’s been a while since I’ve posted, but I thought I might do a little update on what I’ve been up to for the none of you that visit this site 🙂 My buddy stungeye and I have launched another web product, this one is specifically designed for mobile phones. At QRB.ca, you can build mobile landing pages with location specific directions for events, locations, or attractions. This is perfect for tourism, small and medium sized businesses, or event planning. Think of how many out of town guests will appreciate knowing where they are and how they can get to your wedding, or tourists in town trying to find the local attractions. It’s perfect for mobile advertising campaigns as a destination page for mobile ads. Anyway, that’s enough spiel! It’s free to try out!

Manitoba Election Website

Last year, for the Winnipeg civic election, I helped develop Winnipeg’s premier election website: WinnipegElection.ca. We were exceptionally pleased with how that turned out, so we’re doing the same thing for the Manitoba Provincial Election. So today, I’m proud to announce our launching of ManitobaElection.ca, the most trusted source of information for the upcoming 2011 Provincial Election. Many new features are in the works, but we’re launching with what we have today to get the word out.

The who of you are

It’s been a while since I’ve written anything, but a post on reddit about memory got me thinking, so I put down some thoughts about how memory works, and memristors!
* * *
I think the reason you have nobody answering is that there is no definitive answer to your question. Memory and consciousness are the big unknowns in philosophy and neuroscience, endlessly debatable and almost impossible to prove. It’s all just theories, which are little more than mental ‘what ifs’.. However, I’ll take a stab and tell you my theory.
So our brains, the most complex object that we know of in existence, are just neural networks of neural networks of neural networks. Think about how we learn, from babies to adults. I imagine that a baby’s brain is a mass of unconnected and pre-mapped out neural networks. Some of these networks will have been formed as a result of our DNA, things like controlling your breathing and heart-rate to the medulla, the thalamus and hypothalamus, probably pre-wired to route information to and from different areas of your brain. The cerebellum is probably hard-wired to control your limbs, but all of these things are connected via pathways to the cerebrum, which I’m betting is mostly unmapped.
So you have a baby, he’s born, he’s basically raw-unmapped sensations, stimulation coming in from all over the place and probably no way to process it properly. All this baby knows is that things are hot, things are cold, he’s hungry, he’s tired, he’s warm, he’s safe, he’s scared, just these raw emotions that are built in for survival. Once he starts growing, he starts learning. He sees that if he moves his hand, he can see his fingers, and if he wiggles his fingers, they move. You start getting these feedback networks getting burnt into the cerebrum, this cause and effect portions of the brain – if he cries, there’s comfort, he see’s his mom, she tickles him, little networks getting formed in the cerebrum. As the child grows up, more and more actions and stimulus are getting defined in the cerebrum. Walking, running, making sound, tying the sounds together to make speech, networks building upon networks. As the child is learning, he’s starting to chain these networks together. Associations between networks. Saying something that’s unintentionally funny to all the adults in the room, and watching them burst into laughter. Important events are getting written into the cerebrum, things that are different are getting saved for future use.
Now as he grow up, and his consciousness is forming and solidifying, he starts to see associations with stuff that happened in the past. He see’s a child saying something funny and everybody laughing, and that get’s hashed back to the time when he was a child doing the same thing. Whatever part of his brain that has evolved to be his consciousness rolls back over those networked connections that were saved in his cerebrum, and it’s played out again in his internal movie theatre guy. What exactly the nature of that internal movie theatre guy is, that’s another question and much more philosophical / spiritual.
Anyways, that’s my interpretation of how memory works. Whenever your consciousness is rolling back over the network that formed a different or important or rewarding point in your life. Most of your day to day stuff seems to be ignored, because it’s not eventful, and it doesn’t change the who of you are.
As for memristors, yes, I’m pretty sure that if they actually get developed, we’re going to see a whole new level of processing. They really do seem to be made for neural networks, however keep in mind the physiology of a computer neural network and a wetware neural network are very different – with our neurons, you have tens if not hundreds of incoming connections to the dendrites of a neuron, which is then in turn connected to hundreds of other neurons. Memristors are single input single output, but I bet that you could possibly emulate the same behaviour using a bunch in parallel or something. Anyways, that’s my two cents.

I’m proud to introduce BabyLolly.com

So over the course of the last year and a half, my friends and I have been developing a new social networking site aimed at families. Specifically, it’s an online, private babybook where mothers and fathers can safely upload pictures, videos, notes and other information about their children to an online space where only invited people can view. Some more details:

  • Photo/Video Gallery: no more cumbersome emailing of baby photos. Store and organize all your photos and videos and share them with family and friends.
  • Baby Journal: keep an online journal of your baby’s experiences and developments.
  • Baby Milestones, Firsts & Favourites: never forget an important milestone again! Capture and share all your baby’s important firsts & favourites.
  • Connect & Collaborate: give family and friends the opportunity to fully contribute to the babybook by leaving notes, uploading photos & videos, and sharing in each and every precious moment.
  • It’s a private site (so only people you invite will see your babypage) and best of all: it’s 100% free!

So if you have a family, or know someone who has a family and would like them to share their photos in an easy manner, go to BabyLolly.com and sign up! Any feedback would be appreciated.

Truth Nodes

Truth is sacrosanct to the human character. The only way we can build a philosophical construct of our identity is through cornerstones of truth, upon which we build more complex structures of truth for the purposes of explaining our reality. We all share one, indivisible truth – the acceptance of our unique perception. Everyone inately understands that the person watching the movie screen of our life is a unique individual, and something that we alone possess. But we also understand that everyone else out there is witness to their own showing, their own unique perception of the events unfolding in their life. Well we may not acknowledge it, at a fundamental level we all understand that our own reality is ours, and ours alone.
The problem lies in reconciling diametrically opposed truths. There are easy examples of this, say one person may believe devoutly in the existence of god, and one may not. These are irreconcilable, as they’re both taken on faith of their own character, and would destroy any truth structures that have been built on top. So how do you tell which perception is right?
Truth is not a democracy. The majority is not always right, as has been seen countless times in the study of science. Once an idea becomes entrenched in a society, it takes a monumental effort to prove it otherwise, as the opposing perception of truth has such momentum within the people which form that societal group. At the same time, one cannot be so plastic as to attach equal importance to each new fad idea that comes along, for it may not be grounded in truth, as much as the person promoting it may wish and believe it to be so.
This is the delicate balance, between falsehoods and truth, that we all wage in our day to day lives. It seems that few of us have the wherewithal to examine our beliefs logically, and change them accordingly and without bias towards that truth that is more truthy than the rest.

How to be an explorer of the world

Wally found these inspiring instructions written on a piece of paper while exploring Winnipeg. He made a bunch of photocopies and gave one to me. I thought they were pretty wonderful so I’ve inscribed them for all to grok.

  1. Always be looking. (Notice the ground beneath your feet.)
  2. Consider everything alive and animate.
  3. Everything is interesting. Look closer.
  4. Alter your course often.
  5. Observe for long durations (and short ones.)
  6. Notice the stories going on around you.
  7. Notice patterns. Make connections.
  8. Document your findings (field notes) in a variety of ways.
  9. Incorporate indeterminancy.
  10. Observe movement.
  11. Create a personal dialogue with your environment. Talk to it.
  12. Trace things back to their origins.
  13. Use all of the senses in your investigations.

There’s some really good advice in there for everyone.