I have only had my HTC desire for over 1 month and managed to full my SD card. (I previously have also run out of onboard memory for apps - but that issue should be resolved by the Froyo release of android - where I will be able to store applications on the SD card).

The full SD card problem - is different in that I know I have K9 mail installed and loads of other apps. I also thought the problem might have been caused by accidentally recording a very long video. I spent a lot of time looking for a app in the market place - but had no luck. Eventually I attached the phone to my macbook (using the USB cable) and pointed Jdisk report to my /Volumes/No Name on my mac to get a pie chart of my SD cards disk usage. It was doggcatcher (a podcast downloader) that is using all the disk space.

insane complexity in finding the black and white option - does apple get a kickback from HP on the number of color print cartridges used!?

I spent an hour messing around trying to get HP device manager to communicate with my HP C4380 all in one printer/scanner

It was working before I upgraded to Snow Leopard - I found several articles stating that you can just download the latest drivers and recreate the printer - this did not work for me. turns out the easiest is to not use the HP device manager - and simply use the 'scanner' tab when you list the printers details in apple->system preferences->printers->c4380 tab

( "photo by Jeff Kubina")

London startup - I think these guys are will do well - great for navigating orgcharts and finding 'stakeholders' and experts

Their website

crunchbase data ...

a video

(photo credit to flickr:louisvolant)

Just spent the last 2 days solid playing with my new HTC desire from 3

I was previously on 02 for 10 years but their network is overloaded due to the number of iphones on their network (this is largely due to the now expired iphone-02 exclusive deal in UK).

I must have installed over 50 apps - I still don't have 'skype lite for 3' working - its doesnt support the HTC Desire yet - will wait a few weeks and give it another go.

Due to issues with battery life I have ordered one one these portapow usb battery extenders that is rechargeable - will have to write a review on it once I have tried it out.

I have also ordered a Epik HTC Desire protector case for the phone from Hong Kong as a lot of the cases are available are actually for the Google Nexus One - like the FlexiShield do not fit correctly. Over 50% of the phone cases seem to be sock-style or folder-style - which doesnt seem like a good idea. How are are supposed to be able to answer the phone quickly? Anyway will have to wait and see if its a good choice

view from plane

These are some of the tips I have come up with when I fly longhall:

  • for longhall flights prebook seats away from toilet doors - either on isle or window
  • check-in as early as possible
  • pack one set wax earplugs
  • one set sleeping pills
  • wear lightweight trousers - no jeans as its hard to sleep in them
  • take one hardcover notebook - I use this if I get someone whos arms go over the armrest onto my side - you can end up with someone elbowing you in the ribs the entire flight - I place the book on my side of the seat between myself and armrest as a guard from their elbow
  • remove any magazines in front of you - this can give you another 1cm+ of leg space

Flickr has built in photo printing - but they charge 9p per print. http://www.photobox.co.uk charge only 5p per print. I used the flickr organiser to create a new flickr set called 'to print', then logged into photobox, chose 'from flickr' and the 'sets' tab' and then simply pressed the 'add all' link. [at the end of the photobox checkout process I discovered that 5p per print is actually a lie - its 9p per print with photobox - you may as well use the built in flickr photo printing]

I want to keep facebook as my default photo store - and just push some photos to facebook. This bookmarklet works very well for that purpose.


Photo by Scragz

  • use bind variables
  • restrict the rights of your web apps database user - no more rights than necessary (ie. no drop/create)
  • in production mode, when a sql error occurs, only show a message such as "an error occured" - not the full sql that was executed
In this podcast 'Joel Spolsky' makes the point that the title 'Software Architect' shouldn't really exist and that designing high level software interaction is just part of a good developers job.

  • ...are unsure that the title "Software Architect" is a good one. We're leaning towards it being almost.. a net negative. "It's almost disrespectful of the actual architects who work in construction, to use that word to refer to some kind of high-falutin' big-picture UML-drawing code monkey."
  • To the extent that the architect is not in the trenches with you doing the work, they don't have enough context, and will inevitably make the wrong decisions.
  • If we had the power, we'd do away with the title "Architect". But if you're stuck with it -- and the architecture astronomy that it frequently engenders --  what is the proper role for a so-called Architect? They could work to connect disparate groups at large organizations, to provide context and reduce duplication for disparate groups that are working in isolation. It can be hard for groups working locally to see the context of the larger organization. But I traditionally think of this role as an evangelist and educator, not an architect.

