« Archives in January, 2010

Motion Graphics

Part of my degree is to create a 3-4 minute project, using Adobe After Effects.

So this is the first of many blog entries on the Subject. This blog (under this category) will form part of my project entry, (5% in fact), as a production journal.
So any comments will come in handy!

Currently I’m slightly add odds, but have a thought of creating a advert for Firefox or perhaps google chrome.

Ultimately using shape and colour manipulation to merge the relevant browser logos to create the chrome one.

Perhaps starting the 3-4 mins with a quick browser history, Netscape anyone??? 😛

Watched Transformers (the first Michael Bay one) today and having watched Start Trek XI by J.J. Abrams, should be good inspiration for this project, in terms of technology.

Avatar might be a bit far…..

Javascript Image.onLoad Broken

Heres my code:

        var target = '';
        var loadstr = '';
        var webcamimg = '';

        function runwebcam(ttarget) {
                target = ttarget;
                webcamimg = new Image();
                loadstr = "http://lsrfm.com/images/webcam/lsr_studio.jpg?" + Math.random();
                webcamimg.src = loadstr;
                webcamimg.onLoad = gowebcam();
        }

        function gowebcam() {
                //stuff
        }

Thru the use of FireBug I’ve discovered that the function onLoad declared by onLoad is executing regardless of whether the image has finished being downloaded, which was my understanding as per TechRepublics Article.

So after a bit of hunting around I found this from Talideon.com.

So my adjusted code now reads:

        function runwebcam(ttarget) {
                target = ttarget;
                webcamimg = new Image();
                loadstr = "http://lsrfm.com/images/webcam/lsr_studio.jpg?" + Math.random();
                webcamimg.src = loadstr;
                webcamimg.onLoad = gowebcam();
        }
        function gowebcam() {
                if (!webcamimg.complete) {
                        setTimeout("gowebcam()", 500);
                        return;
                }
                //stuff
        }

Update:

Video of before/showing the fucked-upness

And Not fucked

Curl, MusicBrainz and PHP

As part of the New Years Resolutions I didn’t make.

I’m updating my blog with some Code Snippets!

Been fiddling about with my PHP powered Jukebox that plays out on LSRfm.com (Leeds Student Radio) Overnight, and there is a need for a bulk track adder.

So, I’ve been tidying up the MusicBrainz Data Fetcher, as well as fiddling with PHP and getting ID3 tags from Files. But thats a different blog post.

Essentially there is a (new-ish non updated recently) PHP Library for the interaction with MusicBrainz, (A music database), recently found that (this morning its rubbish), but of no good.

So went back to my curl method.

Tidyied it up and got it down to a few less lines.

Essentially for a given track, the PHP extracts the ID3 tags, and then passes it to this function: (its needs making into a function btw :-P)

$curl = new curl();

$data = array(
	'title'		=> 'Showdown',
	'artist'	=> 'Pendulum',
	'release'	=> 'In Silico',
	'duration'	=> 327784,
//	'tracknumber'	=> 0,
//	'count'		=> 10,
//	'releasetype'	=> '',

	'limit'		=> 25,
	'limit'		=> 1,
);
$target = 'http://musicbrainz.org/ws/1/track/?type=xml';
foreach ($data as $ref => $dat) {
	$target .= '&' . $ref . '=' . urlencode($dat);
}

                                $curl->target($target);
                                $curl->runit();
                                $mb = $curl->bodyarray['metadata'];

if (isset($mb['track-list'])) {
	$mb = $mb['track-list'];

	if (isset($mb['track']['0'])) {
		$mb = $mb['track'];
		$artist_id = $mb['0']['artist_attr']['id'];
		$song_id = $mb['0_attr']['id'];
	} else {
		$artist_id = $mb['track']['artist_attr']['id'];
		$song_id = $mb['track_attr']['id'];
	}
} else {
	// no data
}

echo "\n" . $artist_id . ' ' . $song_id;

Where new curl() just calls my Curl Class.

I’m sure you have your own ways of doing curl, but mine just sets the target with $curl->target and curlexec() with $curl->runit.

The result is in $curl->body, or exploded nicely as an array in $curl->bodyarray. I’ll post about my curl later! As well as some other Carlyon_CMS stuff.

So thats a quick rough and ready way to get a artist and song ID from MusicBraiz.

Its worth noting that since my limit is st to 1.

