Tuesday, July 29, 2008

<blink>ing without <blink>

<blink> is clearly the best tag ever in html. It's my favourite quasi-tag at least and I wonder why I don't use it as often as I should.

The thing is NO ONE ELSE likes it. I mean WHY SHOULD THEY? It's fairly annoying to people who take the internet seriously. I mean with macromedia flash or pictures you can create some pretty annoying stuff but put it in to plain text and YOU'VE GONE TOO FAR.

I'm a strong believer of <blink>. I think the world would be a better place with <blink>. However there are a few people who dislike <blink> (or at least claim that it doesn't exist) these people are:
  1. The w3c
  2. Internet Explorer
Well that is a bit of a lie. The w3c does allow <blink> but only in CSS in the following example:
span.blink{text-decoration: blink;}
So you see blinking is not difficult if you want to stick to standards. Just use <span class="blink"> and you are in valid HTML/XHTML zone.

This only leaves one problem: Internet Explorer.

Sadly Internet Explorer is an old dog who can't learn new (or old depending on how you look at it) tricks. Sure it's now a little more sensible tha... no wait to be honest I prefered IE6 to IE7, where everything has been moved to fit in with the vista "Everything's not where it was before" concept. I actually liked IE6 before that annoying yellow bar rubbish from an XP service pack. Seriously. Ok where was I? Er... umm...

Well my point is that Internet Explorer is rubbish.

However I can't leave it like that. When web developing you have to consider ALL of the browsers. Oh wouldn't it be easier if everyone used FireFox but websites should also work on browsers like IE, Opera and Safari. IMO IE is still used by people who can barely use a computer (since they don't know that there are other ones they can install) while Safari is used by people who bought an iPod recently and iTunes told them to install Quicktime and Safari while Opera is used by smug people who don't want to use IE (because it's rubbish) but don't want to resort to FireFox because of it's popularity (AKA The kind people who tend to have listened a ton to bands you never heard of on last.FM).

Anyway, minirant over, since making some JavaScript that redirects to a page that tells you to "DOWNLOAD FIREFOX YOU IDIOT" is a little obnoxious and patronising, there is another option.. which funnily enough uses JavaScript.

Search "Cross Browser Blink" or "Blink on IE" and you will find enough on how to get it to work on everything else. The thing is this is the most problematic bit:
var blink = document.all.tags("BLINK")
The problem with this is that "blink" is now a "class" and not a tag anymore and so this needs to point to that instead of the blink tag.

Problem here. Since it's now defined by CSS rather than a tag you are going to need some good JavaScript skills.

I was lazy and was told that I should use JQuery cause "It's da best", aparrently. so I did. If you replace 'document.all.tags("BLINK")' to "$('span.blink')" you'll get it working (so long as you put in JQuery as well)

So there you go. Blink tags in everything and all done without using a single <blink>.






Next week: How to embed MIDI into webpages without looking like an ass

Thursday, July 3, 2008

This is what I have been so smug about for the past week...

Have I mentioned that Python is my favouritest programming language ever? If not I am mentioning it now. Granted, I am a nub at programming, last year I knew no programming language and didn't intend to learn more than what I would at University (which to my knowledge was just java) I couldn't even TOUCH Linux. Now it's my prefered choice for OS (though only Ubuntu, I'm still learning ;) )
Oh god I sound so blooming smug in that paragraph.

Though I might like to point out that I'm a nub to computing (the last year has shown me that), I don't actually like talking about how amazing I am at these things. I feel that some elitist is about to look at what I have written and sneer and chortle at my nubishness.
"Python? Ubuntu? What lark! What an uneducated individual but I suppose simple things please simple minds ;)"

I don't really have to imagine it since I already know someone like that. Lets say his name is Phil (it isn't actually). Phil is a know-it-all/cynical cunt/elitist and although I don't mind his crap he does annoy the crap out of me so that the only option I have is trolling him, which is not difficult. All I have to say is "The only useful command in vim is :q" and watch him blather about how I'm wrong and that vim is the best damn text editor in the world putting him in the pool of fanboyism that I shown with Python or Ubuntu.

