Skip to content

Web application in 24 hrs

So I came up with this idea of building web application in 24 hours experiment. Task was as follows: come up with an idea, think of any innovative use, build it and deploy. Registering domain name, drawing UI, designing model layer, setting up server, writing code, testing and all the usual stuff took… 15 hours, 49 minutes and 11 seconds according to my time tracker.

Of course, there must be a lot of bugs hidden somewhere, and interaction stuff may have to be redesigned at some point. Also, load testing should be done properly. I guess a few pieces will need serious optimization and caching applied.

But – if you’d like to try it out, be my guest and visit Adplified at http://adplified.com/. Please let me know if you have any suggestions.

Testing web applications #1

A short summary of tools for functional testing. That’s first part of my research on automation in web development.

Project Website Type Configuration Key advantages
Canoo WebTest http://webtest.canoo.com/ Manual assertions Groovy, XML Straighforward and extensible, easy data importing.
Celerity http://celerity.rubyforge.org/ Manual assertions JRuby Simplicity.
HtmlUnit http://htmlunit.sourceforge.net/ Manual assertions JUnit Low-level, extensibility.
Jameleon http://jameleon.sourceforge.net/ Manual assertions Jelly, JUnit Plugins, integration of other tools.
JWebUnit http://jwebunit.sourceforge.net/ Manual assertions JUnit Simple API, integrating Selenium.
MaxQ http://maxq.tigris.org/ Session recording Jython, JUnit Interesting architecture.
Sahi http://sahi.co.in/w/ Session recording IDE, JavaScript, Rhino Good support for highly dynamic applications.
Selenium http://selenium-ide.openqa.org/ Session recording IDE, JUnit, Nunit, Python Community support, powerful options.
Sikuli http://sikuli.org/ Image matching IDE, Python Simplicity, portability, novel approach.
Solex http://solex.sourceforge.net/ Manual assertions Eclipse IDE Integration with Eclipse.
TestGen4Web https://addons.mozilla.org/en-US/firefox/addon/1385 Session recording IDE, Firefox plugin Integration with Firefox.
Twill http://twill.idyll.org/ Manual assertions Python Pure Python.
Watir http://watir.com/ Manual assertions Ruby Like Twill, lightweight and low-level.
Windmill http://www.getwindmill.com/ Session recording JavaScript, Python, Ruby Smart support for multiple browsers.

Automating with… Screenshots?

This thing is absolutely awesome. It gives me the feeling of living in the 21st century and shows how we are going to interact with computers in the near future. Well, as soon as it gets “production-ready” and voice recognition is applied. But that’s a different story.

So what is it all about? Let’s say I need a timetable of the bus going to the university. In my reality these are very likely to be outdated right the next day I checked them. So instead of looking it up every morning, half-sleeping and struggling between drinking coffee and eating breakfast, I could ask my computer to send it over to my phone. Obviously, you could do that with general technical knowledge and some experience in OS scripting, but why to bother? There are much more interesting things to hack nowadays, right?

What is the alternative? You open up Sikuli, grab some screenshots, add a few lines of Python code (if you want to) and you’re ready to go. Yes, it’s that easy. Here’s the effect:

And here you can see a demonstration of sending PDF with the timetable:

Experimenting with Sikuli from Robert on Vimeo.

The sexiest thing about it is that you can use… Python Unit Testing! And that makes it really powerful tool (like e.g. Selenium). For instance, imagine distributing Django apps with GUI tests already there…

How dumb the world is?

James “The Amazing” Randi is amazing indeed. His fight for rationality and passion about being conscious are inspiring, while his sense of humor is so sharp that it physically hurts to imagine how bright and intelligent this guy is.