The first option of if (isset($mb[‘track’][‘0’]) is entirely redundant, as that only triggers when mb returns more than 1 result.

(I only just added limit before writing this post, which is where I decided to write this post)

The MusicBrainz Docs for its XML service is at: http://musicbrainz.org/doc/XML_Web_Service If your Interested!

Mac Fun and Connecting to LSRfm.com!

So, I’m sat at home, having finished work last night, running Fruity Single handedly (the other tech broke his elbow before coming to work, and got sent to A&E bout 1am).

And then sleeping, (hmm sleep)

I find the need to connect to my FreeBSD VM, which is running on my Vista Laptop, which is in the LSRfm.com Office.

Its worth noting that the FreeBSD VM is running its networking as a NAT, so has its own IP address, so the Vista Laptop as a machine has two IP’s.

Standard SSH Tunnelling for the win!

ssh -p <open external port> -f bcarlyon@<lsr office domain> -L 1313:<internal IP of the VM>:22 -N && ssh -p 1313 bcarlyon@127.0.0.1 && kill `ps aux | grep <lsr office domain> | grep -v grep | awk ‘{print $2}’`

Breaking the command down.

Open the tunnel to the office (I like using 1313 and upwards for local ports, 13 is my lucky number).

-p specifys a port, as @katie_server, the machine I am SSH-ing to initally is port forwarded from the LSRfm.com Firewall.

-L sets up the local port

-N executes no command and puts that SSH session into the background.

Then open a ssh session thru that local port

When I exit the SSH session, the grep command kills the Tunnel, but only ssh commands for the lsr office domain.

grep -v grep makes sure that the grep command is exculced from being killed.

I discovered that the awk ‘{print $2}’ was outputting all the matches and thus kill killed them all which is a bonus, see next.

So I decided to setup Foxy Proxy on Firefox, so that I can route all my network traffic that match a lsr office computer, in this case http://192.168.0.*

So my Firefox now uses normal Internet unless accessing a LSRLocal Ip Address, at which points it routes it thru the socks proxy.

That socks proxy being a SSH tunnel to LSR office:

ssh – p <external port> -f bcarlyon@<lsr office domain> -D 1314 -C -N

-D sets up a dynamic, routes all traffic that goes thru 1314 to its relevant port on the outside or internal internet.

So if I wasn’t using FoxyProxy patterns and was routing all my network traffic in Firefox thru the Socks Proxy, then I can access the whole of the internet thru the tunnel, rather than use -L for a local/specific computer.

-D can be used with PuTTY, say if you wanted to listen to Pandora in the UK and happen to have SSH access to a server in america, or if you wanted to use IRN, which is IP Locked, in LSRfm.com’s case to the LSR office.

So now by alias-ed command for my mac, called freebsdvmnet reads:

ssh -p <ext. port> -f bcarlyon@<lsr dom> -L 1313:<VM IP>:22 -N &&
ssh -p <ext. port> -f bcarlyon@<lsr dom> -D 1314 -C -N &&
ssh -p <ext. port> -f bcarlyon@<lsr dom> -L 1315:<VM IP>:80 -N &&
ssh -p 1313 bcarlyon@127.0.0.1 && kill `ps aux | grep <lsr dom> | grep -v grep | awk ‘{print $2}’`

So,

Open ssh tunnel, to LSRfm.com, thru Katie, into FreeBSDvm (running on Vista Top (Hannah).

Open ssh tunnel for internet access

Open specific Tunnel for FreeBSDvm

Open SSH session thru tunnel to FreeBSDvm

KIll it all, when I exit the SSH session thru the Tunnel.

Given my FoxyProxy setup, the Specific Port 80 Tunnel to the FreeBSDvm is not needed. (I discovered FoxyProxy Patten Matching after writing the command).

So after all this I thought about connecting to the LSR File Server (lsr-fs) thru the tunnel. Initially trying a standard SSH tunnel on port 139, I find that smb://localhost:port/share/ the use of localhost is disabled in current OSX.

Brief Google Later: http://blog.newsyland.com/mac-os-x/leopard-broke-smb-tunneling

Choices Choices.

sudo ifconfig lo0 alias 127.0.0.2 up

Seems easiest, but I find myself using, the main instructions.

Create a ssh tunnel overwriting port 139, then smb://localhost works fine, (but seriously why disable the localhost loop back in the first place)

sudo ssh -p <Ext IP> -f bcarlyon@<lsr dom> -L 139:127.0.0.1:139 -N

The Blog Advises routing 445 too.

Both are privileged ports so need Sudo.

So some terminal use as directed by Newsyland Blog = Win

So that is what I’ve done this morning, some ssh fun and accessing the File Server as if I was in the office.

Next to see if it works on Windows, this is gonna be useful for general use, (and stopping my Apache server needing .htaccess Rules to stop people accessing it) and for Student Radio External Broadcasts!

AND YES I STILL NEED TO FIX MY BLOG STYLE!!!!

My new toy

🙂