However as much as I'd like to talk about my crazy adventures with Phil I wanted to get to my original point. I really like Python. Not as much as i'd make a website dedicated to how amazing the programming language I like is, but more to a point where it's would be the only language I'd use. Of course that doesn't make much sense but to be honest, me and Python was like (and mind the cheesyness of this) the perfect couple. Ok it's simple, but that's how programming should be. Writing about 4 lines of code that look like english is easier than writing what seems to be like advanced maths.

Would this mean I'd like ruby? Possibly, but I'd prefer to stay faithful to my lover. Also I can't think how I would do one-line-solutions for Project Euler with ruby. I'll stick with what I know at the moment.

Anyway, what I was getting to is that I like to use Python anywhere I can. I sneak it in my Pseudocode. I make solutions with it that are smaller than my Java ones. I even use it at work. Really.

I am bilingual (i.e. I know English and Welsh), and this summer I've been lucky to get a job doing translating. Not quite what I was made for. Just because someone is able to speak two language doesn't really mean that they can translate perfectly between the two. Luckily for me I have someone helping me however this person is not the fluent in welsh and therefore I have to help her tel her what is a particular word was and whatnot.

Anyway, I had enough of checking the dictionary myself and sent the online dictionary to her. The problem was that if one dictionary didn't have a word the other would and so you'd have to look in all of them (which was 3 in total, not much but still a pain to look over). The other thing was that you'd have to switch to "English to Welsh" mode before sending the word otherwise it wouldn't find anything. What I needed therefore was a little thing that would get the word and show a list of the welsh vesion. This in Python was as simple as importing the webbrowser module and doing the following:

webbrowser.open("http://www.bbc.co.uk/cgi-bin/wales/learnwelsh/welsh_dictionary.pl?gair="+raw_input("What is the word?: "))
A few problems came from this. It was only one dictionary so:

word = raw_input("What is the word?: ")
webbrowser.open("http://www.bbc.co.uk/cgi-bin/wales/learnwelsh/welsh_dictionary.pl?gair="+word)
webbrowser.open('http://www.geiriadur.net/atebion.php?term='+word+'&direction=ew&type=all&whichpart=exact')
This gave a seperate problem since it only gave the last webpage. Funnily enough I managed to make it pop up two windows in Visual Basic (using the macro maker in word as a guide) I also managed to make it little bit more clever by looking for the word that someone has selected instead of having to type it in. I felt that having 2 popups was a bit too much though. Plus the websites were pretty distracting.

My plan was therefore to grab the data of both pages keep the useful data and print it out on one page. While the first (urllib2) and last (webbrowser) was simple the middle (re) was a bit tricky. I had no experience whatsoever with regular expressions, still I tried. After hours of figuring out why it wasn't working I ended up having to remove any \n, \t and \r characters so that the whole webpage HTML was on one line. Numerous fiddling about and the thing was working.

However I wanted to do what I did with the first version (i.e. a select word and push butan thing). The VisualBasic was easy however the way I had to get it working was to have the VB pointing to:
"..../Dictionary2.py " + Word
Also I thought I should have it as an exe since other people are going to use this. This was something that Phil was going to laugh at. "What you want to use py2exe so you can make buggy programs? HA!". Fortunately I ignored him and did the program anyway. You can get it with the link below (This contains the code as well):

AFALS ENGLISH TO WELSH DICTIONARY GRABBER

If you want to know the final what the VB script is so you can run it in Word it's this:
TheWord = "[whatever the path is]Dictionary2.exe " + Selection.Text
Shell TheWord, vbMinimizedFocus
(Funnily enough I got Phil to see the code. He found nothing wrong)

To use it either use the VB script, double click it and type in the word you want or in command line just use "Dictionary2.exe [whatever the word is]". THIMPLE.

Known quirks: Firefox complains when trying to run it. However the list is made if you just look at "Dictionary.html" in the folder.

Now the next step is to get this thing to do my work for me...