I remember a friend of mine telling me a story about “guru”, whose one of great abilities (apart from exploiting children sexually, for what he’s being chased in most of the civilised world) was to use his “psychic” power to create things. She was absolutely sure this was true, even though she hasn’t seen it personally. And even if she had, seeing is usually not enough. Why? Well, that’s where rationality comes in. Rationality is a natural condition of any intelligent person and some people just keep this state unchanged throughout their lifes, while others need some refreshing. If you need that kind of recovery, I’ll give you a tip: stop watching horror movies, playing RPG, hugging trees and talking to ghosts for at least a few days. That doesn’t help much in treating. And if you haven’t seen Avatar yet, I recommend buying tickets any other weekend.

So how do people know, what is real? There are a few simple rules to follow if unsure:

  • First of all, if there was anything like psychic powers proven by anyone, James Randi wouldn’t be looking for anyone to pass 1 milion bucks.
  • Start from seeking simple explanations. No matter how complex the stuff looks like.
  • Before you go into magic, think about basic law of physics.
  • Don’t trust what people say if you feel there’s something irrational going on. Use your own brain.
  • If someone may gain any benefits from making you believe in magic, paranormal abilities etc., you can easily assume it’s a prank.

Ah, did I mention the guru was buying his newly created things in nearby shops? I know, I know. That’s sad there’s no real magic in this boring, physical world.

If you’d like to watch the rationalization process live, here are two clips starring James Hydrick – an ex-prisoner, kung-fu master with telekinetic skills. Eventually, he admitted that is was a simple trick and he just wanted to check “how dumb the world is“. Enjoy.

Don’t forget to visit James Randi Educational Foundation website!

The ghost in zsh

Some Django stuff

A few Django 1.1 functions someone may find useful.

Project management

django.utils.version.get_svn_revision

    def get_svn_revision(path=None):
        """
        Returns the SVN revision in the form SVN-XXXX,
        where XXXX is the revision number.

        Returns SVN-unknown if anything goes wrong, such as an unexpected
        format of internal SVN files.

        If path is provided, it should be a directory whose SVN info you want to
        inspect. If it's not provided, this will use the root django/ package
        directory.
        """

Python helpers

django.utils.importlib.import_module

    def import_module(name, package=None):
        """Import a module.

        The 'package' argument is required when performing a relative import. It
        specifies the package to use as the anchor point from which to resolve the
        relative import to an absolute import.

        """

django.utils._os.safe_join

    def safe_join(base, *paths):
        """
        Joins one or more path components to the base path component intelligently.
        Returns a normalized, absolute version of the final path.

        The final path must be located inside of the base path component (otherwise
        a ValueError is raised).
        """

django.utils.daemonize.become_daemon

    def become_daemon(our_home_dir='.', out_log='/dev/null',
                      err_log='/dev/null', umask=022):
        "Robustly turn into a UNIX daemon, running in our_home_dir."

from django.utils.itercompat

    """
    Providing iterator functions that are not in all version of Python we support.
    Where possible, we try to use the system-native version and only fall back to
    these implementations if necessary.
    """

Dates

django.utils.feedgenerator.rfc2822_date

    def rfc2822_date(date):
        [...]
        return date.strftime('%a, %d %b %Y %H:%M:%S -0000')

django.utils.feedgenerator.rfc3339_date

    def rfc3339_date(date):
        [...]
        return date.strftime('%Y-%m-%dT%H:%M:%SZ')

Being agile doesn’t mean being relaxed

Some people think that doing things “agile” means all you need is: a client that will never get pissed off, a set of loose requirements and eternity for development work. These people are wrong. If you think I’m lying, you belong to the same group of people, what implies that you’re wrong as well. As easy as falling off a log.

If you’re dreaming of a zero-day-millions startup, you’re not willing to learn and your ego is much greater than your skills, you would probably use “agile” buzzword so you’re very likely to hide your incompetence. “What? What documentation? Diagrams? UML? What is that? Come on, we are agile, you silly boy! We create coolest Web applications with no effort at all!” Don’t do that. It’s wrong.

