def create_temp_app_dir(prefix, suffix='', cleanup=60):
    """ Create a temporary direrctory and return path

    The directory will be named "<prefix>_<timestamp>_<pid>_<suffix>".
    Will clean up directories with the same prefix which are older than
    cleanup seconds.
    """

    # Select main dir
    maindir = os.path.join(appdata_dir('flexx'), 'temp_apps')
    if not os.path.isdir(maindir):  # pragma: no cover
        os.mkdir(maindir)

    prefix = prefix.strip(' _-') + '_'
    suffix = '' if not suffix else '_' + suffix.strip(' _-')

    # Clear any old files
    for dname in os.listdir(maindir):
        if dname.startswith(prefix):
            dirname = os.path.join(maindir, dname)
            if os.path.isdir(dirname):
                try:
                    dirtime = int(dname.split('_')[1])
                except Exception:  # pragma: no cover
                    pass
                if (dirtime - time.time()) > cleanup:  # pragma: no cover
                    try:
                        shutil.rmtree(dirname)
                    except (OSError, IOError):
                        pass

    # Return new dir
    id = '%i_%i' % (time.time(), os.getpid())
    path = os.path.join(maindir, prefix + id + suffix)
    os.mkdir(path)
    return path


# From pyzolib/paths.py (https://bitbucket.org/pyzo/pyzolib/src/tip/paths.py)
dataset/ETHPy150Open zoofIO/flexx/flexx/webruntime/common.py/create_temp_app_dir/swapped operands of `-`