Posts

Showing posts from 2013

Get a list of your functions in mysql

If you want a list of functions (as opposed to procedures) use this: select *  from information_schema.routines  where routine_schema = 'your_schema_name'  and routine_type != 'PROCEDURE'

Douglas Crockford Video 5 - 'The end of all things'

No let up in quality in this video. Here are my notes for the final video in the original series: Cross site scripting (XSS) is a big problem. Huge privs accorded to a successful attacker. Caja and adsafe - make js safer. Don't confuse a variable and a value. How does an object get a reference: By Creation By Construction By Reference David Parnas: http://www.cs.umd.edu/class/spring2003/cmsc838p/Design/criteria.pdf Lazy programmers guide http://www.youtube.com/watch?v=eL5o4PFuxTY Keep performance delays below 100ms - provide some sort of immediate feedback. Don’t fiddle with code. Measure first. Use PageSpeed Arrays can be slow in older versions of ie. No hashmaps. Don’t add unnecessary chrome. Takes time. Don’t tune for quirks. Keep code clean and readable. Future versions of JS engines will be much faster. Your quirk optimisations may cause trouble. jslint.com Avoid global variables. Avoid ++ - too easy to mess up Use jsl

Douglas Crockford's JavaScript Video 4 - AJAX

These videos are remarkable in the packed world of IT training videos in that they are clear and enjoyable to watch. The fourth instalment is about Ajax, but goes into plenty of detail that I didn't know about where the DOM came from and some info about the famous browser wars. Here are my notes so that you can see what is in there before you invest 90 minutes. Markup languages RUNOFF GML - generalized markup language SGML HTML - simplified SGML Latex Angle brackets came from Scribe . HTML Does not fail on errors - allowed innovation. Otherwise the web would have frozen. 2 types of outlines - H1 - not nested and p type which are. Yuk. CSS Not modular - clashes can wreck your page. difficult to manage selectors - classitis and iditis. None of the browser vendors ever got it implemented! The DOM Brendan Eich - Netscape Browser workflow url -> Fetch -> cache  -> Parse -> Tree ->  Flow -> display list ->  Paint -> pixels Comments a

Douglas Crockford's JavaScript Videos from his time at Yahoo

He has now moved on to other things, but these videos are still around. They are like reading a novel - long form is still best. No sound bites here. Each video is over an hour long and there are 8 of them. I am only on the third at the moment, but am getting a huge amount out of them. If you are like most js developers and me you will be bludgeoning your way through whatever tasks you need to complete without knowing the details. JQuery et al insulate us from having to know this stuff right? Afraid not. There is no substitute for knowing the javascript in detail. These videos manage to do that.

Useful CSS Wisdom

I came across this in the most recent Web Design Weekly. I have called it wisdom as it is full of the type of advice that people only have the balls to give you when they really know what they are talking about. Why IDs in CSS should be avoided is detailed. A lot of people rant about this, but there is something about this document that got me sifting through my CSS to find all the # marks. The document is short and I am going to look back at it a few times over the coming months to make sure I have squeezed the benefit out of it.

Web Design Weekly

Web Design Weekly is a great resource for front end developers and wannabes. Once you subscribe it arrives in your inbox once a week with a selection of articles, news, tools etc. that you can use in your work. It is just like subscribing to RSS but I find that getting news on a specific area like this once a week means that I set aside some time to at least browse it and find out what is interesting. The material is often of a high quality and where I don't manage to get stuff working it's probably down to me not persisting with it long enough. If this is the type of work that you do I recommend signing up for this. The link is at the start of this post.

Mozilla Developer Network JavaScript Resources

When I am looking for anything to do with js, html or css on the web I tend to put the letters mdn into the search line along with whatever else I am looking for. This usually pushes me to the pages on the Mozilla Developer Network. They are consistently of high quality - unlike for example W3Schools  and are clearly written by the type of people who possess the knowledge that I want. Mostly it is just a dip in to find our a syntax here and there, but they do offer comprehensive book style start to finish information. The JavaScript Guide for example is here . I have been programming in JavaScript for quite a while now, so I am not reading this line for line, but a scan through it is clearing up some long held confusions for me. I reckon getting proper skills into your head and hands is a slow process and the way there is to persist and add new pieces every day. Going through the MDN docs is an example of this.