Production is still production, no matter how much fun you think it is and how relaxed you are. Especially software development is the area where thinking, designing and planning is a serious job. And, let me remind you, building Web applications is software production. No matter you like it or not.

Imagine asynchronous world

The only thing I like about mobile phones, apart from letting me to be in touch with my friends and family, is Internet access and PIM functionality. And these are the only arguments that stop me from throwing away my SIM card.
Do you like people entering your office and talking to you no matter you like it or not? Especially when thinking on some complex issues that need all your brain cells working in parallel? And that’s what happens when someone calls you to talk about stuff that is important _for that person_ and _at this given moment_. Obviously, some information is easier to pass using voice, however the condition is that the message is: short, precise and making decision is not required. That’s the reason I was such a great fan of voice mail and pagers.
Audio calls miss body language and are never precise enough. Especially that it’s very uncommon for most people to be able to follow 2-3 hours long discussion and remember things already brought to attention. It just makes no sense to discuss technical stuff over the phone, unless a lot of creativity and brain-storming is needed (or you’re responsible for customer service).
Most of the communication should be asynchronous. Send me a message, so I have some time to think about problems you want me to solve and I will get back to you with my ideas when I’m absolutely sure they are reasonable. This approach boosts quality and helps avoiding mistakes of time pressure answers. Another benefit is that we are able to understand why things were done this way and not the other, and why other solutions wouldn’t work. That is, documenting design decisions is fairly simple. Finally, it’s easier to collect knowledge, develop procedures and help members of the development team to understand the aims and expected results of the work pursued. Not to mention that being asynchronous lets you plan better and do better job in terms of time management.
After all, it’s all about if the end product satisfies requirements. Just make sure that when speaking with your customer about choosing e-mail over phone conversations you give reasons that are well-founded and will not offend anyone. Especially, if cultural differences bring even more complexity to your communication.

The only thing I like about mobile phones, apart from being in touch with my friends and family, is Internet access and PIM functionality. And these are the only arguments that stop me from throwing away my SIM card.

Do you like people entering your office and talking to you no matter you like it or not? Especially when thinking on some complex issues that need all your brain cells working in parallel? And that’s what happens when someone calls you to talk about stuff that is important for that person and at this given moment. Obviously, some information is easier to pass using voice, however the condition is that the message is: short, precise and making decision is not required.

Continue reading ‘Imagine asynchronous world’ »

Antonio Vivaldi’s Stabat Mater

I can hardly find any more inspiriting and mind-blowing music than sacral. That’s like Scottish Highlands in early morning mist. The kind of experience that keeps you shut up for the rest of the day.

One of my latest discoveries I wish to share with you is Eia Mater, the seventh movement from Antonio Vivaldi’s Stabat Mater In F Minor. Stabat Mater is a Latin, thirteenth century hymn dedicated to Mary’s suffering during the crucifixion of Jesus Christ.

This composition just strikes with simplicity. Dramatic, minimalistic and unbelievably powerful. The first thing that came to my mind after listening to Eia Mater, what happened utterly by accident, was that there is nothing more I shall ever hear. That if I got deaf, there wouldn’t be much to regret.

The impression was of course temporary, but this piece absolutely changed my understanding of music.

Performed with amazing passion by Sara Mingardo (especially the bar #313, words “Fac, ut…”). Conducted by Rinaldo Alessandrini.

The text of Stabat Mater can be found at ChoralWiki

RabbitMQ, Celery and Django

So why would you need a task queue? Let’s say you are building a Web application that is going to convert a fair amount of files (converting videos to Adobe Flash for instance). The other requirement is that a user must be notified when the video was converted and management tasks need to happen automatically: after a video was uploaded, it needs to be picked up, processed, moved from queue to repository and then published. Apart from displaying a view with the upload form, everything must happen in the background, so the Web application is still responsive enough.
Continue reading ‘RabbitMQ, Celery and Django’ »