I think its good to question - Joel has his own small business - so he probably doesnt get any exposure to the change management and political war-ing of large orgs - which I think the title 'architect' helps with in order to get a product adopted by the org.

For a specific software product - I think the only way you can work on architecting some software is if you are involved working at the coal face (to gain respect of the developers and understanding of the problems) or at an extremely high level with some kind of enterprise architecture blocks for 'out of the box' products like SAP.

This Puppet vs Chef article is a great example of a how a well seo-ed blog can affect the opinions of many. If you look at the initial article in a quick 'skim read' to choose a technology - you would conclude that Puppet is the best option. However there are plenty of comments below the article specifying why the article is FUD.  I have come across this before when reading about cassandra - I later discovered from an expert inside Yahoo! that a lot of the information was incorrect.

installing Chef on ubuntu - I will be interested to see if its better than Yahoo's internal tools for configuration management.

I can really sympathise with this graphic designer - the media industry is full of people asking freelancers for things as cheap as possible.
Promising things like 'do this one cheap and there will be lots of future work' - which either doesn't materialise or is also at the same price.
I think it may also be linked to the recession - lots of people getting connections to do things for free as a favour because we don't have any money at the moment. I know of a SEO, who eventually had to refuse providing advice to anyone as he was over run with favours to people.

The growth of websites like elance.com also means a freelancer in London has to compete with - for example someone in a remote country, working from home, paying no tax. The cost of living in London means - that its basically impossible to sustain yourself on small projects. Each project has a unpaid lead time - in which you are collecting requirements and providing a estimate. Often small projects come with unpaid post project support. Getting requirements out of non-technical clients is a scary process where you discover whey didn't really know what they needed. Often you may find yourself helping them with their requirements, only to discover you are just telling them to use a specific tool or webservice. Thats all cool - but living in London you can burn through cash making you feel like you are in 'free fall'

I guess its time to refresh my sql - moving into finance means I could be running a lot of adhoc sql queries.

I am convinced I have used correlated subqueries before but had never heard of the term.
A correlated subquery is a query where the subquery uses values from the outer queries where clause.


SELECT empnum, name
FROM employee AS e1
WHERE salary > (SELECT avg(salary)
FROM employee
WHERE department = e1.department);

e1.department joins with the where cause of the other query.

This causes the query engine to execute the inner query for each match on the outer 'where' cause
This could produce some very inefficient queries. I guess as a programmer you can think of it as a 'for loop' - as in get all the data matching the where cause, loop though each row and perform another query.


mysql> select * from employee;
+------+-------+--------+---------------+
| id | name | salary | department_id |
+------+-------+--------+---------------+
| 2 | paul | 101 | 1 |
| 1 | bob | 100 | 1 |
| 3 | randy | 300 | 2 |
| 4 | sally | 305 | 2 |
+------+-------+--------+---------------+
4 rows in set (0.00 sec)


mysql> SELECT avg(salary) FROM employee
-> ;
+-------------+
| avg(salary) |
+-------------+
| 201.5000 |
+-------------+
1 row in set (0.06 sec)


mysql> SELECT id, name FROM employee AS e1 WHERE salary > (SELECT avg(salary) FROM employee WHERE department_id = e1.department_id);
+------+-------+
| id | name |
+------+-------+
| 2 | paul |
| 4 | sally |
+------+-------+
2 rows in set (0.00 sec)

The above query gives employees who have above average salary.

It much more effient to create a in memory table called a derived table called sal_ave using the syntax 'AS':

mysql> select name from employee e, (SELECT department_id, avg(salary) salary FROM employee group by department_id) AS sal_ave where e.salary > sal_ave.salary and e.department_id = sal_ave.department_id ;
+-------+
| name |
+-------+
| paul |
| sally |
+-------+
2 rows in set (0.00 sec)

Another common question in interviews is what is the difference between a WHERE and a HAVING cause

"HAVING specifies a search condition for a group or an aggregate function used in SELECT statement.

HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP BY is not used, HAVING behaves like a WHERE clause.

A HAVING clause is like a WHERE clause, but applies only to groups as a whole, whereas the WHERE clause applies to individual rows. A query can contain both a WHERE clause and a HAVING clause.

The optimizer always automatically analyzes each statement you enter and selects an efficient means of executing it. In general, that means eliminating undesired rows in earlier clauses."

The problem with the flare prefuse library is that flare is a commonly used word - so searching for examples on google results in a lot of matches other uses of the word flare. A simple solution is to use site explorer to find links to the flare prefuse website - this naturally disambiguates the meaning.

