Browser request serialisation
placefell
ext2366
It's beginning to be quite well known that if you want to load a lot of objects from the same web server, then they'll download faster if you give it more than one domain name (but not too many or you get killed by waiting for DNS requests), as web browsers have a limit on how many items they will download in parallel from the same host.

There are other limits to what the browser will download in parallel, and there's now a really cool tool Cuzillion which allows you to see how this works in browsers without having to produce the pages yourself, and without having anything else affecting the page load time.

I did a bit of experimenting with 10 images taking 2s each to load, and found a weird feature of firefox (3.5.2). It does load the first 6 images in parallel, however the next 4 are loaded one after another. Rather than as another block. You can try it yourself here. Thus it takes 10s (2+2+2+2+2) rather than the 4s (2+2) I would expect.

Attached is the screenshot of firebug showing this in action. Does this happen in other browsers?

Parallel requests

(no subject)
placefell
ext2366
Some boxed-sets have multiple CDs. Imagine you're creating an API that tells you which CD a track is on. What should it be called?

Poll #1445800 CD numbering

What should the API call the element representing which CD a track is on?

discNumber
3(60.0%)
diskNumber
0(0.0%)
Other
2(40.0%)

If Other, what should it be?


Collaborative flash development
placefell
ext2366
Does anyone write flash apps as part of a team? It seems that the "source" is a big binary mess of an FLA file. This means that you cannot merge changes made by different developers, basically limiting each file to only one developer at a time.

There also appears to be no command-line compiler, so you cannot have your auto build system compile the flash, or your deployment script. Instead the developer has to commit the SWF file as well as the source. Something that you really shouldn't be doing.

Flex is a lot better in both regards. There's a command-line compiler, and you write .as files like a real language.

Am I missing something? Is there a command-line compiler?

Cpan fail
placefell
ext2366
I tried to install a perl module today. Ok my machine is old, but that's why I'm using cpan rather than using a package that comes the OS. First I discovered readline wasn't working in cpan. That's an easy fix right, you just do install Bundle::CPAN. Nope, it fails.

Recursive dependency detected:
    Bundle::CPAN
 => Test::Harness
 => A/AN/ANDYA/Test-Harness-3.17.tar.gz
 => File::Spec
 => S/SM/SMUELLER/PathTools-3.30.tar.gz
 => Scalar::Util
 => G/GB/GBARR/Scalar-List-Utils-1.21.tar.gz
 => Test::More
 => M/MS/MSCHWERN/Test-Simple-0.92.tar.gz
 => Test::Harness.
Cannot continue.


Now, I'm not dissing people who write perl doing testing. However if you're writing a test harness, please make sure that you're not needed for any of your dependencies to compile. What am I supposed to do?
Tags:

Persistent urls without page reloads
placefell
ext2366
How many times has someone passed you a url to google maps, and you've clicked on it to find you're at a completely different place to where they intended you to be? Quite often you'll be at the centre of a town, or at their house. This is because they've copied the URL out of the address bar of their browser thinking that it will take you to what they can see. This is a very sensible way for them to expect it to work. It is how they've been trained to use the web. However, in order to share a link on google maps you need to click on the "share this" button, and share the url that gives you. When you click the button, it generates a URL that encodes what you're seeing.

The browser URL getting out of sync with what you're seeing is a problem with all ajax applications - they want to update the content of the page, without triggering a page reload and all of the slowdown that entails. Sometimes it isn't just slowdown. On the site our users are playing music, and they don't want it to stop whenever they browse around to find some more to listen to. This problem isn't new to AJAX though, it's been true since the days of frames - one of the reasons that frames didn't catch on was that your browser's urlbar only contained the location of the frameset, which will point to the front page of a site, and not to the page that you're currently looking at.

We "solve" this using a complicated system of javascript. Users without javascript can't listen to music using our play/javascript based player anyway, so will not get music interrupted.

If you browse around the site, you'll see that your url ends up in the form
  http://www.we7.com/#/music/blues

Can you see the "#" in there? That's an anchor in URL speak, and tells the browser that the content after it isn't part of the address of the page to request, but a location within that "page" where the content is found..

What about anchors that are used as anchors?

For example, http://www.we7.com/help/using-we7#playing-music

Most of the time this doesn't work. Instead you just get taken to the top of the page. It does work (it some browsers) for links within the site, where we intercept links in this form, and change the javascript that loads the new location into the content frame, and once the page has loaded, we then scroll the window to the location of that element (well, not quite, as that would put that element under the player, so we in fact have to scroll to just above the element, so that the element is at the top of the part of the page that you can see).

But what if a non-javascript user (or googlebot) shares a link with a javascript user? Some sites make this just add the anchor to the end of the URL that you started on, so if someone comes to our site from a
google search for madonna, they're urls would be of the form
  http://www.we7.com/artists/Madonna?artistId=95352#/about/faq

This isn't a very nice url, as it implies to people that you're sharing it with that they'll see something about madonna, even though you're shareing the FAQ page, it also leaks which page you started from (like
in the google maps case), and for non-javascript people (and google bot if this is a link on a website) will take them to the (unintended) madonna page.

Instead, if your browser supports javascript, and it gets taken to a url that isn't the root, then it'll redirect you to the root with a cookie so that the browser knows what it's supposed to put in the visible part
of the page. this front page will then render the player frame and include the page you wanted to see.

