IPhone, Mobile Safari and JavaScript

I, personally, find it really irritating when a device (like, say, an IPhone) uses a browser (like, say, MobileSafari) which behaves in a contradictory manner (like, say, displaying the contents of <noscript></noscript> tags and running the scripts embedded in the page perfectly). Grrr.
</venting>

Rants
Technology
Web development
Work

Comments (1)

Permalink

/usr/bin/env

The first thing I do whenever I start a script is to add the #! line. When writing Python I have always written ‘#!/usr/bin/env python’ and when writing Perl ‘#!/use/bin/perl’. I suspect this stems from using systems where it was commonplace to have multiple versions of Python installed (at the time, 2.3 and 2.4) but only a single version of Perl (5.8.8).

This has always worked fine for me because 90% of the time there is only one version of Perl, and it(or a link to it) is at /usr/bin/perl. I discovered today, however, a situation where there are multiple versions of Perl and the one I want is not at /usr/bin/perl.

I recently purchased a 12" PowerBook running OSX 10.5. I needed some development libraries installed and MacPorts seemed to offer the quickest, easiest and most maintainable route to install them. So I installed the libraries I needed and one of them pulled in the MacPorts version of Perl. I then spent the next 30 minutes, or so, trying to figure out why my script would not run but manually invoking the parts causing it to fail with ‘perl -e’ worked fine. It turned out (as you have probably guessed by now) that my script had a #! line using /usr/bin/perl (the OS provided version) whilst `perl` was using /opt/local/bin/perl (the MacPorts version) due to path precedence. Changing the #! line to ‘#!/usr/bin/env perl’ made the script run properly.

Powered by Bleezer

Uncategorised

Comments (4)

Permalink

Happy birthday to me!

See title.

Life

Comments (1)

Permalink

Bash.org++

