Posted on May 31, 2008

Set Up WebDAV for iCal Sharing on ubuntu 8.04

Enabling WebDAV for iCal publishing/sharing is fairly straightforward:

0. Install apache2 (if it’s not already installed):

sudo apt-get install apache2

1. Create a WebDAV directory in your DocumentRoot with the proper permissions:

mkdir -p /var/www/webdav
chmod -R 777 /var/www/webdav

2. Edit Apache2′s dav_fs.conf file:

cd /etc/apache2/mods-available
sudo vi dav_fs.conf

DAVLockDB /var/lock/apache2/DAVLock


DAV On
DAVMinTimeout 600
DAVDepthInfinity On

AllowOverride AuthConfig
AuthName “DAV Restricted”
AuthType Basic
AuthUserFile /etc/apache2/.htaccess

Require valid-user

3. Create symlinks to the proper DAV module files:
(Some of these will already exist. Leave them alone.)

cd ../mods-enabled
sudo ln -s ../mods-available/dav.load
sudo ln -s ../mods-available/dav_fs.conf
sudo ln -s ../mods-available/dav_fs.load

4. Create the ‘AuthUserFile’ indicated in step 2:

sudo htpasswd -m -c /etc/httpd/.htaccess webcal

5. Restart apache:

sudo /etc/init.d/apache2 restart

6. Publish your iCal!

Your url for publishing should now look like http://mywebhost/webdav/iCal/. Enjoy!

Based on a guide for Fedora at millan.info.

Posted on May 29, 2008

Posted on May 23, 2008

iTunes Playlist Export

One of my long-time gripes with iTunes is that the only ways to export its playlists are to text and xml which aren’t particularly useful by themselves. I’ve been doing more processor- and memory-intensive work on my laptop lately, and wish to augment said work with tunes whilst also not killing my machine. iTunes isn’t exactly a RAM-lightweight, so in situations like this I tend to fire up the ever-trusty install of WinAmp. Recently, however, I’ve been listening to the same massive playlist over and over again, and re-creating it in WinAmp would be a bit of a pain.

Lucky for me, someone else thought that automating this would be a good idea. Enter iTunes Export, which does exactly what it says it does, quickly and to several useful formats. As great single-purpose software does, it just plain works.

   

There are four screens, each of which are, as you can see, pretty straightforward. Screen 3 is where all of the fun options are. I didn’t need to re-copy all of my music to a new location, but I can see how that would be useful if you wanted to, say, burn a DVD of a large playlist for someone who doesn’t have iTunes. For me, the M3U export without copy was perfect, and I haven’t opened iTunes in days.

Posted on May 20, 2008

Clearing the Baffles (II)

Three months ago, I “cleared the blogging baffles” and actually found it fairly cathartic. Based on that, I set up a task reminder to remind me to do just that every three months on the 20th.

Here are the posts sitting in my drafts folder that I’ll likely never get to finishing / cleaning / etc.:

  • Email Link at Right (tags: how-to )
  • 5 Geek Decisions I Wish I’d Made Differently (tags: uncategorized )

*delete*

Posted on May 19, 2008

Prime Time

Every so often I go back through posts on my old blog, which is securely archived for my own random access. [There are some fairly good posts on it about technology that wouldn't make sense to re-post here, but are still a good reference for me.] I read one the other day that made me chuckle with geekish delight as I read:

1,000,003 is the smallest seven-digit prime number I could think of, which, being completely impossible to wholly divide from, should take care of the repetitive quotes.

Backstory: I used to have a random quote generator made up of stupid phrases I’d collected over time. Some were output from fortune, some from movies or tv shows, and others were stupid inside jokes. There were far too many Family Guy references, IIRC. It played well to the quasi-personal, friends-oriented content I was producing at the time. Each quote was an entry in a MySQL table with a primary key which I used for retrieval based on this code:

srand((double)microtime()*1000000);
$tq_query = mysql_query("select count(qid) from quotes")
or die ('Invalid Query: ' . mysql_error());
$getQuote = sprintf("select quote from quotes where qid='%s';",
addslashes(rand(1, mysql_result($tq_query,0)-1)));
$gq_result = mysql_query($getQuote)
or die ('Invalid Query: ' . mysql_error());
echo mysql_result($gq_result,0);

Aside: As I copy and paste this now, I wonder why I didn’t just do something like “SELECT quote FROM quotes ORDER BY rand() LIMIT 1″, putting the responsibility for randomness on MySQL’s already set up random seed? I may have been over-prioritizing database robustness on a site that never got more than a few hundred hits per day.

My girlfriend at the time (now my wife) noticed that the quotes didn’t actually seem that random and, in fact, the same few kept repeating themselves over and over again. I had noticed the same thing, but never felt that motivated to investigate. [She was, I think, between classes and it bothered her… so who am I to argue?]

After reading a bunch of threads on the PHP website, I reasoned that the problem was that I was seeding the random stack with an even number. Due to silly rounding and a padding value, the number most commonly returned out of this function was 24, which is incredibly un-prime. [Even cooler to the numbers nerd inside of me, 24 is the largest number divisible by all numbers less than its square root.] So.. following good number theory, I changed the seed value to 1000003, which is prime, and in few other ways special.

In additional retrospect, saying “that I could think of” was quite silly… The list of smallest n-digit primes is readily available, so this shouldn’t require much thought at all. If memory serves, I don’t believe I looked this up, and really, how hard should it be for someone who finds math fun to know that 100001 and 100002 aren’t prime [11 and 2 are lowest divisors, respectively]?

Posted on May 17, 2008

Cygwin Prompt Here (for tcsh)

In a post I can no longer find, Scott Hanselman blogged about a registry entry to add a “Command Prompt Here” item to Windows’ right-click context menu. This has, many times, saved me almost 30 seconds of opening cmd.exe and typing out a ridiculous CD statement. Since then, however, I’ve found myself using Cygwin a lot more than cmd as it gives me a lot more power in an environment with which I’m much more familiar. (Some things are kinda wonky [pathnames, for instance] but it’s more user-friendly to me, and I can’t quite get into PowerShell like some of my more Windows-oriented friends.)

Because of my Cygwin-love, I’ve found myself using the Command Prompt Here context-menu item, and then immediately entering tcsh and doing what needs to be done. I can’, then, double Ctrl-D my way out of the window since cmd has no clue what Ctrl-D is. It’s annoying, but it means I have to take the extra two seconds to type ‘exit’. So, throwing any concept of cost/benefit out the window [though, those four seconds probably add up to like... 30 minutes of lost productivity a year], I investigated how to do the same thing for Cygwin.

Somebody figured this out already, so all that was left was for me to have it run tcsh instead of bash, and I was all set. This was painfully simple. Here’s the registry script I’m using:

REGEDIT4
[HKEY_CLASSES_ROOT\Directory\shell\TcshHere]
@="&Cygwin Prompt Here"

[HKEY_CLASSES_ROOT\Directory\shell\TcshHere\command]
@="c:\cygwin\bin\bash.exe --login -c \"cd '%1' ; exec /bin/tcsh\""

[HKEY_CLASSES_ROOT\Drive\shell\TcshHere]
@="&Cygwin Prompt Here"

[HKEY_CLASSES_ROOT\Drive\shell\TcshHere\command]
@="c:\cygwin\bin\bash.exe --login -c \"cd '%1' ; exec /bin/tcsh\""