New FaceBook Feature in Testing

In the early afternoon on the 1st of July I first noticed what I think CNET is now reporting on as a News Feed face-lift.

A FaceBook representative described the change as, “a feature within News Feed that gives people the ability to see what their friends are commenting on and ‘liking,’ as these actions are being taken on Facebook”.

As you can see from the screenshots below, this sidebar seems to be what the representative is describing. Real-time updates of what my friends are doing. The best way I can describe it is like the Most Recent stream, except with comments, likes, friendings and taggings. Then, upon clicking the post or whatever it may be, you can view more details about that particular item in a popup, and if applicable, comment on it. If it’s a like, you’re able to also like the item. If it’s a friend addition, you can also add their new friend as a friend if you wish.

The representative also remarked that, “this test includes a small percentage of Facebook users, just a fraction of a percent. In the coming weeks, as we learn more from this test, we’ll keep making improvements and may expand it to more people.”

The only changes I’ve seen so far are various UI tweaks (though the bar has ostensibly remained in the sameplace) such as merging with the Chat list half-way down.

Apart from a brief blip for five days between the 2nd and 7th of July, the bar has remained on the right-hand side of my screen since its introduction.

Screenshots

Je te verrai bientôt, Paris!

I’m going to Paris in 10 days! I’m going to be there for a year, being an au pair. I am so ludicrously excited.

Intro by The XX is not only fantastic and great to chill to, it also reminds me of Paris thanks to this stunning video:

SCP Hates Spaces

Something to remember. scp absolutely hates spaces. With a passion.

Not simply content with escaping spaces with a backslash, e.g. ~/some\ directory/some\ file.jpg, scp demands the backslashes themselves be escaped, resulting in ~/some\\ directory/some\\ file.jpg. But no! This is not enough. We must quote the entire path regardless of the fact that the spaces have already been escaped. Twice.

Now we end up with "~/some\\ directory/some\\ file.jpg". Ridiculous. And just to be clear, it’s not any old quote, it must be a double one. Single quotation marks just don’t cut the mustard, apparently.

It’s times like this I really don’t like the CLI for being so obtuse.

Setting Up AWStats with Lighttpd and Debian

After installing AWStats via apt-get, I realised that its install doesn’t really play very nicely with Lighttpd. That is, the auto_setup file wouldn’t work. Or at least I don’t think it will. I wasted a lot of time if it actually does work! And also, its files and folders seemed spread around everywhere, and they weren’t in the location that all the tutorials and how-tos said they were going to be.

In the end, I opted to install the RPM (which installed them into standard locations) by turning it into a deb file using Alien. It was simple enough.

Downloading

Pop over here and copy the link to the latest RPM download. Now:

sudo apt-get install alien
wget <link>
sudo alien -d <filename>.rpm
sudo dpkg -i <filename>.deb

Lighttpd Configuration

Now everything should be installed into /usr/local/awstats. Edit your lighttpd.conf to include the necessary paths:

# Aliases for AWStats
alias.url += (
                "/awstatsclasses" => "/usr/local/awstats/wwwroot/classes/",
                "/awstatscss" => "/usr/local/awstats/wwwroot/css/",
                "/awstatsicons" => "/usr/local/awstats/wwwroot/icon/",
                "/awstats" => "/usr/local/awstats/wwwroot/cgi-bin/",
                "/icon/" => "/usr/local/awstats/wwwroot/icon/"
              )

You’ll want to change the “+=” to simply “=” if this is the first or only alias.url entry in your conf file. If you do not, when you restart Lighttpd it will spit an error out at you.

Also add this to provide AWStats cgi-bin access:

# provide awstats cgi-bin access
$HTTP["url"] =~ "/awstats/" {
      cgi.assign = ( ".pl" => "/usr/bin/perl" )
}

Now restart Lighttpd with something like sudo /etc/init.d/lighttpd restart

AWStats Configuration

Next we’ve got to configure AWStats just the way we want it. There’s a model/example configuration file included with AWStats, it’s found in /etc/awstats:

sudo cp awstats.model.conf awstats.<nameofyourdomain>.<tld>.conf

For example, I did:

sudo cp awstats.model.conf awstats.theendoftheuniver.se.conf

You can make as many copies of this conf as you like if you have more than one domain tied to a specific server, simply name them all correctly and repeat the process below.

sudo $EDITOR /etc/awstats/awstats.<nameofyourdomain>.<tld>.conf

Make sure you change at least the following values to your own:

LogFile="/var/log/httpd/mylog.log"
SiteDomain=""
DirData="."

