Archive for the Category Development

 
 

PrivateJournal

I use a LiveJournal account as a private journal, and so all my posts are private. As far as I’ve been able to tell so far, LiveJournal always defaults to public when posting a new entry.

After getting a bit annoyed, I realised GreaseMonkey would be the perfect tool to fix the UI for myself. So, I wrote a quick script to set the privacy selector to “Private” on the post page. And so, I present possibly the shortest GreaseMonkey script ever. Enjoy!

privatejournal.user.js

Even more rapid development with Django and jQuery

Compared to coming up with an idea, writing a web app is like trying to swim through treacle. After completing a week-long iteration on TickTickDone, it typically takes a day or two to unwind and mentally process the iteration’s work, then about an hour to come up with the tasks for the next week. Actually coding and testing those features takes the majority of the week’s 15 hours work.

The one-web-app-per-week idea is limited by how much functionality you can develop within the limited timeframe. I’d like to make my time spent coding as efficient as possible. So, I’m setting myself the challenge of creating a framework on top of Django and jQuery such that I can re-develop the current version of TickTickDone (iteration 8, made up of 8 weeks work) within one week.

At the moment, TTD’s code is not great in the DRY department. That problem exists in the javascript code and also in the python code, which is troubled by many very similar unit tests for very similar AJAX response functions. So as a solution, I plan to start by abstracting as many common patterns as I can. I’ll also try exploring the jQuery plugin library for pre-built components to help along the way, and see if I can form all of these into a cohesive library. Once I feel it’s ready, I’ll try using it to re-develop TickTickDone in a week.

An obvious alternative to this whole approach (and the one commonly used) is to hire more people to code for you. That’s not an option for me at the moment because I don’t have the money to hire more coders (a constraint), but it’s also not a great strategy due to the communication scaling problems in large teams.

Any thoughts? Has anyone done this (or tried to do this) before? Let me know in the comments.

Collapsible forms with jQuery

I spent a few hours recently refactoring the TickTickDone javascript to reduce code duplication. In the process, I generalised out a common pattern - a link that, when clicked disappears and is replaced with a form. If the form is cancelled or submitted, the form disappears and the link returns. An example can be found in the “Add a new milestone” button on the goal page of TickTickDone. I’ve packaged up the HTML template and the javascript, and linked them below. To use it, create your HTML page with a section following the format in collapse-form.html. Include collapse-form.js, and call the following in your javascript init:

init_collapse_forms($(document));

Collapsible forms version 1:

collapse-form.html

collapse-form.js

Twitter + shell for Python

In response to this post, I’ve written an equivalent script in python (because I’m too lazy to get the CPAN lib):

#!/usr/bin/python

from twyt.twitter import Twitter
import sys

username = ''
password = ''

def tweet(message):
    twitter = Twitter()
    twitter.setauth(username, password)
    twitter.status_update(message)

if __name__ == '__main__':
    message = ' '.join(sys.argv[1:])
    tweet(message)

It depends on python-twyt. Enjoy!

Twitter Obliterate

I had a request for a script to delete all the tweets in an account, so here it is:

twitter-obliterate-0.1

May be harmful to your tweets, use at your own risk! I’m not sure how fast it is, since I’ve only tested it on an account with about 10 tweets. It has to send a separate HTTP request for each tweet, and it does so serially. Hopefully it’ll be adequate for all but the most massive accounts.

The tarball includes a version of the python-twyt library, modified to add support for the archive command. Patch on the way to the maintainer shortly…

Update: I’ve done a few tests and it appears the code has some bugs, but due to lack of demand I haven’t investigated any further. Let me know if you’re interested in a fix!