How To Find the Private Key For the Delicious API

I’d like to write a python script that looked at my Delicious Bookmarks and checks to see if they are dead links. This is possible because Delicious has an API. And you can just ask for what you want by asking for a specific URL.

That works fine as long as you don’t want your private bookmarks. If you want them, you have to:

{key} = a security key for the feed, which can be found via the page associated with the feed (eg. inbox, network or bookmarks). Allows visibilty to otherwise private data.

But there is no explanation of how you find the key. It says via the “page associated with the feed”. But it’s not. Not anymore, because Delicious changed its look and in the process hid its RSS feeds.

As an aside, when did RSS because pariah? Google drops Readers, Delicious hides its RSS feeds. What’s up?

But you can still find the needed private key by signing in to your account and going to{username}/

Over on the right side, you’ll see something like the image at the right: Delicious Sidebar

The URL for the “Private” link has your key in it.

You can get it by right clicking and using “Copy Link” or your browser’s equivalent. The private key is that big bunch of letters and numbers after the “?private=”. Just put it on your request URL the same way.

BTW: this key may change if you change your password.

Corona SDK Game Project Post-mordem

This past semester I audited Intro to Digital Entertainment at ACU. I’ve always been interested in video game development and wanted to learn more.

For my final project I decided to write a video game using the cross-platform mobile SDK, Corona. That project was due last Thursday and I decided to post my thoughts on the framework I used.

The teacher of the class, Dr. Brian Burton, has written a book “Mobile App Development with Corona”. I decided I’d give it a try for my project because he’d given us a sample to start from and was so positive about it.

Well the project is done and at our presentation we got a lot of positive feedback about the game. I learned a lot doing the project, so here are my thoughts on developing with Corona.


You can get a lot done very easily. This is really one of Corona’s biggest pluses. Want to display a graphic on screen? One line of code.

background_image = display.newImage( "images/paper_bkg.png" )

Want sprite animation? One line of code.

ship.sp_ship = spriteSheet:grabSprite("ship.psd", true);

Want to move it from point A to point B?,{ x=1000, y=1000, rotation=45, time=1000, onComplete=finishShipMove, transition=easing.outQuad })

Adding collision detection, gravity effects, and many other features are very easy to do. I gave my son access to Dr Burton’s book and my laptop one day during Thanksgiving and he had sprites flying around in no time. The goal of Corona’s founders is to make an environment for non-programmers to make games.

Aside: I think this goal is part of my frustration. I kept expecting things a professional programmer would want from an environment and language.

The Community is Helpful.

A couple of times I posted to the forums and someone always responded back quickly. The people who use Corona love it and want to help others. I expect this post will get comments from people at Corona Labs, because I’ve seen them do it for other posts about Corona.


Lua. You write all of your game code in the language Lua. When you are writing a cross platform framework, you have to pick a language to write in because the various platforms all use different ones. Android uses Java. iOS uses Objective-C. Corona uses Lua.

My understanding is the main reason for picking Lua is the interpreter only adds 500k to the executable, which is an important consideration when you must have your framework code and the interpreter in every app you make.

But frankly Lua sucks. I could really go on and on with details, but I’ll try and be succinct.

Lua has no object-orientedness, but it looks like it does. (I didn’t realize how dependent/addicted to OOP I was until I didn’t have it) In Lua just about everything is a table – what Objective-C calls a dictionary – a list of key value pairs. Even arrays are tables where the keys are the array indexes. The reason Lua look like it has objects is you can set function “pointers” as values, so to call a function on a table it looks like an object function call. See the display call above. But there are no constructors/destructors. You can’t just release and object and know it will get rid of all its data, you have to write not just the dealloc code, but the mechanism.

This also leads to very strange scoping of variables, which I still don’t fully understand. But all globals are really in a secret table called _G. You can add variables to an “object” just by assigning them – better not make a typo in an assignment. This can be useful, for instance the SDK uses this when turning display object into physics bodies. You pass it a display object and it adds all the variables and functions needed for collision detection to it.

But then in other instances you will pass an “object” into a function that calls back later but when you get the callback you no longer have all the parts you passed in. And there is a “self” variable, which I never figured out.

What this means is you really have to give up on encapsulation. Once you realize everything should just be a global, life in Corona gets much easier.

The Corona Toolset is Primitive. The other problem with Corona is it lacks the support tools to make easy to use. Really there are no tools from Corona itself. You edit text files in whatever editor you want, then launch the simulator and point it to your main.lua file. Then things run.

