{"id":3160,"date":"2011-01-30T17:34:43","date_gmt":"2011-01-30T21:34:43","guid":{"rendered":"https:\/\/silvercpu.com\/blog\/?p=3160"},"modified":"2011-01-30T17:40:39","modified_gmt":"2011-01-30T21:40:39","slug":"dont-try-this-at-home","status":"publish","type":"post","link":"https:\/\/silvercpu.com\/?p=3160","title":{"rendered":"Don&#8217;t Try This At Home"},"content":{"rendered":"<p>OK, so you know how I accidentally deleted my old blog a few months ago? Yes, I&#8217;m <em>that<\/em> stupid. Well, I had some of the entries backed up via livejournal and already imported those. The rest I had backed up in this long ass sql file. <\/p>\n<p>I got to thinking (thoughts can be very dangerous) that I&#8217;m pretty smart (uh huh) and I should be able to find a way to import them here. It would be fun &#8230;<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/silvercpu.com\/blog\/wp-content\/uploads\/2011\/01\/headache.jpg?ssl=1\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"3161\" data-permalink=\"https:\/\/silvercpu.com\/?attachment_id=3161\" data-orig-file=\"https:\/\/i0.wp.com\/silvercpu.com\/wp-content\/uploads\/2011\/01\/headache.jpg?fit=800%2C483&amp;ssl=1\" data-orig-size=\"800,483\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"headache\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/silvercpu.com\/wp-content\/uploads\/2011\/01\/headache.jpg?fit=800%2C483&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/silvercpu.com\/blog\/wp-content\/uploads\/2011\/01\/headache.jpg?resize=800%2C483&#038;ssl=1\" alt=\"\" title=\"headache\" width=\"800\" height=\"483\" class=\"aligncenter size-full wp-image-3161\" srcset=\"https:\/\/i0.wp.com\/silvercpu.com\/wp-content\/uploads\/2011\/01\/headache.jpg?w=800&amp;ssl=1 800w, https:\/\/i0.wp.com\/silvercpu.com\/wp-content\/uploads\/2011\/01\/headache.jpg?resize=300%2C181&amp;ssl=1 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<p>First, I imported the sql file into a fresh database. Then I exported those entries as xml. I wrote a perl script to parse the xml and put it into <a href=\"http:\/\/codex.wordpress.org\/Importing_Content#Importing_from_.5BX.5DHTML\">RSS format<\/a> so I can use the RSS Import Plugin import the posts into WordPress. This all should have been much easier than it actually was &#8230;<\/p>\n<p>My first problem was that I had to convert the date into RFC-822 format without any perl Date modules because I couldn&#8217;t figure out how to install them. I had to hard code some stuff, but I figured no one else is going to be using this piece of crap script anyway. I also had to do things like convert the html encoding for < > into the actual symbols and get rid of escaped quotes.<\/p>\n<p>After all of that, I was able to run my script and import my posts. Most of them anyway. Between June of 2002 and June 2003, I started using b2. I guess some b2 developer decided it would be a good idea to have <a href=\"http:\/\/en.wikipedia.org\/wiki\/Quotation_mark_glyphs\">smart quotes<\/a> on by default. MySQL doesn&#8217;t seem to care for smart quotes much. What I didn&#8217;t realize is that when those posts were imported into the database, mySQL cut them all off after it saw the first smart quote. I had 402 unusable blog posts.<\/p>\n<p>So I went back to my perl. I wrote a script to get rid of the smart quotes and escape them properly. Then I imported all of the posts into the database again, deleted the ones that came out OK the first time and exported the newly unsmart quoted posts. Then I ran my script on those. I deleted the junk posts from wordpress and imported the good ones.<\/p>\n<p>Then I hit another problem. Some of the posts were somehow identical to the ones I already imported and deleted and the importer didn&#8217;t want to import them again. I had to modify my perl script so it only outputted the ones that didn&#8217;t want to import and change the timestamp by a second. Then I imported them again.<\/p>\n<p>It was worse than it sounds. On the bright side, I have all 1400 or so posts now in a readable format and maybe I did have a little fun in a totally geeky way.<\/p>\n<p>I started using blogging software in December of 2001, so anything before that was either done in notepad or copied from my handwritten journals. Most of the posts are badly written and boring, so I only recommend reading them if you&#8217;re having trouble sleeping.<\/p>\n<p>Did you ever start a project you wished half way through that you hadn&#8217;t?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OK, so you know how I accidentally deleted my old blog a few months ago? Yes, I&#8217;m that stupid. Well, I had some of the entries backed up via livejournal and already imported those. The rest I had backed up in this long ass sql file. I got to thinking (thoughts can be very dangerous) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[],"tags":[],"class_list":["post-3160","post","type-post","status-publish","format-standard","hentry"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bQP0-OY","jetpack_likes_enabled":true,"jetpack-related-posts":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/silvercpu.com\/index.php?rest_route=\/wp\/v2\/posts\/3160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/silvercpu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/silvercpu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/silvercpu.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/silvercpu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3160"}],"version-history":[{"count":3,"href":"https:\/\/silvercpu.com\/index.php?rest_route=\/wp\/v2\/posts\/3160\/revisions"}],"predecessor-version":[{"id":3163,"href":"https:\/\/silvercpu.com\/index.php?rest_route=\/wp\/v2\/posts\/3160\/revisions\/3163"}],"wp:attachment":[{"href":"https:\/\/silvercpu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/silvercpu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/silvercpu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}