Sidetracked
Day to day ramblings of a web developer, with rants and raves about work, music, fatherhood, and life in general, with a liberal smattering of japes and jokes....
Sunday, October 23, 2011
Saturday, October 22, 2011
Friday, September 17, 2010
DJ Fresh - Gold Dust OFFICIAL VIDEO (Out NOW)
Monday, August 16, 2010
Lost Generation
Saturday, August 14, 2010
Tuesday, July 20, 2010
Quick Tip – Optimizing DOM Traversal » Learning jQuery - Tips, Techniques, Tutorials
The topic of optimization has come up a number of times in the jQuery mailing list. jQuery’s DOM traversal is powerful and easy, but it can sometimes be slow as well. As with any JavaScript library or framework, the helper methods will be slower than the plain old JavaScript (p.o.j) methods. Nevertheless, if we keep in mind the jQuery’s speed hierarchy, the speed difference between jQuery and p.o.j. will often be negligible.
The “speed hierarchy” goes like this, in order of fastest to slowest:
- ID : $(‘#some-id’)
- Element : $(‘div’)
- Class : $(‘.some-class’)
jQuery uses JavaScript’s native
getElementById()
to find an ID in the document. It’s fast — probably the single fastest way to find something in the DOM — because it’s only looking for a single unique thing, and it’ll stop looking once it has found it. So, if we have<h2 id="title">This is my title</h2>
, we would use$('#title')
, not$('h2#title')
to access it.To find a bare class name, as in #3 above, jQuery goes through every element in the entire DOM. To find an element, on the other hand, it uses
getElementsByTagName()
, thereby limiting the number of elements it has to traverse right from the start. Therefore, if we know which element the class is tied to, we can speed up the traversal significantly by referring to it, using, for example,$('div.some-class')
rather than$('.some-class')
.Likewise, we can help jQuery gather our classes faster if we can limit where jQuery looks to a particular ID:
$('#sidebar .menu')
, not$('.menu')
.I’m sure there other ways to make DOM traversal speedier, so if anyone knows any other tricks, I’d love to see them in the comments. Also, I should probably reiterate that if speed is all you care about, no library/framework is going to beat p.o.j.
Update: Motivated by enej’s comment, I put together a little speed-test page where you can try out a number of different DOM queries and see how fast they are. Since I posted a link to the page on the jQuery mailing list, there has been quite a bit of activity in this area. Aaron Heimlich extended the speed test to work in conjunction with Firebug for some awesome reporting, and rumor has it that Yehuda Katz is working on an entire speed-test suite.
Update
Please be aware that these optimizations are not necessarily helpful as of jQuery 1.3 because of the new “Sizzle” selector engine.
A handy tip for those who are interested in speeding up their jQuery code. It may seem obvious, but I've had a conversation about this in the last couple of days, so thought it would be handy to post!
An open letter to Harvester Restaurants
To Whom It May Concern.
I visited your Harvester in Fareham last night as a family gathering to celebrate my girlfriend's birthday, and frankly, it was probably the worst meal of my life, after a catalogue of issues from the moment we arrived. I shall list each point for you so you can see just how badly your Fareham branch is run.1) When we arrived, we were greeted by a barman who was surly at best. There was no "good evening, what can I get you", and when I want to pay by card, he just said "I havent got a card reader" in a merable surly fashion, and walked off, then returned and just held the reader out for me to use. Maybe, as a front of house member of staff, he should be a little more polite and maybe even try to engage customers as they arrive.2) When we got to our table, despite the staff seeing we had two children with us, we had to wait nearly over 10 minutes for a child's menu3) When I went to the salad bar, there were no white rolls, no potatoe salad left, no pasta salad left, and the coleslaw was made with lettuce!! The lettuce all looked dry and tired, the peppers looked slimy and frankly, I was unwilling to eat any of it. 4) When our order eventually arrived, the waitress didnt clear away all the used salad bowls and side plates, which we had stacked at the end of the table when we finished them.5) None of the plates of food had any sort of garnish, just a plate of tired, brown looking food. My chips were cold, and the extra prawns my girlfirend ordered to accompany her fillet steak looked revolting, pale and dry, and to add insult to injury they were cold. I asked the waitress to get me some hot chips and sent the prawns back too, but when she returned, the prawns still looked inedble and my chips were still not hot!6) Not wanting to spoil my girlfriends meal, I decided not to cause a scene or complain until the end of the meal, but when the waitress returned with our drinks order, she then spilt a drink on my meal, and then laughed!!! Maybe if the bowls from the salads had been cleared, she would have had room to put the drinks down safely. At this point, I had to go outside and have a cigarette as I was so angry at the complete ineptitude of your entire operation and how it was spoiling my girlfriends evening out.7) At this point I complained to one of the waiting staff, who said she had told the manager about the situation, and the managers response to her was "Leave them til they have finished their meal". Surely, a better approach would be to come over and see if she could help sort things out and ensure our evening wasnt completely ruined. No such luck.8) Finally, when the manager did eventually come over and speak with us, she just said "I understand you havent had a very good meal". I then outlined the catalog of failure to here, and she didnt even say sorry. She just said ok, we will only charge for the drinks. Then she left us. She didnt return to the table, but instead left a waitress to deal with us. As a "manager" maybe she should have made a bit more effort, but frankly, after everything else I witnessed last night, I'm not really that surprised.9) The final insult came when my girlfriend visited the toilet before leaving, which was dirty, and had no toliet paper!So. Thanks for a FANTASTIC evening. It was definately a "A Night to Remember". I will NEVER step foot in one of your establishments ever again, and I will make it a point to make sure that anyone I know does'nt have to go through the same experience.Your service is appalling. Your food is disgusting. Your standards are so low I'm not even sure you have any. Unimpressed.Sunday, June 06, 2010
A Geeky Guitarist Post...
Well, I've just had a week off work, the majority of which was spent sat in the sunshine playing my guitar - A refreshing change from sitting in front of my laptop for hours on end! Anyway, since picking my guitar back up a couple of months ago, I've discovered some web sites and iPhone apps that are really useful to all guitarists, of any skill level, and I thought I'd take time out to share them...
Useful Sites
I've found it really helpful to sit down in front of my PC with my guitar and learn from online tabs and video lessons, so here's my list of some of the best guitar sites...
- Ultimate Guitar - I suspect most guitarists already know this one, so forgive me for stating the obvious, but this site definately needs mentioning. Great content, including reviews of guitars, hardware, bands and more, a huge repository of song tabs and chords, interviews, lessons and much more. This should be your first stop!
- Free Guitar Videos - I really like this site. A huge amount of video based lessons in all styles, with well produced videos. A good one to site in front of your PC with your guitar and actually have "virtual lessons". This is a site that has really helped me get back up to speed since picking my guitar up after not playing for a few years!
- JGuitar - Although it's design looks very dated, JGuitar has a few handy features, including a Chord Calculator that automatically determines every mathematically possible fingering for a chord based on the options you specify, handy for sussing out alternative fingerings, a Tab Mapper, that takes a tab URL and generates chord structures, and a Chord Search function. It's well worth exploring.
- Justin Guitar - If you want to learn how to play well known tracks, or you're interested in getting to grips with some music theory, Justin Sandercoe's site is brilliant. Justin Sandercoe is a London based guitarist, songwriter, performer, producer and educato, and his video lessons on YouTube have had over 60 million views! I've spent quiet a bit of time on this site, and my playing has definately improved! Even if you spend just 10 minutes on Justin Guitar, you will see how much much time, effort and enthusiasm Justin has spent on making his site a brilliant guitarists resource.
- Guitarists.net - Another site with great content, although the design and layout is a bit dated. It features quite a few good lessons, for beginners and also for more advanced players, covering music theory, scales, licks, tricks and more. There is also an interesting directory of music/guitar related software. Check it out!
- Chops from Hell - This is one for my colleague Tristan! A proper "RAWK" site with cheesy design, but this site has some lessons and videos for the "shredder" guitarist. Definately not for beginners, but worth checking out if you want to see some guys who can really play "metal" lead guitar. While I'm not really into some of the heavier rock music, I really admire people who can "shred".
- Guitar Player - Another really good resource, from the magazine Guitar Player. Lots of great content, including video lessons from some amazing musicians (Check out Joe Bonamassa's blues videos). This site has also has some interesting "non-lesson" articles - Have a read of "
- Guitar Player World - This site has a few good lessons, covering beginners and some more advanced stuff, along with articles and lessons about playing different styles. A lot of the lessons are more text/theory based, rather than video or tabs, but still worth reading!
- YouTube - Although not a dedicated guitarist's site, there are literally thousands of video guitar lessons available on YouTube. Some are definately better than others, but a few users worth checking out include RockOnGoodPeople, BerkleeMusic, GuitarJamzDotCom and LickLibrary
- ChordBook - This one's a bit different, as it is Flash based, with an interactive section allows you to choose guitar type (electric or acoustic) and find any chord and hear them played on the virtual guitar. You can also create your own chords and save them for later use. Chord book also has a Flash based interactive Scales tool to help you learn your scales!
iPhone Apps
As well as using my PC to improve my guitar skill, I've also discovered "there's an app for that" when it comes to the iPhone too! Here's the list of guitar related apps I have on my iPhone...
- Guitar Toolkit - This is one of my favourites. A really well put together app, with a tuner for most popular tunings and suitable for 6 and 12 string guitars, bass, banjo, mandolin and ukelele, a metronome, complete with tap pad to set your own timing, and chord and scale libraries. A must buy, and a definate bargain at £5.99.
- Ultimate Guitar Tabs - Another app that I have used almost daily since getting back into guitar. It uses Ultimate Guitar's huge database of tabs and chords, allowingyou to search for any song you want to learn to play, with both tabs and chords. Most songs have multiple versions, rated by other users so you can easily see which is the best or most accurate version to learn. This one would be good on the iPad, as tab and chords tend to need a decent screen area so you can read and play, but still handy on the iPhone.
- Guitar: Play and Share - This one is just amazing. there are quiet a few "iphoine guitar" apps, that allow you to "play" chords and scales, but to be honest, none of them work that well, as the iphone is'nt really anything like a guitar! Guitar: Play and Share gets around this by simply providing buttons for chords (over 1900 in the library, and you can define your own) , then you simply hit the strings you want to play. A simple, but ingenious solution, and it's a fantastic tool for creating your own progressions and songs, even without your guitar. If you ever find yourself having an idea, but you don't have a guitar to hand, this is a must have.
- Fretboard - FretBoard holds a collection of more than 140 instrument tunings in 15 instrument groups and a huge amount of music theory packed in a simple and intuitive interface guaranteeing fast access and easy understanding, and helps visualize chords and scales.
- ChordMaster - A very handy chord library, from D'Addario. With more than 7800 chords and variations, with the ability to strum and hear individual notes in each chord. Very handy indeed!
I'm sure there are more iPhone apps out there, but that's the list of apps I've installed and use regularly. I hope those of you who play guitar finds something handy, in the meantime, I'm off to sit in the garden and practice!