The Documentation if Weak. Corona staff have freely said their docs suck. I wouldn’t go that far. I never found any API there wasn’t at least a minimal explanation of. (Except a break down of what fields are available in config.lua) I remember times Apple’s own docs have been worse. But there isn’t much depth. Not enough explanation of why things work they way they do. Also the overview/tutorials are spread across their blog and only occasionally linked to from the relavent API pages.

There’s no IDE. There are some third party ones, but none as slick and complete as say XCode.

There’s no Debugger. Well there is a command line debugger, but it was easier just to debug via print() than to figure that out. It really, really needs a visual debugger.

The Simulator is only kind of a simulator. Seems to me the Simulator is a OpenGL-only window. Since Corona is mainly for games, most of what it does is in OpenGL. The Simulator just shows you this stuff. This becomes obvious when you want to do something like put up a native alert, or use the keyboard for input. Can’t be done in the simulator. There are also performance differences between OpenGL on your Mac in the simulator and on your iPhone/iPad, which it seems a simulator should simulate.

“But Ron, you can always use the iOS Simulator.” No, you can’t debug in the iOS Simulator. Which I discovered and panicked the first time something ran fine in the Simulator and hung in the iOS Simulator.

This is partially a function of Corna and partially an Apple problem. The Corona side is they have separated you from the actual OS – that’s the price you pay for cross platform – and therefore you don’t get the access that would allow you to use a real debugger.

The other is classic Apple. When iOS 6 came out, Apple decided to limit app’s ability to output to console. Specifically they didn’t want apps like Corona let the Lua scripts output to console. So in order to debug via print() I had to write an entire set of logging routines (kind of an object) that would log to a file instead of stdout. A royal pain, but not one I blame Corona Labs for.

I won’t complain about the fact if you want to build something to run in the iOS Simulator or your device, Corona requires a round trip via the Internet to do the compile and build, and that roundtrip is purposefully delayed by 20-30 seconds if you aren’t a paying member. That’s a valid shareware limitation.

I do wonder how many of these complaints would go away if the Corona SDK were a library you included in XCode and did your coding and debugging there. But that doesn’t really work for the cross-platform nature of the framework. Also it doesn’t appear XCode understands Lua, but hey maybe they could change to Python which would solve almost all my Lua problems. (Ahh Corona that I could program in Python, that gives me a warm fuzzy feeling just reading it.)

This has gone on long enough, but I knew it would be long. I’ve essentially worked full-time on this project for a month, so I’ve had time to build up some complaints.

The other possibility is I’m full of it, since I haven’t used other tools, maybe I don’t know how easy Corona is. I’ll know by the end of the year. I’m going to do is rewrite my game using Cocos2d and Chipmunk. There are two reasons for this.

Firstly I need an iOS app in the AppStore. I’ve been looking for a programming job and most people who are looking for iOS programmers want them to have an app in the store. Don’t know how well an interview would go if I said, “Well it’s in the store but I didn’t write it in Cocoa.”

Secondly, this will let me work where I’m comfortable. I’ve done MacOS programming for almost 20 years now. About 9 of those using OSX/Cocoa/Obective-C. I can apply those skills to to my game if I write it in a native format.

Scripting XCode4 To Generate Method Comments

This article will show you how to use a python script to generate a comment from the actual declaration of the method.

So you’d have something that looked like this (Click image at right for bigger)

XCode 4 Doesn’t Support Scripting of Any Kind

XCode 4 removed the Script Menu and all the hooks that used to be there. They don’t even let you use AppleEvents to set the selection. Read the How This Script Came To Be section of the post for more details.

What you have to do is create a Service that receives the selected text, pass it to your script as an argument, then takes your script’s output and replace the selected text with it.

I wrote a Service once a long time ago using XCode and Cocoa, but that’s really way more than we need to do. Instead we will us Automator to handle the Service part for us.

Create An Automator Service

1. Launch Automator.
I just hit Cmd-Space, and start typing till I see it. But it’s in the Application folder if you’d rather click to it.

2. Create A New Workflow.
Cmd-N, or File > New

3. Select “Service” from the Choose Type Panel

4. Find the Run Shell Script Action.
If the Library isn’t showing, click the button in the tool bar, or View > Show Library.
Then there is a little search field at the top, type in Run and you should see the action (like the image at the left).
Drag the Run Shell Script action to the right hand panel.

