Floyd’s Worthwhile Endeavor v0.8.4 Released!
A new version of Floyd’s Worthwhile Endeavor is now available on the App Store.
Here are the highlights of this release:
- Five new types of hats!
- Elephants are less dangerous: they can only kill you when you then are walking towards you.
- Better memory usage
- New help text in Level 1
- Bug Fix: Floyd no longer falls through rope bridges
- Build 1201: Game has been built 358 times since last revision (11 days ago). That’s an average of 32.5 builds a day.
- Email support (at) decided.ly with bug reports or use the contact form on this site.
Presenting Floyd’s Worthwhile Endeavor
For the past eight months, I have been working on an iOS game based on the photography of Eadward Muybridge. As of this week, the game is now in the App Store. Since my quiet soft-launch earlier this week, it has already been downloaded more than five thousand times!
- Main Menu!
- Floyd runs atop a floating island
- Floyd leaps off an elephant’s back
- Floyd jumps a rooftop onto a building below
- Floyd rides and elephant across a rope bridge
- Floyd jump from fiery island to fiery island
- Floyd jumps onto a rope bridge
- Floyd meets an ostrich for the first time
jsTaskPaper: Display Taskpaper Todo lists as HTML using Javascript
For the longest time I’ve wanted to set up a giant billboard-style to-do list in my office–something that would be so big that it would be hard to ignore.  I was tempted by Panic’s gorgeous Status Board iOS app, but I didn’t know how easy it would be to integrate my daily Taskpaper-based todo lists with Panic’s widgets. (Also, the thought of tying up my iPad for this project was a no go.) We have tons of old computers lying around here, all perfect for powering a read-only browser-based status board, so it seemed like a no-brainer to throw something together.
Surprisingly, there didn’t seem to be any Javascript-based TaskPaper formatters out there.  So, using Jim King’s tp_to_html.pl script as a starting point, I created jsTaskPaper, a Javascript library for rendering TaskPaper files as HTML. Here’s what the output looks like:
Usage is pretty simple. You create a div in your HTML like so:
<div id="scratchTasks"></div>
and then you invoke the Javascript lib as follows:
<script type="text/JavaScript"> $(document).ready(function(){ new TaskPaperPanel('#scratchTasks', '<url-of-taskpaper-todo-file>', 4000); }); </script>
That’s pretty much it. Once you’ve got it set up, you can style it using the taskpaper.css file.
Check it out here:Â jsTaskPaper
–Dave
TIP: How to sync your entire Sublime Text project over to your dev server with a single keystroke
If you do all of your web coding on your laptop, but don’t run a local PHP stack, you may be searching for a quick way to sync your files over to your dev server. Well, my friends, look no further than rsync. Not only is it fast and secure, but you can actually set it up to be a build tool in Sublime Text 2. Here’s how to set that up:
1. Select the Tools → Build System → New Build System… menu option.
2. A new window will pop up with the a blank template for your new build system. Here’s what mine looks like:
{ "cmd": ["./devsync", "${project_base_name}"], "working_dir": "/Users/dhilowitz/code/" }
As you can see, I don’t run rsync directly, but rather point Sublime Text to a shell script called devsync that lives in my ~/code directory. I have this file saved as devsync.sublime-build.
3. Finally, here’s what that ~/code/devsync script looks like:
#!/bin/bash if test -z "$1" then echo "Missing folder name argument." else RSYNC_TO="[email protected]:/mnt/www/$1/" echo "Syncing from `pwd`/$1 to $RSYNC_TO" rsync -avz --delete --exclude '.git' -e ssh ./$1/ $RSYNC_TO fi
That’s it! Of course, your development setup is probably not identical to mine, so you will have to play around in order to get things working properly. rsync can be a finicky thing to get working if you don’t have experience with it. You may want to do some trial and error on the command line before moving your commands into the shell script. It should be noted that it is possible to actually invoke rsync directly from Sublime Text (i.e. without a shell script). It’s also possible to set it up on a per-project basis so that you use different settings depending on which project you are working with. Here’s an example of a project file that invokes rsync directly:
{ "folders": [ { "path": "." } ], "build_systems": [ { "name": "rsync", "cmd": [ "rsync", "-avz", "--delete", "--exclude", "'.git'", "-e", "ssh", "./site/", "[email protected]:/var/www/" ] } ] }
Good luck!
–Dave
PHP TIP: A quick, non-RegEx way of replacing an IMG tag’s SRC= attribute
It’s often useful to be able to swap out the src= attribute of an HTML IMG tag without losing any of the other attributes. Here’s a quick, non-regex way of doing this. It uses the PHP DOM API to create a tiny HTML document, then saves the XML for just the IMG element.
function replace_img_src($original_img_tag, $new_src_url) { $doc = new DOMDocument(); $doc->loadHTML($original_img_tag); $tags = $doc->getElementsByTagName('img'); if(count($tags) > 0) { $tag = $tags->item(0); $tag->setAttribute('src', $new_src_url); return $doc->saveXML($tag); } return false; }
Note: In versions of PHP after 5.3.6, $doc->saveXML($tag)
 can be changed to $doc->saveHTML($tag)