LogFile tells AWStats where to look for your domain’s log. For instance, yours may be /var/log/lighttpd/access.log – you can always grep your lighttpd.conf file for accesslog.filename to be sure of it. If you’re using WordPress, you may have your logs in /var/www/<sitename>/logs/access.log. Again searching for accesslog.filename will tell you.

SiteDomain is pretty self-explanatory. Your site’s domain name. My entry here is simply “theendoftheuniver.se”.

DirData is the path where you’d like data generated by AWStats to be kept. Make sure whichever directory you pick is writable by the user that you webserver (lighttpd) runs under:

sudo chown -R www-data:www-data /path/to/folder/

Make sure that LogFormat is set as 1. This is the correct setting for Apache and Lighttpd logs.

The next couple are optional:

DNSLookup=1
AllowFullYearView=3

They default to 2 and 2 respectively. I prefer setting them to the values above as DNSLookup shows names instead of IP addresses and basic country reports, and AllowFullYearView allows a full year of stats to be viewed on your browser.

You can also uncomment a few plugins for extra functionality. I like “tooltips”, “graphgooglechartapi”, “geoipfree” and “hostinfo”. The last two do require you to install a couple of Perl modules though, namely Geo::IPfree and Net::XWhois.

Updating

Finally, simply update your databases!

sudo /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=<domain>.<tld>

For example, I did:

sudo /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=theendoftheuniver.se

You can now view your shiny new, comprehensive stats at http://yourserver.tld/awstats/awstats.pl?config=<domain>.<tld>

Cron

Now, we don’t want to be running this command all the time. Let’s add it to cron:

sudo $EDITOR /etc/cron.daily/01awstats

Paste in the following and save:

#!/bin/bash
# path to cgi-bin
AWS=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl
# append your domain
DOMAINS="<domain1>.<tld> <domain2>.<tld> <domain3>.<tld>"
# loop through all domains
for d in ${DOMAINS}
do
   ${AWS} -update -config=${d}
done

Now chmod the file to make it executable:

sudo chmod +x /etc/cron.daily/01awstats

Usability

The very last thing you might want to do (honestly, I promise) is add a domain name selection page. This is handy if you have more than domain. If you want one, create an index.html in /usr/local/awstats/wwwroot/cgi-bin/:

sudo $EDITOR /usr/local/awstats/wwwroot/cgi-bin/index.html

Paste in and adapt the following:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function usePage(frm,nm){
for (var i_tem = 0, bobs=frm.elements; i_tem < bobs.length; i_tem++)
if(bobs[i_tem].name==nm&&bobs[i_tem].checked)
frm.action=bobs[i_tem].value;
}
</script>
</head>
<body>
Which site would you like to see stats for?
<div>
<form action="#" method="post" onsubmit="usePage(this, 'bob');">
<br><input type="radio" name="bob" value="awstats.pl?config=domain1.tld"> name1<br>
<input type="radio" name="bob" value="awstats.pl?config=domain2.tld"> name2<br>
<input type="radio" name="bob" value="awstats.pl?config=domain3.tld"> name3<br><br>
<input type="submit" value="Go!">
</form>
</div>
</body>
</html>

Add in or remove as many <input type="radio" name="bob" value="awstats.pl?config=domainx.tld"> namex<br> lines as you need. Simply browse to http://yourserver.tld/awstats to pick and explore your domain.

Here’s a preview of those radio buttons:

Screen shot 2011-07-19 at 03.26.21

Homebrew Versus MacPorts

So on the recommendation of a friend, I decided to get rid of MacPorts and try out Homebrew. Before nuking MacPorts, I made a short list of the ports I wanted to reinstall with Homebrew. To uninstall I followed these handy isntructions here.

So, MacPorts was now uninstalled and Homebrew was successfully installed. I nuked the /usr/local dir (except for a couple of binaries in ./bin) and rm’d a Mono framework in /Library that brew doctor complained about.

I proceeded to install a few ports I used to have installed via MacPorts, and they went okay. Irssi ran fine. However, I started getting rather annoyed with brew when well-known ports such as mpd started failing to compile. And it wasn’t just one, it was disparagingly often. I switched away from MacPorts for less work not more! I simply couldn’t be bothered, so I promptly removed brew and reinstalled MacPorts. My poor old MacBook is recompiling everything all over again.

Perhaps it was just me with the mpd compilation problem? Either way, a shame – it seemed quite nice.

Installing Deluge on Debian Lenny [Updated]

The installation PPA of this post is outdated and you should use the following instead: 

deb http://ppa.launchpad.net/deluge-team/ppa/ubuntu lucid main
deb-src http://ppa.launchpad.net/deluge-team/ppa/ubuntu lucid main

Using this PPA key:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 249AD24C