This worked quite well, but had a problem - twitter's url parser will truncate urls at any ? after the # which means that http://www.we7.com/#/arist/Madonna?artistId=95352 becomes just
http://www.we7.com/#/arist/Madonna, which - unfortunately - our site will return a 404 to as it doesn't have the ID. The simple solution to this was to change the javascript so that it switched ? with ! in the urls in the browser, and back again when it made requests. We also had to add a server that would redirect urls with ! in, back to the ? form as people had realised that they could share
urls by just removing the "#/" from the middle.

Bingo, twitter was happy! However a lot of blogging software which didn't mind the ?s in the anchor doesn't like !. We've considered ~, but mail.app doesn't like that (WTF?? hasn't unix has
http://www.example.com/~foo/ for years?)

I think the only safe way would be to remap all the urls in the app so that there are no ?s at all and the parameters are embedded in the path, the way that rails made popular code>http://www.we7.com/artists/95352/Madonna</code> or even http://www.we7.com/artist/Madonna

Any better ways of doing it? Are there good sites that change the URL whilst navigating about using AJAX without this confusing system?

Does this make any sense, or is it just rambling? I should really post more often to get more practice.

Even the jvm gets synchronization wrong sometimes
placefell
ext2366
The JVM has the following code in DeleteOnExit.

  static void add(String file) {
	synchronized(files) {
	    if(files == null)
		throw new IllegalStateException("Shutdown in progress");

	    files.add(file);
	}
    }


What would you expect to happen if files was null?

More...Collapse )

Share your login?
placefell
ext2366
Here's a quick poll...

Some websites ask you for your login details for other sites. This is in order to do something on your behalf. Maybe it's facebook asking for your gmail account details so they can import your address book as a friends list, maybe it's a site that will email your twitter replies to you, or a website that wants to report your listening to last.fm for you. Would you enter your details onto a third-party website so they can access your account on your behalf?


Poll #1394269 Share your details

Would you share your twitter details?

I don't have a twitter account
1(16.7%)
Sure, they can have my details for something cool
1(16.7%)
No way are they getting access to my twitter
4(66.7%)
Isn't that what OAuth is for?
0(0.0%)
I use the same password for twitter as most sites, so they can probably login as me anyway :)
0(0.0%)

How about your last.fm login?

I don't have a scrobbler account
0(0.0%)
Sure, they can use my details to scrobble for me
2(33.3%)
No way
1(16.7%)
Don't last.fm have an authentication API?
2(33.3%)
I use the same password for last.fm as most sites....
0(0.0%)


Discussion...Collapse )

Interesting filesystems hack
placefell
ext2366
This is an interesting feature that I learned from our new sysadmin. It seems like it'll be dangerous until you realise which levels of abstraction it works at.

Simply put: you can mount the same filesystem read-write in two places. [1]

This means that when you are migrating a set of files (from /, but that's not important) onto a different partition you can copy to the new partition, mount it over where they were (and all the open files are still there, just hidden). When you've checked that it all works and want to recover all that space that's taken up with files that you can't get to, then you can mount the filesystem somewhere else (which doesn't have the other mount obscuring it), and delete the files.

It's suggested that prudent people touch a file before they delete, to check that they are about to delete the right set of files.

I thought - eww, that must make a mess, two sets of structures inodes etc in ram, getting out of sync, but no, it's one filesystem at the bottom, and two sets of paths mapping to that one filesystem. The power of abstractions!


[1] In linux, 2.4.something+

Currently listening to Cake - Comfort Eagle

Graze
placefell
ext2366
Anyone else seen all the marketing for Graze?

They are designed to be perfect for office dwellers who want a healthy option for lunch without having to leave their desk. Clearly it's for those people who don't take a proper lunch break anyway. Now, I fall into that category. Normally I bring in left-overs from home, so I'm not the sort of person normally spending 4 quid/day at M&S on a salad though.

They charge you 3 quid/day and post you lunch. What you get is a cardboard box, about the size of a VHS tape, but slightly thinner so it'll fit though letter boxes. In this are 3 plastic containers, containing fresh fruit, dried fruit seeds and nuts. The exact mix can be tuned using their website but telling them your likes and dislikes.

The idea is that you eat it gradually during the day, rather than all at lunch time, and this is somehow better for your metabolism.

I found that I didn't get into it, not helped by the first box only coming at lunch time, but I found that I had finished it all by 2:30. I wasn't hungry. That's a good thing. Then I found that the box I'd eaten contained over 600 calories. Much more than the 400 you'd get from a carton of soup from tesco.

Anyway, I don't think it's for me, but if anyone wants to try, you can get your first box free, and the second half-price, by using the code: FYWNRC5. Their idea seems a good one, and it might work for you, but 3 quid/day sounds like quite a lot for someone who isn't already buying a sandwich every day. Oh, and you'll have to find another excuse to leave the office at lunch and get your fresh air.

No, really, SimpleDateFormat isn't thread safe.
placefell
ext2366
Maybe the documentation for SimpleDateFormat isn't clear enough. It was certainly a bad design decision, but SimpleDateFormat isn't thread-safe. The parse() and format() methods are not thread-safe. They appear to store parts of the date in fields within the object, so if you parse dates in several threads at a time then you might get errors, and when you format in several threads you might get the wrong dates.

It's not like nobody has seen this before, yet still experienced Java programmers keep using single SimpleDateFormat objects from multiple threads. It should probably be one the list of things to teach programmers when they start a new job. Maybe I should have a commit hook to check that nobody uses SimpleDateFormat, and have a thread-safe wrapper.

?

Log in

No account? Create an account