5. Configure the Run Shell Script Action.
The core the commenting work is the script. I’m specifically using it to make method comments, but you could write your own script to do anything. Brian wrote scripts that aligned selected routine names so the colons lined up vertically, that’s pretty cool. I’ve written scripts to take a list of serial numbers and format them as variable declarations to a pirate list. The sky is the limit.
Select /usr/bin/python form the Shell: popup. You could also write your script in a different language. If you do select a different shell from the popup.
Here’s the script I’m using for the commenting:
I’ll talk about the details in a minute, but right now downloaded it, open it in a text editor like TextWrangler or even XCode, copy its content, and paste it into the Run Shell Script text area.

6. Save your Automator Workflow
Cmd-S, or File > Save. Instead of a standard save dialog, you get a little panel that says “Save service as:” and lets you enter the name you want to use. Pick carefully because this is what will be in the Services menu. And I couldn’t figure out how to change it later. Ended up duplicating the file just to change the name.
The Automator file is actually created in ~/Library/Services.

That’s it as far and hooking up the script. You can try it out by opening some code in XCode4, selecting a declaration in the code, and going to Apple > Services > Generate Method Comment, or whatever you named it.

A new comment will appear and you can even Shift Tab and get taken to the description bubble for editing.

You also can do this in most text editors, so even is you dont’ use XCode you can use the service.

How the Script Works

I won’t go into the details, because I think I did a pretty good job documenting it. Basically it just parses through the string, finds the parts it needs, and generates strings for the comment. It doesn’t really try to understand the code, it just gets what it needs to generate what I want for the comment.

You can go in and change the print statements in main() to reformat it to your comment style.

Debugging An Automator Shell Script Service

Editing and debugging a script in Automator is a pain in the ass, to the point it really isn’t viable . For one you can’t run the Service in XCode and get any feedback in Automator. What Automator will suggest if you click the run button, is you add a “Get Specific Text” action before and it’s output will be passed to your script. This “works”. You run and fail in Automator.

But you can’t read python error messages in the Automator Log window. You only get the first line of the error, which is bad because python outputs a traceback first, so every error is multiple lines long.

Here’s what I ended up doing.

Really you need to run it from the command line, and you need a real text editor, not just a text view. So I opened a new document in TextWrangler (for some reason it seems wrong to use XCode4). I pasted the code from my Automator action into the TextWrangler document and saved it as a .py file.

You’ve got my .py file to start with. You’ll need to change the name of the file you downloaded. I had to add .txt to the end for security reasons.

To run your script you are going to use python from the command line in Terminal. Find where you saved your script and cd there in terminal. Type “python” and you’ll get a wonderful error message because there is no text passed in to parse. No arguments at all.

You could add a string of a method declaration to your command line, but one thing you’ll want to test is how your script handles multi-line declarations.

Luckily I’ve given you a way in the code. Look at line 26-29:


# for debugging here are some string to parse.
testString = “- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation”

And then at 102-103:

if TESTING: routineName = testString
else: routineName = sys.argv[1]

If you set TESTING to True, then instead of using a passed in argument from the command line, the code uses testString, which is defined on line 29. Make Testing True and go back and rerun your script. Now you will see a comment.

There are a few other bits of debugging code I left in, but commented out. Hopefully they make sense if you need them.

Some things you might want to watch out for when debugging your own scripts here.

Multi-line inputs. If the declaration has returns in it, you can run into problems. For me I take out all of the returns and get a flat declaration before processing.

Tabs and Spaces. There is a difference and they can trick you. There are places in the code where I search for whitespace/code breaks by looking for a space. Really I probably should look for a tab character too.

Formatting Output. Tabs and spaces are a pain on output too. Luckily we’re programmers here and are probably using a monospace font for our code. So I just used spaces for tabs. Matter of fact I wrote a little routine that generates a number of spaces. Then I made a convenience method that returns a tab. Then I can just put it in a print statement and have a “tab” of spaces. There is also a constant for the number of spaces in a tab, so you can easily change it is you want more or less.

How This Script Came To Be

I was away from coding for months and then got a gig converting a board game to the iPhone/iPad. With much excitement I updated my tools to XCode 4 and jumped into it. There are a lot of cool features and I was overall impressed. Then I wrote my first code and realized I hadn’t migrated my scripts that generate method headers by selecting the method declaration in the code.

One of my former co-workers, Brian Webster of Fat Cat Software, had written a cool script to do it, and we put them in XCode 3’s script folder and were off to the races.