Book about Design Patterns in JavaScript

This book by Addy Osmani goes into depth about the various design patterns that you can use in your JavaScript. The main advantage that I am getting out of it is going through the examples and reading the references to see how to do 'complex' JavaScript. Singletons always come in handy in Java, now I can do them in JS. A host of other patterns are covered. I will be taking the time to go through this book in more detail over the coming weeks.

Some Resources to Help You Get Started With Grunt.js

I have been a bit worried about deploying cleartext javascript to my production environment for a while now. The hassle of obfuscating always put me off: Use something like Google's closure service Change all of the references in my html to point to the generated files Make sure the clear text dev versions of the js are not deployed and finally  Do the deploy Grunt.js looks like it might be my saviour here. Having come from (and still being in) the Java world I think of this as being Ant for javascript. Just what I was after. I am just doing a bit each day so as not to interfere too much with the day job, but so far I have added these tasks (in development at least, I am not doing anything with grunt on live code yet): Remove white space from js files with uglify Compress javascript to gzip Run my existing QUnit tests Lint my javascript Although it is early days this looks like having the scope to make everything a bit easier. Here are some resources I have used o

Feature removal from mysql following Oracle takeover?

I am using MySql 5.5.20 (select @@version). There does not appear to be any difference between explain and explain extended in this version. See here for the expected output from extended. I don't know if this is a feature removal that happened after Oracle took over. They seem to be pushing people to buy the enterprise tools. Not an option for some (me included) as I am using Google's Cloud SQL service. I don't think it allows this type of monitoring and even if it did it is unlikely that I have access to the knobs to turn to make good on its recommendations. My experience of enterprise monitoring is limited as I mainly do dev, not admin. I am usually not around when the dust settles and people start to worry about stuff like monitoring. I was at a mysql talk given my Oracle last year in Dublin. It was an impressive morning spent explaining the things they had improved in mysql since the purchase. They did not mention removing any handy admin features which might pus

Falling off a performance cliff with group_concat in Google Cloud SQL

I started to write this article as the performance of some of my mysql queries had gone off a cliff. This was related to my use of the GROUP_CONCAT function. This rolls up a set result set and shows the passed in row values concatenated. Handy for reporting, but not much else. In the highly memory constrained world of Google Cloud SQL using this on a well indexed set of tables (albeit it with multiple left outer joins in place) pushed a regularly executed query for a few hundred milliseconds to 6 to 9 seconds. Disaster. I pulled the db over to my dev machine (copy of prod) and ran the query there. No problem. I am concluding that the GROUP_CONCAT was the bad guy here. I found another way to achieve my goal, but this cost me an afternoon and a lot of fretting before I got out of the woods. MySql is not bad, but occasionally it bites.

Good Video on Creating Large JavaScript applications

My JavaScript application started out small, but is now getting very big. The main js file is about 3k lines long. Performance is still very good, but I am getting concerned about maintainability. I had been stumbling around in the alphabet soup of javascript tools and libraries for a while and was looking for somethign which would make sense of this. I found Addy Osmani's video on structuring large JavaScript applications very good. I have just watched the first part (23 mins) so far, but it is pitched at my level, so looking forward to the next ones. The video is here: http://addyosmani.com/scalable-javascript-videos/ Addy's slides are here: https://speakerdeck.com/addyosmani/large-scale-javascript-application-architecture He mentions at one point that he is writing a book on backbone.js development. Here is a link to the book https://github.com/addyosmani/backbone-fundamentals Its free at this link, but you have to build. I will give this a go at some point. You ca

Good Design Learning Resource