I found this link confirming to that flare is the best tool to be using  for now

"Yes, but how heavy is Axiis? Have you pushed the limits? I used Ravis Birdeye for our initial efforts for my network mapping app http://www.flairjax.com/?p=72, but the mxml components are way to heavy. Had to go to flare."

  I found this  classification of different types of visualisations

  • data visualisation - numbers in a graph, pie chart, barchart, scatterplot (quantitative data)
  • information visualisation - interactive visual reprentation of information in order to improve cognition
  • concept visualisation - mindmaps and other representations of concepts (qualitative data)
  • strategy visualisation - company strategy - (I dont understand how this in a classification similar to the others listed here)
  • metaphor visualisation - use a metaphores such as tree or landmass to represent something completely different
  • compound visualisation - something that uses a fixture of the above techniques

I think a better classification of a visualisation would be

  1. Is the visualisation user interactive?
  2. Does it represent a moment in time or a change over time  (does it have a time dimension)
  3. Does it contain quantitative data (numbers)
  4. Does it contain qualitative data (opinions of concepts - based on subjective or intangible ideas such as "warmth" or "friendly")
  5. Number of physical dimensions - 1D, 2D, 3D
  6. What visual que's  are used to represent information - color, line patterns, fill area, animation

more to be added to this classification list over time

I decided to clean up the first animation that I had learned from the actionscript animation book. It can also be viewed here.

In the process I made some mistakes and learned a few things:

  1. I extended the object model to be more a mathematical graph based model - with Nodes and Edges - and I tried to abstract out the concept of forces
  2. I made the mistake of trying to iterate over the springs instead of the nodes - this makes life more complex as the forces are applied to nodes - it meant that I was accidentally applying gravity to the node once per spring attached to the node - conclusion: you most iterate over the nodes and then for each node - each force applied to that node
  3. I made the mistake of trying to apply all calculations and rewdrawing the spring lines in the same loop. This does not work because particles later on in the calculation loop will change position. Conclusion is that you need to calculate all of the nodes new positions before having a separate loop with redraws the spring lines
  4. I created the concept of MoorPoint nodes - nodes which do not move in response to forces - only the user's mouse drag and drop actions

The code can be downloaded from here.

After doing all this work - I found that the system was unstable - in terms of a small change in spring value or gravity could result in the nodes disappearing off stage. You can add damping or change the values but I decided to look at some libraries. I downloaded this as3 visualisation library - which is fantastic. They have done a great job of creating a great object orientated model that can be applied. For example they

  • have nodes and edges
  • have separated out the spring, attraction and gravitational forces into implementation of an iforce interface
  • the forces are applied to particles - ie. not to nodes - so the concepts of particle forces and a node-edge graph are kept separate
  • they have rapid node and edge iterators
  • they have the concepts of a fix() attribute that prevents the node from moving when subjected to forces - similar to a MoorPoint
  • node and edge meta data is catered for

Anyone who is working with graphs (node - edges) in no matter what language should look at the flare visualisation library

web graphCame across Barrett Lyon and the opte project - seems kind of interesting

especially the techniques of creating large graphs of the webs connectivity

"Lyon's work tracking Russian Denial of service attack extortion groups has been featured around the globe[4]. He provided details and helped coordinate with multinational law enforcement groups which resulted in the capture of Ivan Maksakov, Alexander Petrov, and Denis Stepanov [5]. The three men were at the heart of an extortion ring which was extorting money from banks, Internet casinos, and other web based businesses. Reported damages caused by Maksakov, Petrov, and Stenanov range in the the tens of millions of dollars. On October 8th 2007, Maksakov, Petrov, Stenanov were found guilty and sentenced to eight years in prison in the Russian Federation with a 100,000 ruble penalty[6]."

  Whist creating my first animation - I was trying to place vertical label text on the sliders. The text was not appearing - there are numerous forumn posts on this subject. This was because I was not using embedded fonts  I managed to get embedded fonts working as follows

[Embed(systemFont='Arial', fontName='spArial', mimeType='application/x-font')]
public static var ArialFont:Class;


var textField: TextField = new TextField();
textField.text = "hello";
textField.selectable = false;
textField.autoSize = TextFieldAutoSize.LEFT;
textField.setTextFormat(new TextFormat("spArial", 12, 0));
textField.embedFonts = true;
square.addChild(textField);

The problem with embedding fonts is that they increase the size of the swf by 100k which is a lot when the origional file was 8k. The following technique renders the text as a bitmap and this can then be rotated:


tmpTextField.selectable = false;
tmpTextField.autoSize = TextFieldAutoSize.LEFT;
tmpTextField.text = _label;
tmpTextField.background = false;


// http://www.actionscript.org/forums/showthread.php3?t=150918
var myBitmapData:BitmapData = new BitmapData(80, 20, true, 0x00000000);


myBitmapData.draw(tmpTextField);
_labelBitmapField = new Bitmap(myBitmapData);


_labelBitmapField.smoothing = true;
_labelBitmapField.rotation = -90;
_labelBitmapField.x = 0;
_labelBitmapField.y = _height;
addChild(_labelBitmapField);

  You can try out my with my first animation here

Several months ago I bought Actionscript 3.0 Animation - Over Christmas I have had some time to play with some ideas. I am interested in visualisation tools - especially things that help technical people understand better what is happening in a complex environment. eg. visualisation of code execution or visualisation of business strategy.

Firstly some key summary points of what I learned from the book:

Sprites are the base class for all interactive elements on the visible screen which is called a Stage. (Actually all interactive elements are derived from DisplayObjectContainer but for the purposes of these animations we work mainly with sprites). The addChild(aSprite) method is what makes the sprite visible on the Stage. You can use removeChild(aSprite) to remove it from the stage. The sprite is not destroyed - just hiding in the wings and not visible to the user. Adding the sprite back onto the stage is a process known as reparenting.

The aSprite.graphics. draw api allow you draw lines and circles associated with that Sprite.

Changing the value of aSprite.rotation property causes the sprite to rotate that value in degrees. All lines drawn by the draw api associated with aSprite will rotate with it automatically.


aSprite.x
aSprite.y

properties values change the sprite position on the stage.

mouse events occur when you are over a sprite but are always available to the stage. ie. if you move over a ball spite and you can have listeners on the stage and the ball, both receiving events


stage.focus = aSprite;

allows you to capture keyboard events on a sprite instead of only on the stage

aSprite.mouseX aSprite.mouseY values are relative to the position of the sprite on the stage.

My first question is : Given that each sprite created has overhead, when do you create something as a seperate sprite?

I think the answer is:

  • When you want to be able to capture events associated with it seperately - for example the handle of a interactive slider is created as sprite
  • When you want to be able to move the object seperately - by simply changing the .x and .y properties
  • When you you want to be able to rotate the object and have all graphics associated with the sprite rotate autmatically
  • When you want to be able to show ( addChild() ) or remove the object (removeChild()) from the stage seperately

so a tree could be

  • single tree sprite
  • part of a forest sprite
  • could have branches as sprites

all depending on what you want to happen in the animation.

Flash's coordinate system is a little messed up - they have x,y position 0,0 in the top left corner and angles (such as aSprite.rotation) run counteclockwise.

to find the angle between to points you can simply use


dx = mouseX - sprite.x;
dy = mouseY - sprite.y;
angleInRadians = Math.atan2( dy, dx );
sprite.rotation = angleInRadians * 180 / Math.PI;

Note: All of the trig functions expect and return radians but sprite.rotation requires 'angle in degrees'.

you can always get the distance between two points using pythagoras theorem

dx = x2 - x1;
dy = y2 - y1;
distance = Math.sqrt( (dx*dx) + (dy*dy) );

Side Note: Adding and removing event listeners in flash is lightweight - so its normal practice to call removeEventListener() when you are in a state where you want to ignore events - rather than have a ignoreEventX flag

In order to perform animation - we may have a set of event listeners for keyboard and mouse events and most importantly:


addEventListener( Event.ENTER_FRAME, onEnterFrame );

listener which is called at the framerate of the flashplayer

inside the onEnterFrame() method - the following code often seems to appear:

  • for each seperate sprite on the stage,
  • take each of the physical forces that are being applied to that sprite broken down as x and y components (use cos and sin to do this)
  • sum these forces and calculate the sprites new position
  • check if the sprite has now gone beyond the stage boundaries
  • for each sprite that has not been already checked - check for a collision
  • if a collision has occured apply interaction logic - could be collision mechanics or attaching the two sprites.

to convert any angle and force magnitude into its x and y components use


vx = Math.cos(angleInRadians) * speedInPixelsPerFrame;
vy = Math.sin( angleInRadians ) * speedInPixelsPerFrame;

We have to run a lot of calculations for each sprite on each frame - so it is common to simply cache the values of xy and vy and work with these directly. Also because it is simply about creating a realistic simulation and speed is actually in pixels per frame - constants like gravity force of G = 9.82 m/s2are simply not used - the developer experiments with the variable constants until a realistic animation is created.

