Windows Live Writer: Picture Upload Not Supported by Blog

The scenario is, you have a custom install of WordPress and you’re trying to upload a blog post that has pictures included but you get the error “Picture Upload Not Supported by Blog”.  WordPress does support this, so you have two options.

  1. You can configure Live Writer to FTP the pictures to your blog.  This solution works fine, but I’d rather fix the problem that caused the above error.
  2. To fix the above error, you need to create an “uploads” inside of the wp-content folder in your WordPress installation.  (yourBlog/wp-content/uploads).  It’s very important that you then set permissions on this folder so the site can write content to it.  If your web server is a unix/linux blend then you can use most FTP programs to set the folder permissions to 777.  If you are using a Microsoft IIS web server then you’ll need to find a utility to set the permissions on the folder to read/write for both yourself, and the IUSR user that the site uses.  My web host Brinkster has a utility available on their page that allows for these type of changes in their setup.

Internet Explorer Error: SCRIPT5009: ‘JSON’ is undefined

Symptoms:

You may notice that your jQuery application stops working without throwing any JavaScript error messages, but the same code works in Chrome and FireFox.  There are a few reasons this could happen.  First, you could be using an older version of IE (like 7) where JSON is not natively implemented and you have to force its inclusion.  Second, your newer IE browser may be running in compatibility mode which is making it behave like IE7 and thus not including JSON natively.

Solution 1:

  • Setup your HTML so that the browser does not run in compatibility mode.  This will ensure that the IE8/IE9 engine renders the page.  The downside of this is that your page will still fail on IE7. 

Solution 2:

  • Manually include the JSON library in your page.  You can either include it with all page loads or specifically check what browser the user is using and only send it to browsers that need it. 
  • The file that you want on the below link is “json2.js”.  Newer browser should ignore this file if you include it, but it will allow older ones to work.
  • You can find the JSON library here:  https://github.com/douglascrockford/JSON-js
    • If you included this in the same directory with your HTML you would just add this somewhere below your jQuery inclusion with a:  <script src="json2.js" type="text/javascript"></script>

My choice and recommendation is solution #2 which is what I’ve use whenever I’ve run into this issue. 

WordPress: SQL to select latest articles

This is just another post with some SQL that will run against the WordPress database.  This snippet selects the latest 5 articles.  You can change the value in the limit portion of the SQL to bring back the exact number you want to see in your record set.

select id,
    post_title
from wp_posts
where post_status = 'publish' and post_type = 'post'
order by post_date desc limit 5                                      

WP7–Using Microsoft Advertising / How you get paid

The two main ways to get paid through your WP7 app are by selling your app and by placing advertising in your app (excluding in app sales which I’m not sure are approved for Windows Phone at this point).  If you stick with Microsoft for both then you will get paid in two different ways. 

First, you can get paid by selling you app.  To get paid, you will need to meet the minimum threshold of sales which at this point is $200.  This means, Microsoft holds onto your sales money until you hit that threshold.  This is irrespective of any ad sales you make, it has to be $200 in people purchasing your program.

Second, you can sell ads through Microsoft Pubcenter.  Microsoft has made it easy to integrate ads into your program via the AdControl which is natively included in the tools released with Mango (SDK 7.1).  All you have to do is create a pubcenter account, create an ad unit and then place the ID they give you into your control.  To be paid through this service, you must meet a threshold of $50 and it is irrespective of any program sales. 

In an ideal world, the ad revenue and the app sale revenue would travel through the same account contributing to the threshold and increasing the chances you’ll be paid more quickly.  In a bureaucratic world, these are two MS departments with two totally different setups (as I was told in a form post either at the pubcenter or the app hub, can’t remember which now).  For the foreseeable future, they are separate.

The above is if you stick with a total MS revenue solution.  You can also go outside and use something like Google’s AdMob.  I use AdSense for my web-site so I’ve investigated this route as it seems appealing, but I also don’t know yet if AdMob is paid separate than AdSense. 

Thus far, I have revenue with multiple services but I haven’t met the minimum threshold in any to receive a payment.  If I could only pool them it would work much better for me actually getting paid (total, of all services I think I’ve made $50 in revenue over a few months).  :)  I would seriously consider changing to a service that allows me to pool web ads, with mobile ads in the same account.  Just to say, I never expected to make much, it’s more of a hobby project to see if I could.

VB.Net – Simple Function to do an nslookup

