Javascript Image.onLoad Broken

A Javascript Problem, and a Solution

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

Mac Fun and Connecting to LSRfm.com!

SSH Fun, with my New Mac Book Pro, and Connecting to Office Stuff From Home Stuff.

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!!!!

iPhone Shoutcast App.

Just a quick post to say,

OMG its the Shoutcast iPhone Application!

http://blog.shoutcast.com/2009/01/09/announcing-the-shoutcast-radio-app-for-iphone-and-ipod-touch/

Shoutcast and LSR on the iPhone
Shoutcast and LSR on the iPhone

You have to turn on Hi-Bit streams in settings tho to listen to LSRfm.com, it wouild appear out low quality stream is not in the index…..

OpenHackLondon 2009

OpenHackLondon, EPIC

Yahoo hack day, well what a weekend, started off in a team, got on the train down to London after and Epic Strip the Riley, followed by a Curry.

Whilst napping my team deserted me…. Not nice.

Got to London, tube, stole some wifi from the Radiisson Hotel.

Went into hackday, set up my machines:

Desk of HackDay with CardboardLaptopStands
Desk of HackDay with CardboardLaptopStands

Built a chair:

Watched some bands,

Yes that is a GameBoy
Yes that is a GameBoy

watched Blade Runner, And all three LOTR in order.

Ended up that me, phoenixrising, and Cauis built the twitter search API, but using YQL, so we didnt present it, but did/will be extending it to search other sites…

Then more bands and bean bag fun

Then came home again…..

And excellent weekend, learned a lot and lorward to going next time….

Things to Remember for next Year

Bring Headphones

Bring Wireless Router for table Intranet

Bring Speakers

Bring External Harddrive

Bring A Server

Make bigger Chair

Decide on team and Idea before arriving

Google Summer of Code: ACCEPTED!

GSoC Its ON!

Woot I got accepted to Google Summer of code!

This year I shall be working with GeekLog and AptitudeCMS on a Syndication API.

This also means Summer will be code filled, and I’m back on Planet Soc! Rocking and rolling for another year.

Landon and Robby are also back on the Programmed! Thousand Parsec and OpenMRS Respectivly!

I’m off to work on the Wailers Gig at LUU today so will catch up with you all later!