You know how it is with things like installing script menu items or editing templates etc that you did once along time ago. I couldn’t figure out where the scripts went. Then I starting looking around online and realized quickly the Script Menu was GONE in XCode4. Matter of fact there was NO way to even get the selection and pass it to AppleScript and then set it back.

I looked around occasionally for a couple of months and never found a way to do it. But today I got a little fed up. Code Snippets just weren’t doing it for me, so I went looking again. General consensus was Apple had screwed its developers again and there was no way to do it.

Then I found Brad Oliver’s post on using Automator and Perl to do it. That was all I needed, I could figure out how to replace the selection now. I just needed to find those scripts again. And I couldn’t. So I emailed Brian and started building the Service to do the replacing. When I had that figured out, I hadn’t heard back from Brian, so I just started writing my own script to do the processing.

I wrote the scripts in Python which I had never used before. I’d avoided Python because the idea of using indentation as bracketing had just rubbed me wrong. But I’d been looking into doing some game programming and found there are a lot of 3D engines that are scripted via Python, so I’d decided to learn it. This seemed as good a time as any. I was pleasantly surprised. I made a lot of progress in a relatively short amount of time, especially considering I knew nothing of the language this morning.

Hopefully this post will help you both scripting XCode4 and commenting your code better. If you have any questions feel free to ask them in comments.

UPDATE: 07/17/2012 made a change to the script to handle routines with no parameters.

How To Send URLs From iPhone to Home Browser

I’ve run in to many times where I’m browsing on my iPhone or iPad and want to browse a page at home, but there is no easy was to send the URL and have it just open in my desktop machine’s browser. Well today I figure it out and here’s how you do it.

You will need:

  • An AIM client on your iPhone/iPad – I’m currently using Beejive AIM, but that may change.
  • A “remote” AIM account and a home AIM account.
  • A Mac with iChat running – set it to auto launch at login.
  • My cool AppleScript to glue it all together.

The AppleScript

1. Copy this script and save it in your iChat Script folder. Generally that’s in your home folder /Library/Scripts/iChat/.

using terms from application “iChat”
on message received theMessage for theChat
if theMessage contains “http” then
tell application “Google Chrome”
set URL of active tab of window 1 to theMessage
end tell
end if
end message received
end using terms from

Couple of notes about the script.
We’re going to link this script to a specific buddy. If you linked it to everyone, then any URL in any chat would open in your browser. You don’t want that.
Because we don’t check the buddy in the script you can connect it to two or more buddies and any of them could open URLs.

Set Up AIM programs

You want to add both accounts to the buddy list of your phone AIM program and your desktop’s iChat.
Add your “remote” AIM account to your home AIM’s buddy list.
Add your home AIM to your phone’s buddy list.

In iChat select your remote account’s buddy and select Buddies->Show Info. A window will open, select the Alerts tab. Check the “Run an AppleScript script:” check box. From the popup select the script you just saved to your iChat folder.

If you save your script somewhere else and select it from this pop up using “Choose Script…”, iChat will copy it to the iChat folder, not use it where it is. So if you edit it where you saved it, iChat won’t see that change.

That’s it. Now send an text message with a URL in it.

Couple of caveats.
If you use Beejive AIM on the iPhone it has a UI weirdness where you have to start typing a message before you can paste. So type a space and then do your paste.
If you send something else besides the URL in the text message your browser will give AppleScript an error. A beginning space doesn’t count, so it’s OK.

Custom RSS Feed for a Podcast Category

I’ve started a podcast for my site. To make things easier I just made the podcasts their own category in WordPress and created a feed burner feed for that categories RSS2 feed.

The first episode went out and I subscribed to it in iTunes by entering the Feedburner RSS feed. And the name for the podcast was wrong. It was “Glamour Apprentice >> podcast.

The reason for this is the RSS2 template in WordPress uses the blog’s title, desciption and URL for the header information in all of its RSS feeds. I’m not positive this is the way to handle it if the feed is a category feed, but that’s the way it is.

Looking for a Solution.

I went looking for away to change this information for my category feed. I found this article on how to change the RSS title returned by hacking the feeds.php file in your WordPress installation.

That would work, but you have to remember to save your feeds.php files every upgrade. And since that can happen automatically, that’s a pain. You just shouldn’t change any file outside of the wp-content directory in WordPress.

The Solution