This is just a simple example function that will return a string with some DNS lookup information for an ip address or host name.  You may need to import System.Text and System.Net if they’re not imported and you have compile errors.  I believe this only works for DNS A records.  If you need something more in depth to look at DNS SRV records then you may need to look at using the Windows API (specifically look for “dnsapi” library calls).  If I can remember I’ll try to post an example using that in the near future.

    Protected Shared Function DnsLookup(ByVal hostNameOrAddress As String) As String
        Dim sb As New StringBuilder
        sb.AppendFormat("Lookup: {0}{1}", hostNameOrAddress, vbCrLf)

        Dim hostEntry As IPHostEntry = Dns.GetHostEntry(hostNameOrAddress)
        sb.AppendFormat("  Host Name: {0}{1}", hostEntry.HostName, vbCrLf)

        Dim ipAddresses As IPAddress() = hostEntry.AddressList

        For Each ip As IPAddress In ipAddresses
            sb.AppendFormat("  IP Address: {0}{1}", ip, vbCrLf)
        Next

        Return sb.ToString
    End Function

Internet Explorer crashes when a phone number is displayed on a page

Problem:  IE crashes whenever a page with a phone number, or a number with the same number of digits is displayed.

  1. First thing to try, run IE in safe mode (you can find it through your start menu, it’s called “Internet Explorer (No Add-ons).  Navigate to the page that crashed your browser before and see if it crashes.  If it does not, the problem is very likely related to a plugin that is being loaded.
  2. Identify plugins that might be rewriting the HTML before it gets rendered.  This could be any number of plugins, but in my experience Skype has always seemed to be an offending plugin.  In my case, disabling the Skype plugin stopped this behavior.  Something it was doing re-writing phone numbers was crashing the browser (it rewrites them on the page when it seems a phone number pattern so that you can click on them and shell out to Skype). 
  3. If #2 doesn’t fix the problem, you’ll want to re-enable the plugins one by one to find the offending one.

“No Device Connected” – Windows doesn’t recognize your Windows Phone 7 device is plugged in

Periodically Windows stops detecting my phone, therefore, it doesn’t sync and I can’t deploy or debug applications on it.  There are a few solutions for this.  The one that’s worked for me every time is simply a reboot, then reconnect the device after you log back into Windows.  However, for those that a reboot doesn’t work for you might want to check out this Microsoft support article with a few more fixes (a couple manual and a couple automated with Fix It apps).  You’ll want to try to reboot first before applying any of the MS patches (as it is by far the least invasive to your system). 

  1. http://support.microsoft.com/kb/2410180

WordPress: SQL to select a post programatically by ID

Here’s some code to select the current version of a post given that you know the ID of it from a previous query.  For additional WordPress queries see this related articles:

  1. Get all posts by category:  http://www.blakepell.com/Blog/?p=390
  2. Get all distinct categories:  http://www.blakepell.com/Blog/?p=312
SELECT *
FROM wp_posts
WHERE ID=300 AND post_status = 'publish'

WordPress SQL to get all posts by Category

Here’s some SQL to get all posts in WordPress for a given category id.  This is assuming that you have the default “wp_” prefix on the table name and you know the “term_id” of your category.  If you need a query to get the categories with term_id’s for them, see this blog post for the SQL:  http://www.blakepell.com/Blog/?p=312

SELECT * FROM wp_posts
INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
INNER JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)
WHERE (wp_term_taxonomy.term_id = 23
   AND wp_term_taxonomy.taxonomy = 'category'
   AND wp_posts.post_type = 'post'
   AND wp_posts.post_status = 'publish');
   

How to remove a network drive from Windows Explorer when it doesn’t want to go away.

You know the story, you pop in a flash drive, it doesn’t appear on your drives list but you notice you have this disconnected network drive that’s been hanging on for a while to a computer that doesn’t exist anymore.  You double click the network drive and sure enough, Windows takes you to the Flash drive that it can’t find.  You can disconnect the drive, try to delete, drag it to the recycle bin and it will resurrect itself (it never actually goes to any of those places, so I guess it doesn’t actually resurrect itself).  Anyway, here’s a few steps to get rid of it:

  1. Click Start
  2. Right click “Computer” and choose “Map Network Drive”.
  3. Map a network drive with the same letter of the drive you want to get rid of.  If you don’t have a network drive, use this “\\YourComputerName\C$”.  It will map to the root of your C drive.  Now here the important part, uncheck “Reconnect at Login”.  You don’t want to reconnect.
  4. Right click on the drive in the drives section of “Computer” (can’t help by saying “my computer” still).  Choose “Disconnect”.
  5. Reboot your computer.

When you log back in, the drive will not be there.  Took a few screenshots of the locations/screens you’ll see.

image   image