OSX: Create a Playlist From a Folder

I wanted to use this excellent command line from commandlinefu.com on the mac to create a podcasts playlist on my G1 each time I chucked some new podcast files on it. Unfortunately OSX (or BSD) aren’t exact matches to linux, so here’s my hack. It’s not elegant, too many pipes, but it works!

cd /Volumes/NIALLSG1/Music/Podcasts && find . -type f -exec stat -f "%c %N" {} \; | grep -v '\./\._' | grep -v m4v | sort -rn | sed 's/\.\//;.\//' | awk -F ';' '{print $2}' > ../podcasts.m3u

On my mounted G1 all my podcasts live in /Volumes/NIALLSG1/Music/Podcasts. I generate the podcasts.m3u to the Music folder.

The stat prints the created date as seconds from the epoch followed by the file name.

The first grep -v removes the stupid itunes symbolic links (mutter, mutter) that get copied across from the listings in iTunes, the second removes video podcasts as the Music Player doesn’t play the video.

The sort gives us the list sorted on created date descending.

The sed gives me an easy delimiter to use in the awk. A cheaty bit I know.

The awk spews out the filenames only for the write to the m3u file.

Teh usual caveats apply; your mileage may vary; be careful; etc.

Installing Laconica


  • OS: $ lsb_release -a
    Distributor ID: Ubuntu
    Description: Ubuntu 8.10
    Release: 8.10
    Codename: intrepid
  • php 5.2.6
  • mysql server 5.0.67-0ubuntu6

Added pre-requisities php libraries:

  • sudo apt-get install php5-cli
  • sudo apt-get install php5-curl
  • sudo apt-get install php5-mysql
  • sudo apt-get install php5-gd
  • sudo apt-get install php-gettext
  • Check mbstring is installed: php -i | grep -i mbstring
    If you get some output, you should be OK.
  • Check xmlwriter is installed: php -i | grep -i xmlwriter
    If you get some output, you should be OK.

Added nice to haves:

  • sudo apt-get install php5-memcache
  • sudo apt-get install php-pear
  • sudo apt-get install php5-dev
  • sudo pecl install mailparse
  • Not sure whether you need this, but did it anyway as seemed logical at the time: sudo vim /etc/php5/conf.d/mailparse.ini
    and add:
    # manual configuration for php mailparse module
    # yourInitials 16-mar-09
  • Install Sphinx Server. Not sure how/when we’ll config this, but it’s as well to get it in before we’re asked for it:
    • sudo apt get install libmysqlclient15-dev
    • wget http://sphinxsearch.com/downloads/sphinx-
    • tar -xvf sphinx-
    • cd sphinx-
    • ./configure
    • make
    • sudo make install
    • Check it’s in OK: search
      You should see output starting with: Sphinx
  • sudo apt-get install php5-xcache

I suggest you also install phpMyAdmin for looking after the mysql databases if you haven’t already. I’m certainly not hard enough to do all the sql work from the command-line 🙂

Just in case restart Apache:

  • sudo /etc/init.d/apache2 restart

And now, we begin. Rather marvellously Mr Prodromou has just released a new laconia update, version, which includes a “first version of a web-based installer”. I’m following the instructions from the README file in the download. Here goes…. Just followed the instructions and I have a functioning install! Mwah-ha. Mwah-ha! Mwah-ha-ha-ha-haaaaaa! I have the power. etc.

Things not working: Fancy URLs. But I’ll get ’round to that.

UPDATE: run sudo a2enmod rewrite to enable the apache rewrite engine so you can use fancy urls and then follow the instructions in the README for .htaccess.

Getting a Current Subversion Project Into Git Control

Whilst learning how to use git with svn I am documenting the way I’ve done it. I’m using bash and am starting from the directory above my working directory. The project is checked out already from an svn repo. The working directory is “efot”.

  • Commit anything outstanding in your working directory to svn
  • Move your working directory out of the way if you’re paranoid like me: mv efot efot.pregit
  • Checkout (clone) your project from svn using git: git-svn clone http://svnServer/repos/section/trunk/efot --username=yourSvnName
  • Watch what’s happening: cd efot;gitk &
  • Make sure git ignores .svn and, since I use eclipse in an heterogenous env with other developers, I exclude bin/, and *.log as well:
    • vim .git/info/exclude
    • add “.svn” (without the quotes) to the bottom of the file
    • newline, add “bin” (without the quotes) to the bottom of the file
    • newline, add “*.log” (without the quotes) to the bottom of the file
    • save and quit.
  • Make sure svn will ignore git files and local files I don’t commit to the trunk:cd .. && svn ps svn:ignore ".git" efot && cd efot
    cd .. && svn ps svn:ignore ".classpath*" efot && cd efot
  • cd .. && svn ps svn:ignore ".settings" efot && cd efot

  • give it a descriptive label in git: git-tag -a 20090310_efot_release_prod

Now for the paranoid amongst us, cross the i’s and dot the t’s ;):

  • cp -R ../efot.pregit/src . ; cp -R ../efot.pregit/testsrc .;cp -R ../efot.pregit/xml;cp ../efot.pregit/.classpath . ; cp ../efot.pregit/.settings .;
  • git add .
  • git commit -a
  • update from svn: git-svn fetch
  • if any come in on the fetch, replay any git changes onto it (shouldn’t be any at this point): git-svn rebase
  • commit to svn: git-svn dcommit

Job’s a good’un. I think.

Refs: Git User’s Manual, Flavio Castelli, and Git Crash Course.

Git locally, Subversion Repos

Whilst learning how to use git with svn starting from a new item in the trunk, I’ve hit a couple of snags and am documenting the way I should have done it.

  • Create your new working directory and add it to svn first: mkdir efot && svn add efot && svn commit efot -m "starting the new project"
    (Note the revision number for later)
  • Make sure svn will ignore git files: svn ps svn:ignore ".git" efot
  • Now we go to setup git: cd efot
  • Initialise git: git svn init https://svnServer/repos/section/trunk/efot
  • Get the right revision from svn using the revision number you got in 1: git-svn fetch -r2424
  • Make sure everything is really, really, really ready ;): git-svn rebase
  • Make sure git ignores .svn:
    • vim .git/info/exclude
    • add “.svn” (without the quotes) to the bottom of the file
    • save and quit.
  • At this point you’re ready to go. Create your usual directory structure and add it to git: git add .
  • Do your first commit to git: git commit
  • Add a file: touch showMe.txt
  • add to git: git add .
  • commit to git: git commit -a
  • update from svn: git-svn fetch
  • if any come in on teh fetch, replay your git changes onto it: git-svn rebase
  • commit to svn: git-svn dcommit

Job’s a good’un. Thanks to Flavio Castelli

Mac OSX: Things To Do First If You’re a Developer

If you’re a developer moving to a Mac may I recommend, from my own experience, you do these three things before you try and do anything at all other than using iLife or M$ Office:

  1. Install XCode Tools. You’ll need your OSX install DVD, select Optional Installs/Xcode Tools, and run the XcodeTools.mpkg. Budget an hour for it to install, hope for 40 mins. Maybe better on the Intels.
  2. Install MacPorts. It makes life so much easier than trawling the web trying to understand the esoterica of Mac OSX standard installs of various things like mysql, sqlite, python and ruby. None of them work quite the way I expect them to, and the hacking to try and understand what’s different, and then how to fix it, is so time consuming I have bypassed them and use MacPorts. It looks like a shedload of other people do too.
  3. create a .bash_profile file in your home directory. Use this for aliases (.bashrc doesn’t work).

All I can think of right now.