.
TIP: How to Play a Sound Whenever You Commit to Git
Writing code alone at home can be an isolating experience. There you are, day in day out, quietly making magic with your mind (sarcasm, obv.) only to silently commit the fruits of your labor into the void of your source control repository, appreciated by no one. If only a crowd of children could be retained for the sole purpose of cheering you on every time you complete something.
Amazingly, Brandon Keepers over at Collective Idea had the same exact same thought (almost; he was substantially less melodramatic in his blog post about it). Â Anyway, here is what my version of his script looks like:
#!/bin/sh toplevel_path=`git rev-parse --show-toplevel` afplay -v 0.1 $toplevel_path/.git/hooks/happykids.wav > /dev/null 2>&1 &
I put this in a file called .git/hooks/post-commit.playsound
. I then trigger this from the main .git/hooks/post-commit
script as follows:
#!/bin/sh toplevel_path=`git rev-parse --show-toplevel` $toplevel_path/.git/hooks/post-commit.tweet $toplevel_path/.git/hooks/post-commit.playsound
Where the post-commit.tweet
script is the script from this blog post. If you aren’t also tweeting your commit posts, you’ll want to delete that line.
If you want this to work for every single Git repository from now on, add these scripts to your git-core templates. You’ll have to figure out where these are (it’s different for every setup). For my Mac, they’re located here: /opt/local/share/git-core/templates/hooks/post-commit.
–David
TIP: Turn WordPress Page Titles On or Off Using Custom Fields
Most WordPress themes display page titles for every page. This is usually what one wants, but sometimes it’s useful to be able to easily turn off WordPress page titles for individual pages but still keep them on by default. This is easy to do with custom fields. For simplicity’s sake, I am going to base these examples on the default WordPress Twenty Twelve theme although the same principle should apply to almost any theme.
The first step is to find where the page title is being generated. In the Twenty Twelve theme, this is in the content-page.php file. Go into content-page.php and find the block of code that looks like this:
<header class="entry-header"> <h1 class="entry-title"><?php the_title(); ?></h1> </header>
and change it to this:
<?php if (get_post_meta($post->ID, 'show_title', true) != "no") {?> <header> <h1><?php the_title(); ?></h1> </header> <?}?>
As you can see we’ve wrapped the <header> tag in an “if” statement. This checks for the presence of a “show_title” custom field for this particular page. If one is present and its value also equals “no,” we don’t show the title. Otherwise, the page title is shown.
The only step left is to open up the editor for the page you want to modify. Go to the bottom of the page to the “Custom Fields” section. (If there is no “Custom Fields” section, you may have to go up to the top, click “Screen Options” and check the “Custom Fields” box.) In the “Name” box, type “show_title.” In the “Value” box, type “no.” Hit “Update.”
That’s it! Your page title should be gone from that page.
–Dave Hilowitz
How to Relay your Git Commit Messages to Twitter in 16 Easy Steps
A while back I started using Twitter as a micro-journaling platform. I created a private Twitter account, and every few hours as I worked on code, I would jot down a private tweet to myself about what it was that I was doing. This private Twitter stream was then archived using Momento App for iPhone. After a while, it occurred to me that another stream that I would love to have archived in Momento is my Git commits as it often says more about what I’m up to than it would occur to me to write in a journal.
I set up a Git post-commit hook that posts to my private Twitter account each time I make a local commit on my development repository. Here’s what I did:
- Prerequisite: Create a Twitter account. It doesn’t have to be private, but it can be.
- Register an application with Twitter. Here’s how you do that:
- Go to http://dev.twitter.com. You may need to sign in again.
- Hover over your avatar in the top-right, and choose “My Applications” from the menu that appears.
- Click on the “Create New Application” Button.
- Fill out the next however you’d like. The website address can be anything. The name of the app can be anything. Leave Callback URL blank. Agree to the agreement, enter the CAPTCHA and you’re good to go.
- Next, you’ll be taken to a screen with a bunch of keys. Copy all of those down into a text editor.
- Click the “Settings” tab. Change to “Read and Write” for Application Type. Click Update.
- Go back to the Details tab. Scroll down to the bottom and click “Create my OAuth Access Token.”
- Wait a few seconds, refresh the page, wait some more. Eventually, at the bottom of the page a section should appear that says “Your access token.” Copy these codes down.
- That’s it for your Twitter App setup.
- Go to http://dev.twitter.com. You may need to sign in again.
- Open up a shell on the machine you are planning to be commit to (and tweet from).
- Install http_post. You will have to compile this from source. (make and make install). Make sure it’s accessible from your PATH.
- Install oauth_sign. You will also have to compile this form source. (make and make install)Â Make sure it’s accessible from your PATH.
- Finally, save the following script into .git/hooks/post-commit in your Git repository.
#!/bin/sh # PATH modification needed for http_post and oauth_sign export PATH=$PATH:/usr/local/bin toplevel_path=`git rev-parse --show-toplevel` toplevel_dir=`basename "$toplevel_path"` branch=`git rev-parse --abbrev-ref HEAD` subject=`git log --pretty=format:%s -n1` hashtags="#code #$toplevel_dir" tweet=$hashtags' ['$branch']: "'$subject'"' # truncate tweets that are longer than 140 characters if [ ${#tweet} -gt 140 ] then tweet_trunc=$(echo $tweet | cut -c1-137) tweet=${tweet_trunc}... fi consumer_key="<Put your computer key here>" consumer_secret="<Put your consumer secret here>" access_token="<Put your access token here>" access_secret="<Put your access token secret here>" url="https:api.twitter.com/1.1/statuses/update.json" http_post -h Authorization "$(oauth_sign \ $consumer_key $consumer_secret \ $access_token $access_secret \ POST "$url" status="$tweet")" \ "$url" status="$tweet"
- Make sure that you make the file executable. (chmod a+x .git/hooks/post-commit)
- That’s it! If you want to have this automatically added to any new repositories you make, modify the git-core templates. You’ll have to figure out where those are (it’s different for every set up). For me, they’re located here:Â /opt/local/share/git-core/templates/hooks/post-commit.
This is all based heavily on scripts at the following two links:
Good luck!
–David
How and Why I Switched Away From Doit.im
Why
This evening, I migrated away from doit.im. I had been using it for over a year and liked it quite a bit, but increasingly I found myself reverting to a TaskPaper-formatted text file for my daily tasks, which defeated the purpose of having all of my big stuff in Doit.im.
Ultimately, I’m looking for a system that will be able to accomodate little daily lists that I make as well as my grandest long-term plans. Doit.im was really good with the latter, but really just OK for the day-to-day tasks.
Overall, doit.im is pretty well designed. My biggest complaint is that you can’t reorder task lists manually. Why does this matter? Well, one of the biggest questions (if not the biggest question) I am looking to have answered is “What should I do next?” IÂ answer this (in theory, at least) by staying on top of all my lists, by making decisions early and often, and by ordering and reordering every project’s task list over and over throughout the day. The operative principle is that I could then move from project-to-project, effortlessly checking off the next task from each one, before going back to the beginning of the list and starting over. Real life isn’t so perfect, but that’s the concept at least.
Even if three or four tasks could potentially be done to move a project forward, I still need to make a decision about which one to start with. In other words, I’m not interested in what can be done next, I’m interested in what will be done next. The difference between these two things is the difference between my moving forward in a project and just staring bewildered at the 568 tasks in my list.
In summary, manual ordering is essential.
How
Leaving Todo.im was technically much harder than I had expected. I had migrated onto their service using their wonderful API. At the time I had been using Remember The Milk, so I wrote a script that parsed RTM’s RSS feed and inserted the tasks from that one-by-one via Doit.im’s API. Pretty straightforward.
Things were quite a bit harder this time around, though, as Doit.im have disabled their API. To make matters worse, they have no functionality for exporting task lists. This isn’t the sort of feature one notices when deciding to use a task management system, but it probably should be. (I should add, at the risk of sounding paranoid, that it’s hard to see their decision to discontinue their API or any kind of export functionality as anything other than an anti-competitive move.)
This left their web app. If you go to any of their list views, you can see that all of the tasks are in divs with the class “link-title.” This means it’s fairly easy to scrape this data into a JavaScript variable, and then into a the clipboard buffer. Here goes:
1. In Chrome: open up the Doit.im website
2. (optional)  Make a custom filter that will show you all tasks
3. Open up a list view for your custom filter (works with any list view really)
4. Open up the Developer Console (option+command+i on the Mac).
5. Paste this snippet…
var taskString = ''; var tasks = $('.taskList .task .title .link-title').text(function(index, value) { taskString = taskString + '- ' + value + "\n"; }); console.log(taskString); copy(taskString);
…into the console and hit enter.
6. Go into your favorite text editor and paste.