Now that I know where to look, I realized there were hooks to change these same routines without editing them directly. I’d hoped maybe I could just change things in my theme, but that didn’t seem to be possible. Plus the right solution would be theme independent.

The solution is to write a very simple Plugin. Which is what I did. Here’s the source:

< ?php
 * @package Podcast Category RSS Name Changer
 * @author Ron Davis
 * @version 0.1
Plugin Name: Podcast Category RSS Name Changer
Plugin URI:
Description: Hack to change the name of my podcast category RSS to the name of the podcast
Author: Ron Davis
Version: 0.1
Author URI:

function changeCat() {
     if (in_category('28')) { 
        echo 'The Shooting Beauty Model Photography Podcast'; 
     } else
     	echo get_wp_title_rss(); 

function changebloginfo_rss($result='', $show='') {
     if ( in_category('28') )
 		switch ($show) {
			case 'name':
				$result = ''; 
			case 'url':
				$result = '';
			case 'description':
				$result = 'Engaging interviews with photographer and models discussion the art and collaboration.';
        return $result;
     } else
     	$result =  bloginfo_rss($show); 
	return $result;

add_filter('wp_title_rss', 'changeCat', 1);
add_filter('bloginfo_rss', changebloginfo_rss, 1, 2);



Warning: it is just a hack. It is very specific to my blog, and if you use it you are doing so at your own risk.

What I wanted to do was get rid of completely the blog title, and then instead of the category name, use the podcast’s title. While investigating I discovered it was using the blog’s description and URL, which I also wanted to change.

You need to know the category number. You can find this in your WP Dashboard under Posts->Categories. You enter that in the lines 17 and 26. My podcast’s category was 28. You could use the name of the category, but you might change that later and it would break the plugin.

On line 18, you enter the title of the podcast. This will replace the BlogName >> CategoryName default.

Then you would replace the information name, url, and description with your values.

Upload the text file with a name like “podcatchanger.php” into your plugins directory on your site, then activate the plugin in your Dashboard.

That should be it. Your RSS feed should have the correct information in it now.

This could be made more generic, maybe given an interface, but I don’t have time for that.

Good Work If You Can Get it

When I took my current job I said it would probably the last one I ever had where I worked for someone else. My idea was to learn to work for myself. But if I could find a company in Houston that worked like this, I’d go work for them.

From a high level, Google’s process probably does look like chaos to someone from a more traditional software development company. As a newcomer, some of the things that leap out at you include:

– there are managers, sort of, but most of them code at least half-time, making them more like tech leads.

– developers can switch teams and/or projects any time they want, no questions asked; just say the word and the movers will show up the next day to put you in your new office with your new team.

– Google has a philosophy of not ever telling developers what to work on, and they take it pretty seriously.

– developers are strongly encouraged to spend 20% of their time (and I mean their M-F, 8-5 time, not weekends or personal time) working on whatever they want, as long as it’s not their main project.

– there aren’t very many meetings. I’d say an average developer attends perhaps 3 meetings a week, including their 1:1 with their lead.

– it’s quiet. Engineers are quietly focused on their work, as individuals or sometimes in little groups or 2 to 5.

– there aren’t Gantt charts or date-task-owner spreadsheets or any other visible project-management artifacts in evidence, not that I’ve ever seen.

– even during the relatively rare crunch periods, people still go get lunch and dinner, which are (famously) always free and tasty, and they don’t work insane hours unless they want to.

Now the article this quote comes from is really a rant against Extreme Programming, mis-labeled as Agile programming. But this description just blew me away. How can Google live doing this? Especially the second one.


If you do anything with web design you should check out Xyle.

It is a very cool tool for analyzing he style sheets of websites. The interface is awesome. My office mate, who doesn’t do any web stuff that I’m aware of said you should register just on the principal of it being so cool. I’m going to work with it some this weekend, but will probably pay the very reasonable $14.95.

And it is OSX only so if you are windows user you should look at the site just to eat your heart out.

Technorati Tags: , ,

Squible, A new kind of blog look.

This is the demo site for Squible, a WordPress theme. It is really different and takes a totally unusual approach to how a blog should look.

For one it only shows you part of one post on the main page. It also puts your blogroll on another page. It is based on tag and not category organization. All in all very interesting.

I’m thinking about a new site that will look to a reader a lot like a blog. I want the front page to be simple and have the latest entry front and center, but I need some other information on the site and the page. So I have been considering the “below the fold” organization that Squible shows. More inspiration is always good.

Technorati Tags: , , ,