Tuesday, June 14, 2011

Generate rails from a ERD ?

This isn't much of a blog post, it's a question !  I love ERDs (Entity Relationship Diagrams)  for database design and have been known to produce them before the database or the code .  Recently I've been doing a lot of work in Ruby on Rails which generates the database and model code for you, hiding the database under a ORM layer.  This is all very well and good  but you can see my problem.  No longer can I build  a ERD, check it's normalisation  nd optimise it with a bit of de-normalisation.

So, the question is:

Is there a tool out there that will take a ERD and generate the rails commands to build a app from the ERD.  I mean create the models and generate the migrations at least  ?

Suppose you had an ERD like this:


When I want to generate rails this would do something like the following

rails generate scaffold Person name:string
rails generate scaffold Town name:string<
rake db:migrate

It would then go in and alter the model for Person to set up the relationship to town.


Answers on a postcard !

Wednesday, May 25, 2011

Setting a home directory link in Rails 3

If you need to set up a path to the home directory in Rails 3  you need to change your routes.rb  file to create a named path.  In your routes.rb file you create the following mapping


match '/' => "home#index", :as => :home

(
this assumes your rails app has been created with 

rails generate controller home index

)

you can then create a link using linked_to

<%= link_to "Home", home_path %>

The point here is we've created the named link as "home"  but the path is referred to home_path.

Wednesday, April 20, 2011

Fun with the Independent's URL's

So:

This blog points out that you can alter URL's at "The Independent" to say anything you wish.  For instance @girlgeeks produced this one

http://www.independent.co.uk/environment/Cameron-destroys-environmental-laws-inUK-26-2270274.html

And

http://www.independent.co.uk/news/business/news/rupert-murdochs-is-a-PROPAGANDA-peddling-bampot-2270217.html

The question is, will they find their way into google search engine ? Lets wait a day or to and see !

Wednesday, April 6, 2011

General Advice for commissioning a web service (web site)

Contract
Ensure you are clear what you are going to get for the money ! Make a tick list of what will be delivered and produce a Gantt chart to track the progress. Ask what development methodology the programmers are going to follow, agile or waterfall. Make sure they explain their methodology so you are clear when you are going to meet with them and how you can track progress.

Browser support
Define which Browsers should be supported. At a very minimum this should include:

I.E9, I.E8
Firefox 3.6 and 4
Chrome 9 and 10
Safari 4

HTML version
Define the version of HTMl you want, make sure your website validates correctly to that version. If you plumb for HTML 5 make sure it displays correctly on the supported browsers. If you use HTML 5, use roles correctly.

CSS version
Again, check the supported browsers will support the version of CSS you choice. If you use CSS3, use only features supported by all browsers.
Interface

Ensure the interface is restful. Ensure return codes are meaningful. This will help when you want to create a mobile verson of the site or create mobile apps that use the site as a service.

A restful interface should help with jQuery support as well. Make sure your interface supports returning data as JSON at a the very least and a RSS feed as an option
Security

Escape all input to avoid XSS attacks . For PHP use htmlentities, all other languages should have something similar

All input and queries to the database should either be Paramatised or better still stored procedures should be used.

Any uploaded content should be limited to known file types. The content of the file should be verified and the file should be stored outside the webserver directories. Download should be anonymous so the file system is obscured.

Version Control
What version control system will they use. If they use a public one are they aware of any copyright problems that it may bring

Testing
How are they going to test the site ? Do they propose to use unit testing, if so will it be automated ?

Wednesday, March 23, 2011

Hackday at Dundee

I've started wandering around taking pictures of the students in acton as they near the start of Dundeeuhack 2011. The demos will take place on Friday afternoon in the QMB street area. Looking forward to seeing what everyone does. The current list of projects is here:


http://hackday.computing.dundee.ac.uk:8080/allhacks.jsp?Year=2011

Pictures as they arrive,



www.flickr.com

acobley's items tagged with uhackdundee11 More of acobley's stuff tagged with uhackdundee11

Friday, March 11, 2011

So you think you own your twitter name ?

Update Tuesday 15th March

An interview with @girlgeeks with the full story is available here: How-safe-is-your-Twitter-name/



Update Sunday 13th March

I believe this matter has now been resolved and the girlgeeks name will go back to the original owner. Thanks for all the support.



So you think you own your twitter name ?

Chances are you don’t, chances are you could have it taken away from you at any moment or have it changed by twitter adding an underscore to it. So what does it matter, it’s only a twiter account after all. Wrong, your twitter account can be your main online presence, your main identity that people know you by and your main contact.

Suppose you’ve spent 2 years building an international reputation, have thousands of follower, some of own are leaders in their fields, some of who are close friends. Overnight their contact books are out of date, overnight their DM messages no longer go to you but some third party, overnight any archived Follow Friday tags #FF are out of date, overnight your on line reputation has gone. And worse, think how many resources you will need to update, business cards, linkedin, Skype and thats not to mention your presence in search engines. Can’t happen here ? It can and it has.