Bash.org++ for this:
(http://bash.org/?845468)
<piercings> A programmer started to cuss
<piercings> Because getting to sleep was a fuss
<piercings> As he lay there in bed
<piercings> Looping ’round in his head
<piercings> was: while(!asleep()) sheep++;

Funnies
Web links

Comments (2)

Permalink

This bodes well…

/usr/bin/env: ruby: No such file or directory

Web development

Comments (0)

Permalink

Why it is technologically impossible to block modern filesharing.

Yet again, our country’s government has demonstrated a complete inability to grasp the fundmental issues involved in a technology-related issue. I’m talking about the recent news story that the British government plans to introduce legal sanctions against ISPs who do not take “concrete steps to curb illegal downloads” (BBC News, 22 Feb 08). In order to avoid these sanctions, what could the ISPs do? Here is a list of a few suggestions, and reasons why they are completely ineffective:

  • Packet sniffing - This has two major failings:
    1. Any kind of packet-sniffing on the amount of data ISPs are constantly shuffling around is going to require some hefty (and expensive) equipment
    2. It is will be instantly circumvented by the introduction of encryption by the filesharing protocols (in fact, according to Wikipedia, bittorrent already uses this to circumvent some ISPs throttling).
  • Block filesharing ports - This is a non-starter as most filesharing applications seem to use a range of ports. If the ISPs start down this route, the filesharers will simply move to different ports (port 80, anyone?). Sooner or later they will block some of the higher-numbered ports which people and businesses care about - blocking port numbers over 2000, for example, would mean that I could not access my VPS’ admin console, my place of work could not update their website and I could not access my svn repository preventing me from performing my job.
  • Block access to websites which facilitate filesharing - This is the simplest (and perhaps least effective!) method of trying to control filesharing. This month, the Danish authorities ordered one ISP to block access to a website called “The Pirate Bay”. According to one source this action resulted in a raise in traffic to the site, from Denmark, of 12%. Clearly censoring the web in this way is not going to work (as well as being questionably legal, anyone remember free-speech?).

Even if the ISPs do find an effective means to block the current popular filesharing software the users will just start using something else, potentially a brand-new protocol and this whole saga will start again. And what of the people who use filesharing technology to distribute legitimate files. I have used “bittorrent” software to download DVD images of some Linux distributions, perfectly leagally (they are free to distribute and re-distribute), as the distributions in question do not, and cannot, provide any other means to downloading the large images (usually in excess of 4GB). How will the ISPs be able to block illegal sharing and still protect the interests of organisations which legitimately provide software for free?

Clearly the coorporations, which are pushing the government for this action, would be better off looking at themselves and trying to understand why people seem to prefer piracy to legitimate routes of acquiring products. One BBC article (whose link I have misplaced, sorry) sums it up quite neatly, saying that the quality of pirated downloads is superior to that of purchased downloads (aside: the poor quality of downloaded music is why I still buy CDs and refuse to buy from the likes of iTunes) and that one of the major reasons piracy of so prevelent in the UK is the huge gap between the showing of headline programs in the US and the UK.

/rant.

Rants
Technology

Comments (0)

Permalink

SELinux

One of my colleagues gave me a VMWare image to use to test authenticating Linux (CentOS in this case) with Active Directory. Unfortunately the image in question is about 10GB and after the existing images on the machine there was not enough for it in /var (a 17GB partition on a 20GB disk). As I could not find any more space on the existing drive I clearly needed to add another disk to the machine. Three dead disks later I finally found a (250GB! - effectively winning the hard-drive lottery) hard disk which no-one was using. Now just to move /var to the new disk.

I partitioned and formatted an 80GB partition, mounted it and copied the existing contents of /var accross. One edit to fstab later, I rebooted. The disk mounted fine, but various services refused to initialise with “permission denied” errors on /var. I checked the permissions against the old /var and they appeared to be identical. Some head scratching later I decided to go an ask the advice of one of my colleagues. He was equally bemused, but suggested that I tar up the old /var and untar it over the new partition incase the copy had not preserved the permissions (even though it had been told to, and they appeared to be correct). I did this however it had no effect. When I returned to my colleagues office, another one of my colleagues was talking to the first and the first suggested that he take a look. He had a quick glance at the problem and asked if SELinux was enabled. It was. One quick `restorecon -R /var` later everything worked. We then proceded to have a rant from colleague #2 about how Fedora and RHEL now had SELinux in enforcing mode by default where as it used to just warn by default, which was better in a production environment where it needs to be run in warning only mode for a while to check nothing is hitting it that should be allowed. Still it is all good fun.

CentOS
Linux
Rants
Work

Comments (0)

Permalink

About time for another post.

Having written nothing on my blog since the 1st of September I feel it’s about time to flex my inability to spell (made worse by the fact that my sister has stolen“borrowed” the dictionary I keep by my computer) again and write something.

Since my last post:

  • I have quit my job.
  • I have started a new job (”IT Services Specialist”) at Loughborough University, part time.
  • I have returned to my job at Startin Tractors for the other half of the week.
  • my sister has been moved to a more secure secure ward - she’s now locked up with the likes of mentally ill prisoners.

Still it’s all good.

I only wish I had something interesting to put here, but I can not think of anything so instead I’m just going to provide a link to http://bash.org, to annoy anyone trying to work at this point.

Blog
Life
Work

Comments (1)

Permalink

Windows FTS

Windows just helpfully rebooted itself (in order to install updates) because I did not spot that the “Rebooting in 5mins…” dialogue had appeared in the background. The last time is showed (10 minutes before) I only managed to catch it 3 seconds before it was about to restart the system. I find a number of things wrong with this:

1. A dialogue which will result in something happening if immediate action is not taken to prevent it (which is a bad idea for a dialogue in the first place) should draw as much attention as is (sensiabily) possible to itself. Being always on top would be a good start, as would flashing the taskbar. That way it could not be ignored and the user would have to clear the dialogue by selecting the “reboot now” or “postpone” buttons. (Note I said “on top” not “focused” - focus stealing is evil and even a critical dialogue like this should not practice this method of grabbing the user’s attention.)

2. Rebooting the system should require elevated privalidges (in my opinion - and if Windows update is already running with elevated pricalidges why am I not prompted to allow it to have these? I am when most Linux distros wish to install updates). What is the point in preventing programs from installing software, altering critical system files etc without my being harrassed by UAC if a process can reboot the system on a whim?

3. For the love of bob can IE please prompt me to save the tabs when a reboot is being forced upon me, in the same way as when I click on the big red ‘X’ in the top right? I not only lost the tabs I was still reading through, but also the contents of my shopping basket on an e-commerce site. As I now do not have the time to rebuild the contents of the basket (due to venting my frustration at my blog, which is far more fun ;) ) the site in question has lost a sale (for a few pounds shy of £100), thanks to Microsoft.

 On a completely different note: I am currently debating what UI convention (specifically related to button placement in dialogues, at the moment) to follow for a new web app I am thinking about developing in my own time. The choice boils down to:

1. Follow MS Windows’ convention, which is likely to be most familiar to the user

or

2. Follow GNOME style convention, which make logical sense and (following button labeling guidelines, as well as placement) significantly reduces the likelyhood of dialogues in which the choice can be ambiguous as to which button will perform which action.

The fact that this is a web app means that following a non-MS convention may be more easily accepted by unskilled (strictly in the sense of computer use) workers than if it were a stand-alone app which was designed to be used within a Windows environment.  On the flip-side, following MS’ convention would probably decrease the learning curve due to the user’s existing familiarity with Windows-style dialogues.

Rants
Technology
Web development
Windows

Comments (1)

Permalink

…and then there were two (posts)

Having survived another day at work, I’ve now gotten round to writing the final few things I missed off this mornings blog post.

One thing I forgot to mention this morning was that, although MSSQL deleted over 1,000 records from a table by a cascaded delete, the output says “4 rows affected” as only four were deleted from the first table. If a higher number had been reported anywhere in the output it might have allerted to us that there was a problem earlier than the customer calling support because their site no longer functioned correctly.

Rant aside, since my last blog post (in May, this is just an extension of this morning’s) my Grandfather, who was formerly a Commando and then a coal miner, died. He’d been ill for sometime but we did not expect him to die quite so suddenly. Fortunately he died peacfully, in A&E where he’d been taken after coughing up some blood at home.