Unfortunately, at the time of writing, Debian Lenny only has Deluge 1.2.3 in its repositories, which isn’t all that stable apparently.

Also unfortunately, Deluge’s wiki gives pretty bad, long-winded instructions on how to get it working. Luckily, it’s all rather simple. I did the following steps in order to get a nice deluge webui working on a Lenny VPS. Do the following steps as root (sudo su).

Simply fire up your favourite editor and edit:

/etc/apt/sources.list

Tack these two lines onto the end:

deb http://ppa.launchpad.net/ferramroberto/linuxfreedomlucid/ubuntu lucid main
deb-src http://ppa.launchpad.net/ferramroberto/linuxfreedomlucid/ubuntu lucid main

Next, you must grab the GPG key!

apt-key adv --recv-keys --keyserver pgp.surfnet.nl 3ACC3965

Finally, update apt and install using aptitude:

apt-get update && aptitude install deluged deluge-web

Aptitude will then proceed to offer you a couple of solutions (if you did this with apt-get, the install would simply fail). Those solutions are either, (1) Install nothing, or (2) Pull the libraries that python-libtorrent (a dependent of deluged) needs from those PPAs we added to sources.list. I think you can guess which one we want! Thusly, hit n (for no) to the first solution and y (yes) to the second.

If you get any errata about signatures not being able to be verified at the update stage, take a look here.

Next, create a user that will run Deluge. How about “deluge”? (I know, you weren’t expecting that!)

adduser --disabled-password --system --home /home/deluge --group deluge

Finally, follow this very useful part of the wiki. Remember to put it the user as “deluge”. At the end of it, you should have gotten the webui up and running! If you haven’t changed anything, it will be running on port 8112 with the default password of “deluge”.

I discovered that the webui has trouble running on Safari and Chrome (and Opera too, I think) because the session limit expires if the server’s time is wrong (checkable with date). On my VPS it was impossible to change the time using sudo date --set <time>, and the zoneinfo method resulted in the wrong times, and still didn’t work even when I fudged it. Luckily this doesn’t affect Firefox. Thus, to overcome this, log into the webui via Firefox and go to Preferences –> Interface and change the Session Timeout value to 99999 (the maximum possible).

Voilà! Safari and Chrome should find that their session timeouts haven’t timed out yet, as we set the value very high. If anyone finds a way to disable either the password or session limit entirely, please let me know!

You can also add HTTPS by simply finding the relevant tickbox in the Preferences and ticking it – there are default keys and certs that Deluge uses to encrypt itself. Pertaining to this, if you wish to use a signed SSL certificate instead, see this post.

AppleScript for Renaming Scene Movies

So, you recently downloaded a few movies from your favourite movie tracker (completely legally of course seeing as you own the DVD/BluRay hard copy and so are just exercising your fair use rights), but they’re all named the way the scene likes them. That is, “Movie.Title.With.Lots.of.Dots.date.quality.source.codec-group”. Now, this isn’t particularly great if you like to keep a nice movie collection with readable and attractive names. Also, those types of names aren’t always ideal for things like Boxee or NMTs when they come to scan the filename and scrape IMDB and TMDB.

In fact, I rename my movies primarily so they’re fit for use with YAMJ (see my YAMJ collection here). YAMJ likes the name first, then the date in brackets to help it distinguish between other titles with a potentially similar name, and then finally an optional indicator of what quality it is. I think YAMJ can determine whether the file is HD content or not by its use of mediaInfo, but I like to tell it for sure just in case.

So, after a particularly large downloading session I really couldn’t be bothered renaming each of the files by hand and decided it was time to bring some automation to the table, so here we go!

This script will only work for “traditional” scene files, like Blue.Valentine.2010.720p.BluRay.x264-HiDtHarry.Potter.And.The.Deathly.Hallows.Part.1.2010.720p.BluRay.DD5.1.x264-EbP or Discussions.with.Richard.Dawkins.Episode.01.The.Four.Horsemen.2008.DVDRip.x264.

A few conditions: It’s only programmed to work with MKV files. It ignores any file with “sample” in the filename (so it doesn’t bother renaming sample files that come with most scene encodes). It’s recursive, so it’s advisable to create a little temporary folder with all the MKVs (NB: you don’t have move the MKV from the “scene folder” that it came in, just move the entire folder) you want to rename to avoid the danger of something being caught in the crossfire.

This is the script:

set AppleScript's text item delimiters to ""

set theDir to POSIX path of (choose folder with prompt "Pick the folder containing the (scene) *.mkv films you would like to rename:") as text