Forces are simply "rate of change of velocity" - so an accelerating spaceship might be modeled as


vx += ax;
vy += ay;

ie. on each onEnterFrame() call - the x and y velocity vectors increase by a value of ax and ay. On the same onEnterFrame() call, the new position of the sprite is then calculated as

sprite.x += vx;
sprite.y += vy;

Gravity on earth is a constant - the distance component is ignored as the mass of the particle vs mass of earth are significantly different - hence we have a y acceleration of:


vy += gravityConstantValueChosenByDeveloper;

Friction force increases the faster something is moving so we use * in the formula:


vx *= frictionValueChosenByDeveloper;
vy *= frictionValueChosenByDeveloper;

Easing occurs when a something moves slower as it gets closer to its target - eg. a person runs up to a wall - The formula therefore calculates the distance between sprite and target


vx = (targetX - sprite.x) * easingValueChosenByDeveloper;
vy = (targetY - sprite.y) * easingValueChosenByDeveloper;

A spring pulls harder the further apart the sprite and the target are. ie. the formula incorporates the distance between the sprite and he target


ax = (targetX - sprite.x) * springStrength;
ay = (targetY - sprite.y) * springStrength;

Offsetting a target: When working with springs or easing its important to be able to calculate the actual target x y cooridates as they may not be the center of the sprite - for example: they could be the nose of the spaceship or end of a bat. In order to do this we use one of our standard trig formulae:


dx = sprite.x - knownX;
dy = sprite.y - knownY;
angleInRadians = Math.atan2( dy, dx );
actualTargetX = knownX + Math.cos( angleInRadians ) * distanceInAStraightLine;
actualTargetY = knownY + Math.cos( angleInRadians ) * distanceInAStraightLine;

Collision detection

basically you have decide if you want to use:

  • flash's built in hit sprite1.hitTestObject( sprite2) - which assumes that the objects are rectangles
  • a distance based collision detection calculation - which favours circular objects

The distance based collision detection calculation formula is simple


dx = sprite2.x - sprite1.x;
dy = sprite2.y - sprite1.y;
dist = Math.sqrt( dx*dx + dy*dy ); // pythagoras theorem
if ( dist > (sprite2.radius + sprite1.radius) ){
trace( "hit");
}

The book gives a simple trick to iterating over each of the sprites only once - this way if object A is not colliding with object B then we dont need to check if B is colliding with A

If you havent worked with java in a while - I think you will find the following process interesting on catching up on where things have moved.

Changes in Java
1) First there is a list of all the enhancements to java over time

Ant and Maven
2) Ant is still great for building a one off custom java app but custom ant scripts for each project have now been replaced with the Maven pom.xml files - which uses "convention over configuration" to standardise the way code is built, packages, deployed etc. This is useful for large orgs of java developers.

Learning to install and work with maven is very quick - 1 day job
Simply go though all the tutorials in the maven book. Eventually you reach the point where there is:

    a single top level pom which "verlocks"(version locks) the versions of the dependencies
    seperate pom files per sub project which simply reference a dependency (no version number is supplied)

Jetty vs Tomcat
3) jetty seems has overtaken tomcat

"

  • requests/responses are sent over a few connections without any significant idle time.
  • Jetty tends to have better scalability when there are many connections with significant idle time, as is the situation for most web sites. Jetty's small memory footprint and advance NIO usage allows a larger number of users per unit of available memory. Also the smaller footprint means that less memory and CPU cache is consumed by the servlet container and more cache is available to speed the execution of non-trivial applications.
  • Jetty also has better performance with regards to serving static content, as Jetty is able to use advance memory mapped file buffers combined with NIO gather writes to instruct the operating system to send file content at maximum DMA speed without entering user memory space or the JVM."

and can jetty can be run from within Maven using

mvn jetty:run

If you see this error message:

"The plugin 'org.apache.maven.plugins:maven-jetty-plugin' does not exist or no valid version could be found"

you have to make certain you are in the correct pom directory - it needs to be the pom one that creates the war

4) Even though java now has annotations - there is an insane amount of xml situps (lots of xml configuration files)

The archi project allows for generation of hello world style code for various frameworks.


[pbirnie@~/java_dev/maven_tut>java -jar archy-0.1.jar
Enter the archetype id [struts2-archetype-starter], or type 'list': appfuse-basic-spring

Next Page »