It happened to a close friend of mine last night. She spent over two years building the @girlgeeks account, spreading words of Girl Geek Scotland to over 26 countries. Last night an organsation called @GIRLGEEKS contacted Twitter to say they had registered trademark for Girl Geeks and wanted the @girlgeeks account for themselves. This organisation only stated a couple of months ago and yet compared to the prior reputation of @girlgeeks this meant nothing, Twitter took the account and handed it to them on a plate. To make matters worse, twitter sent message to the original owner to say they where going to change their twitter name, there was no chance to respond, to argue or to appeal. They just change your name and then tell you afterwards. Oh, and they ask you to make it clear on your that your account is not associated with the brand.

As the previous owner of @girlgeeks says:

“The message from Twitter is get an International TM for your name or they'll take it for a private ltd company”.

Just to make the effect clear, here's what happes if you do a search for girlgeeks on google:


Clearly pointing to the old account, we'd expect to see the good work girlgeeks has been doing. if we click on we get:



Not what expected and very damaging to the original owner to the original owner of the twitter account.


This is clear case of #copywrong, its heavy handed and I suspect that Twitter have no clear idea of the damage they have done. The message is clear, you don’t own your twitter account, Twitter does.

There is an official responce from the other side here PDF

Monday, February 21, 2011

Cassandra’s data model as records and lists

I have to admit I’ve never really been happy with Cassandra’s data model, or to be more precisely, I’ve never really been with my understanding of the model. However I’ve realized that if we think of two use cases for column families then things may become a bit clearer. For me, Column families can be used in one of two ways, either as a record or an ordered list.

Columns used as a record
If we place name value pairs under the column key that contain different attributes then we can consider the columns as classic database record. So if we are wanting to store the details of a user then the columns might be:

Name (key)

  • Email: user@example.com
  • Twiter: TwitterUser
  • Phone: 01 000 345678


In this schema the order of the columns is not important because the names are not related. However unlike a relational database, there is no definition of the “fields” in the record, we define them at runtime in the application. This does give us the flexibility to add new fields providing our application can handle missing “fields”.

Columns used as a List
If each of the name value pairs are the same attributes then we can consider this as an ordered list . In this use case the ordering of the columns is important and the ordering type needs to be carefully thought out. For example if we want to store messages from a user, and we want to be able to get the most recent, then we will store them as:

Author (key)

  • Timeuuid: Message
  • Timeuuid: Message
  • Timeuuid: Message


This ordered list can be thought of as an index of records. The records would be stored in another column family.

Supercolumns as a list of records
Even better, we can use supercolumns to create a combination of lists and records. Normally we would make the supercolumns the ordered list and the columns the record. In our messaging system, we want to get the latest messages from a user:

Author (Key)

  • Timeuuid: (Supercolumn name)
    • Message: Message Text
    • Time: Time of message
    • Picture: Binary picture data
  • Timeuuid: (Supercolumn name)
    • Message: Message Text
    • Time: Time of message
    • Picture: Binary picture data

The supercolumns are ordered by time, the columns under it are not ordered.

As ever I look forward to comments about this post.

Wednesday, February 16, 2011

Dundee Hackday 2011 begins.

So yesterday we kicked off this years Dundee Hackday with YDN and Mozilla. The timetable for this year is:


  • Tuesday 15th, Video conference with Murray Rowan and Steve Marshall from YDN! and Christian Heilmann from Mozilla
  • Wednesday 16th Start to assemble into teams and get your ideas together.
  • Tuesday March 1st Post your groups and ideas to Entry form
  • We will will then take a look at your idea and give you feedback.
  • Start build your Hack.
  • March 25: Show your Hack in the QMB Street to University staff, Yahoo! developers and Christian Heilmann
  • March 25 The Best Hacks are announced, prizes are given. All retire to the student union for a well earned rest!

Christian Heilmann has published his thoughts on yesterday's video conference Introducing Mozilla technology and ideas to students for a hack day


TwitterTag #uhackdundee11
FlickrTag uhackdundee11

Friday, January 14, 2011

IIS and Glassfish together

This is really just a note to myself. However if you want to run IIS and glassfish on the same windows 2008 server it's not enough to config IIS to listen on one IP address. You need to tell windows that it is responsible for only one of the addresses. You can do this form the command line:


netsh http add iplisten ipaddress=xxx.xxx.xxx.xxx

Second Glassfish will need to be configured to listen to only one address. In the config.xml for the domain find the network -listeners and add an address to port 80:


Thursday, January 13, 2011

Firefox and undefined array elements

So here's a Javascript question. Now I admit I'm not a Javascript expert so this ones got me a bit stumped.


In the following code snippet I'm trying to get a function to do something only when it is
first called. It can be called with a number of items (identified by an integer I), it
should call itself only the first time it is called with that arguement. I have an array (lsaCall)
with only the first item defined (and set to 0). If the array element is undefined (or 0) then the function
calls itsel on a timer.

var lsaCall = [0];
function loadSubscribedArticles(i,tag,Author){
 
 //alert("lsaCall "+lsaCall[i]);
 if ((lsaCall[i]==undefined) || (lsaCall[i] ==0)) {
  lsaCall[i]=1;
  //alert("Undefined"+lsaCall[i]);
  var int=self.setInterval("loadSubscribedArticles('"+i+"','"+tag+"','"+Author+"')",1000);
  
 }
}

This works fine and dandy but doesn't work at all in firefox. It complains that lsaCall
is undefined (well I know that !)
Any ideas on how to get this working in firefox ? Is there a better way of doing it ?