Yesterday Pete wrote about a document on maintainable code he found at work. The document makes some very good points for writing “maintainable code”. However I would dispute the suggestion that “Every function should be most 20 lines of code”. The rule where I work is that a function should be the length necessary to perform its given task, no more and no less. Usually this means that the function will fall well within the 20 line limit suggested, however it is not uncommon for a complex function which performs a very specific task (such as manipulating the contents of a particular input file, from a manufacturer, to fit the database schema)  to be 100 or more lines in length. Setting a hard and fast limit on the length of a region of code, be it an if block, a function/method, a class, etc. is not, in my opinion, conducive to maintainable code.

Another interesting item I saw noted on Planet Compsoc was this BBC article about Lenovo (who made my wonderful T60) preparing to sell laptops with Linux pre-installed on them. At the bottom of the article it says “Analysts believe that approximately 6% of computers users run Linux, similar to the numbers choosing Apple Macs”. I find this fact extreemly interesting as the company I previously worked for, in the holidays, had a statistics analyiser (which I installed) for their web logs, which showed approximately 6% of visitors to the site used Linux. The Mac quotient of Visitors was significantly less than that, however, and a full 90% of Visitors used Windows XP. Another random fact I found interesting was that use of IE 7 and IE 6 to visit the site was evenly split at 45% each. It makes me wonder how many of those have IE 7 simply because Windows Automatic Updates have installed it for them, and how many of the IE 6 users only have that because they never run the Automatic Updates.

Finally; At christmas I undetook the task of re-writing the stock management system I had previously written for my then employer. The re-write was necessary as the system had started out as a very small and simple thing, which had then had bits and pieces botched onto it as and when my boss decided that it would be nifty to have feature X (or Y or, more commonly, X, Y and Z. By lunchtime.). The result, as always with projects which develop like this, was a hideous mess with, for some reason, worked. Until it stopped working. And then something would hit the fan and land on my desk.

As a result I decided to dump the hacked-to-death php code, and re-write it using an MVC framework. I settled on Rails as it promised great productivity and allowing the developer to concentrate on writing functionality while it worried about the nittity-gritty, such as interfacing with the database. I completely re-wrote a system which had taken over 2 years to develop in 3 months, and Rails did deliver on its promises. Since I’ve stuck to the (somewhat enforced) MVC seperation of the Rails framework adding functionality is a doddle, as is maintaining the code. I have, however, found a small flaw in my approach.

The rails URL scheme opperates on the theme of ‘[controller]/[action]/[id]‘, where the controller is the name of the controller (duh!), action is the method within that controller which is being called (and is also the name of the view) and id is an identifier (intended for identifing a db record, for example). I am aware this can be hacked somewhat with the Rails cofiguration, but deviating from the intended path for such frameworks often leads to problems down the line when the framework developers decide to fundamentally change the framework such that these hacks no longer work as intended. Anyway, back to the URL scheme. This is all fine and dandy when I have a stock management system with a ‘browse’ controller, which has such actions as ‘list’, ‘view’, ‘pdflist’ and so on, and an ‘edit’ controller which (also) has a ‘list’, ‘edit’, ‘uploadimages’, ‘uploadpdf’ etc. . (I know it looks like the two list actions violated the DRY (Don’t repeat yourself) philosophy, but they operate in fundamentally different ways, the browse one only operates on a specific subset of the database limited, among other things, to just what is in stock.)

My problem is that, although this is fine for a stock management system, I also need to integrate the old parts management system in as well (on the old system this was a HORRIFIC kludge). There are two obvious solutions, neither of which I’m keen on. One is to create a ‘parts’ controller in the existing app, which contains ’editlist’, ‘viewlist’, ‘edit’, ‘view’, ‘uploadphotos’ etc. . This could possibly extended to move all of the stock stuff into a ’stock’ controller. I do not like this as it a) feels too much like bolting the thing on, like the old mess which I’m obviously keen to avoid recreating, and b) the controllers would then get very large and the maintainability provided by seperating out these systems will vanish. The second alternative is to create a seperate rails app to do the parts management. As I mentioned I’m trying to integrate these systems, so creating a seperate app for it seems like a bad move towards that end. It would also mean hacking the Rails config to not assume it is at the root url, and setting up the webserver to rewrite urls. It is all hassle I’d like to avoid.

I’m now wondering if I should have use Django instead, where a project (or site) is supposed to be a collection of apps and I suspect that, as a result, the integrated stock and parts management system would be a lot easier to realise. I’m now back into the realm of trying to justify, either way, another rewrite of the system. I will add that Rails has given me some major performance headaches, and I’ve had to re-write portions of my code to not use the Rails helper functions, which I view as bad, as my code now relies of certain aspects of the Rails framerwork not changing, where as the helper functions should (I would hope) be updated to reflect changes made in the future, in order to achieve something of the order of an acceptable performance.

Life
Linux
Rants
Technology
Web development
Web links
Work

Comments (0)

Permalink