I signed up for HackDesign about a week ago and they sent me an email with some links in. It took a bit of time to get through it all, but it was worth it. I am always learning new bits of stuff - CSS, Java, SQL you name it, but am rarely satisfied that I am following the right 'path'. Not being thorough enough. Resources like HackDesign are the solution to this I reckon. Nice and deep view of a subject - design in this case. There is enough scope for you to click plenty of links and generally learn by doing something other than just reading. These Yahoo design patterns for the web were a useful find. I found them through one of the links in one of the articles. And this is only week one. Now to find similarly deep resources on the other things that I am learning.

Structure in Android App Design - Google IO Video notes

If you are an Android developer, this is well worth a watch. It is from this year's Google IO. Below are some of my notes from watching it. Importantly it introduces the Navigation Drawer (to me at least). I had seen this in a lot of places (Irish Times app for example) and liked the look of it, but was worried about having to pick a library to rely on for this functionality. So the Nav Drawer is now in the support library which makes it usable in most apps.  I'll be taking a look at PhysioTrack over the next few weeks to see how I can enhance its structure by using some of the learnings from this talk.  My Notes: This is an example of a use case that was used in the talk Find a Bar Primary Actor: Drinker Precondition: BarKeeper installed Primary Scenario: 1 Users launches app 2 Indicates that they want to find a bar 3 App presents a list of choices 4 User selects a bar and is shown the choices Steps to take to produce your use cases: Take

Google Cloud SQL - Backup prod and restore on dev instance

To test your code in cloud sql you need a realistic data load. The best way to get this is the backup and restore your production database. Note that you need to make sure you anonymize the data sufficiently immediately after the restore to protect your customers identities. Go to google api console. https://code.google.com/apis/console/ you need to be logged in to your google account for this. Find the name of the storage bucket in cloud storage or create a new one. Go back into Cloud sql console and export data. Give the name of the file as date-prod: june-17-2013-prod Back up will take a while. Once it is completed download the file to your local machine. Decompress it, its in gzip format. This outputs both the mysql db and the required prod db. Use the following shell commands (bash) to get rid of the mysql stuff: grep -in ‘create database’ your_file_name The output gives you the line numbers of the creates (that's what the n is for, the i ig

Upgrading your Appengine SDK in eclipse

I get those warnings in the eclipse console every month or so. I normally put off the in stall until I am left with no choice. This is not healthy of course. Better to document the procedure here and not be afraid! The SDK Download latest SDK from here: https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_Java Extract it somewhere (I created a dir within eclipse for this) : \eclipse\appengine_downloads Add the sdk in eclipse. Change the SDK version in your project and overall in eclipse. Database Driver Check for more recent connector j here: http://dev.mysql.com/downloads/connector/j/ Place it here: \eclipse\appengine_downloads\appengine-java-sdk-1.8.1\lib\impl\mysql-connector-java-5.1.25-bin.jar

Unit testing JavaScript

I am well used to writing unit tests for java code (although most project managers don't really go for it), but had not come across something decent to do this for JavaScript. QUnit appears to be just the job. I don't think it is just me, but I seem to write pretty badly structured js. Coming from java this architectural stuff is mostly forced on you, but not in js. However once you start to write unit tests for your code you start to think about laying this all out better. I read through the intro. Then I read this simplified getting started. And then I wrote some tests for my own code. Altogether this took me just over an hour. A worthwhile investment. This was of course the point where I realised that my code was not particularly testable. Ah well, I will refactor it from now on with this purpose in mind. Next off I am going to go through the cookbook  as it seems to address some of the issues that I want cleared up before I commit fully to this - things like manipulat

Code Academy

There are a bunch of new online learning tools becoming available at the moment. Some are based around the idea of a university style education (http://www.udacity.com/ and http://en.wikipedia.org/wiki/MIT_OpenCourseWare for example), others have a more hands one goal of teaching you how to program. One of the nice programming ones is Code Academy . They have a short list of courses based around programming. They cover areas like JavaScript and JQuery. They have a nice online editor where you carry out the practice questions. There is a clever engine behind this which allows you to get the answer right in a number of ways - it is not just making sure you did exactly as instructed. Useful messages when you go wrong and the whole thing is gamified   To make the rat brain in us all happy :) Well worth a try if this is you thing - or if you would like it to be.