Archive for November 2006

Darcs over sshfs

A while ago I found out that darcs doesn’t work over sshfs out of the box. Of course there was a workaround. Yesterday I was at it again, and this time it was sshfs that gave me grief. After another echange of emails I found a solution.

At the moment this is what’s necessary:

% sshfs -oworkaround=rename <remote path> <local path>
% export DARCS_SLOPPY_LOCKS=1
% darcs put <local path>/<repo name>

My Google Reader share

Listing files in Haskell

As I promised earlier here’s a post on my playing with files and directories in Haskell. This was a few days ago so I’ve forgotten a few of the twists and turns that took me to the goal. Forgive me for that.

First, my goal was to list all files below a directory, recursively. I was sort of hoping to find something similar to Python’s os.walk(). No such luck!

I found out a few things.

  1. getDirectoryContents returns everything in a directory, including . and ... I needed a filter to remove them:

    isDODD f = not $ (endswith "/." f) || (endswith "/.." f)
    

    (At first I called it isDotOrDotDot but I like isDODD better.)

  2. I also needed to separate out the directories and files from the result of getDirectoryContents:

    listDirs = filterM doesDirectoryExist
    listFiles = filterM doesFileExist
    
  3. getDirectoryContents returns a list of the contents in the directory you point it to. All file names/directory names are relative to that path. That means the next thing I needed was to join paths. I first couldn’t believe that there wasn’t a function to do that. I mean, I can list contents of a directory, I can find out if something’s a file or a directory, but the most basic manipulation of paths isn’t there. At first I simply concatenated strings, but I didn’t worry about making it cross platform or anything. Then I found that Cabal comes with libraries that handles cross-platform issues properly, but that library was “closed”. After moaning asking on haskell-cafe I found FilePath. It’s even packaged for Debian here.

    FilePath.joinPath takes a list of strings to join, while I was only interested in joining two strings at a time:

    joinFN p1 p2 = joinPath [p1, p2]
    

Putting it all together I ended up with the following:

listFilesR :: FilePath -> IO [FilePath]
listFilesR path = let
    isDODD :: String -> Bool
    isDODD f = not $ (endswith "/." f) || (endswith "/.." f)

    listDirs :: [FilePath] -> IO [FilePath]
    listDirs = filterM doesDirectoryExist

    listFiles :: [FilePath] -> IO [FilePath]
    listFiles = filterM doesFileExist

    joinFN :: String -> String -> FilePath
    joinFN p1 p2 = joinPath [p1, p2]

    in do
        allfiles <- getDirectoryContents path
        no_dots <- filterM (return . isDODD) (map (joinFN path) allfiles)
        dirs <- listDirs no_dots
        subdirfiles <- (mapM listFilesR dirs >>= return . concat)
        files <- listFiles no_dots
        return $ files ++ subdirfiles

Links and stuff (24/11/2006)

I realised I hadn’t put in one of these posts in a while. The level in my “To Blog” bookmark tag was dangerously high… here we go!

I really enjoy this, rather old article on superstitions in relation to computers. I never bothered counting my superstitions on Windows, but given that I’ve given up on understanding Microsoft’s products I suspect they run in the thousands.

Every developer needs Cenqua’s Commentator. I’m getting it as soon as I’ve saved the money. It’ll be the first piece of software that I pay for myself in years. Worth every penny though.

libgfshare. Please, go off and write some cool software using it. Please! If I were a FirefoxIceWeasel user I would use the Python sidebar. It looks so useful I might look into creating one for epiphany. If you’re considering doing something cool with PDF docs, have a look at extendedPDF. I think I’ve mentioned Rob Bradford’s GConf difftool in another post, or maybe not. Anyway, I’m hoping that’s the first step towards a tool that lets you export GConf settings between machines. Are you a Python web developer, Python Paste is yet another framework.

If you still believe that “do no evil” is enough then you won’t be interested in Google Watch. I however thing they should upgrade their slogan to “do good”, so I am interested.

I found the following post funny, but I’m probably the only one. Havoc doesn’t understand why distributed VCS is better then Subversion. I suppose that’s what happens when you are a famous FLOSS person that immediately gain submit access to any project one shows an interest in. For the rest of us; thank goodness for distributed VCS.

Old news, but Firefly fans are bloody brilliant.

More old news, I don’t really see why I should worry about “identity theft” from someone rummaging through the rubbish in my wheely bins while the UK banks are so careless with client information.

With great power comes great responsibility. It’s sad when language designers don’t believe the developers deserve the responsibility. Here’s a post on the difference in attitude between C# and Python when it comes to empowering the developer.

I had fun reading about the evolution of a Haskell programmer, even though I didn’t understand all the code.

Well, I actually do believe in the cheerleader defense for wireless networks. Anyone who has looked at software security knows that plausable deniability is much easier to achieve than locking down a system. IANAL but I still believe in the phrase “beyond reasonable doubt”.

Now, I wasn’t planning on running Vista on any of my private machines. After reading this, rather long, article on Vista’s EULA I’m absolutely certain of that. I’m almost thinking Microsoft is taking a piss out of their users. However, evidence is mounting that they aren’t. I can’t help but wonder how their “de-activation” will hold up in legal systems outside of the US. I also wonder how much further this distrust-your-user craziness in EULAs can be taken before users start reacting negatively.

Firefox vulnerability, not on Debian?

I received a note about the new Firefox vulnerability yesterday. I ran the proof-of-concept on my Debian machine, using first Epiphany and then Iceweasel. Didn’t work on either. Then I fired up a VMWare image running Windows, with a stock Firefox from mozilla. The proof-of-concept worked just as advertised. So, are the reports missing something (not exploitable on all OSs), or am I just lucky that Debian decided to move to Iceweasel?