set theFiles to (do shell script "cd " & (quoted form of theDir) & " && find . -type f -name \"*.mkv\" -size +1048576k \\! -iname \"*sample*\" -print | sed s1./11")
set x to 1

repeat while x is less than or equal to (number of paragraphs of theFiles)

	set AppleScript's text item delimiters to "/"

	set theFilename to the last text item of paragraph x of theFiles

	set AppleScript's text item delimiters to ""

	set highDef to (do shell script "echo " & (quoted form of theFilename) & " | grep -i -e bluray -e 720p -e 1080p -e hddvd -e hd-dvd -e hdtv; exit 0")
	if highDef is not equal to "" then
		set highDef to true
	else
		set highDef to false
	end if

	set try19 to offset of "19" in theFilename
	set try20 to offset of "20" in theFilename

	if (try19 + try20) is equal to 0 then
		try
			set highDef to "2"
			display dialog "The file, " & theFilename & ", doesn't seem to be in a standard scene format. Please name it manually (include extention):" default answer theFilename
			set theName to text returned of result
		on error errstr number errnum
			display dialog "AppleScript suffered an error: \"" & errstr & " " & errnum & "\". Sorry about that. The file has been left alone, and the script will continue."
			set theName to theFilename
		end try
	else if try19 is equal to 0 then
		set theName to (characters 1 thru (try20 - 2) of theFilename as text)
		set AppleScript's text item delimiters to "."
		set someText to text items of theName
		set AppleScript's text item delimiters to " "
		set theName to someText as text
		set AppleScript's text item delimiters to ""
		set theDate to (characters try20 thru (try20 + 3) of theFilename as text)
	else if try20 is equal to 0 then
		set theName to (characters 1 thru (try19 - 2) of theFilename as text)
		set AppleScript's text item delimiters to "."
		set someText to text items of theName
		set AppleScript's text item delimiters to " "
		set theName to someText as text
		set AppleScript's text item delimiters to ""
		set theDate to (characters try19 thru (try19 + 3) of theFilename as text)
	else if try19 is less than try20 then
		set theName to (characters 1 thru (try19 - 2) of theFilename as text)
		set AppleScript's text item delimiters to "."
		set someText to text items of theName
		set AppleScript's text item delimiters to " "
		set theName to someText as text
		set AppleScript's text item delimiters to ""
		set theDate to (characters try19 thru (try19 + 3) of theFilename as text)
	end if

	if highDef is equal to true then
		do shell script "mv " & (quoted form of (theDir & (paragraph x of theFiles))) & " " & (quoted form of (theDir & ((theName & ".(" & theDate & ").BluRay.mkv"))))
	else if highDef is equal to "2" then
		do shell script "mv " & (quoted form of (theDir & (paragraph x of theFiles))) & " " & (quoted form of (theDir & (theName & ".mkv")))
	else
		do shell script "mv " & (quoted form of (theDir & (paragraph x of theFiles))) & " " & (quoted form of (theDir & (theName & ".(" & theDate & ").mkv")))
	end if

	set x to (x + 1)

end repeat

set AppleScript's text item delimiters to ""

Before

After

Of course, you can change the script to mod the final filename however you wish. Comment if you have any problems, or even if you like it!

Redirect www to non-www Preserving HTTP(S) for Lighttpd

First new blog post in a while… I really haven’t been able to find the time. But university finishes soon so hopefully I’ll have the time to while away some hours on here!

I thought this was worth blogging about as I was Googling around for ages without finding a full answer to this problem anywhere. Namely, I found posts about redirecting HTTP to HTTPS and www to non-www, but none about both. Hopefully this will help and make it easy for others.

I assume you already have HTTPS support up and running on your server, though if you don’t, see this post on the Lighttpd website for a simple how-to.

Edit your lighttpd.conf file to include the following:

[gist id=01b92f5ff177f197515c]

The first section checks if you’re using HTTPS. If you are, it checks if the URL has “www.” at the front. If it does, then it strips it but keeps the https in the URL! It does exactly the same thing for HTTP, except it preserves the http in the URL.

To put it into action, simply restart the Lighttpd server using something like sudo /etc/init.d/lighttpd restart

Sort of Done

So the blog is sort of done. Tidied up all the UI elements I wanted tidying up. I just need to add some social bookmarks to the posts here, and then start adding some content!

Just had to chastise myself for using “content” there. Reminds me of when companies use “solutions”. Fans: Cold air solutions!

Over on About I need to sort out the Connect section as well as figure out exactly what I want to turn Portfolio into, or whether I should just scrap it. Time will tell.

Got to Start Somewhere

So this is the inevitably lame first post of this blog that’s drowning in the backwaters of the Internet. Enjoy.