Tuesday, 7 June 2011

uBlogsy - 1.2

So it's been about a week since I launched uBlogsy and I'm already up to version 1.2.

v1.01 was the first update which added famfamfam icons to the content nodes. It makes everything damn pretty to look at.

v1.1 added optional month folders after @dascoba mentioned them. This version also added an SEO tab. When the SEO properties are left empty, uBlogsy uses the title and body of posts.

v1.2 is todays release. It includes blog import from an RSS url, an alternate archive layout for FarmFreshCode related posts, and minor tweaks.

Thursday, 2 June 2011

uBlogsy - A blog package for Umbraco using Razor

So I decided to create a blog using Umbraco.

I'm a huge fan of Razor, and since Umbraco supports Razor these days, uBlogsy was super easy to make.








ps. If anyone wants to contribute to making skins for uBlogsy, please get in touch.

Saturday, 7 May 2011

uHidesy 1.1 - A way to show and hide properties and tabs in content nodes

After some helpful feedback from Chris Evans and Lennart Stoop, I have spent the last 2 days adding new functionality to uHidesy.


New in this version:

  • uHidesy by default now "tags" tabs and properties which will be hidden from the CMS editor
  • A checkbox has been added to allow hiding of tabs and properties (not tagging)


Download it here:






Thursday, 5 May 2011

uHidesy - A way to show and hide properties and tabs in content nodes

Yesterday I released an awesome new Umbraco package called uHidesy.

uHidesy is a datatype, which when added, allows you to show and hide tabs and properties in content nodes.

Uses...

Scenario 1:
You make document types for a purpose. Then that purpose changes and you must add more properties and tabs. The annoying thing is that it messes up the elegant interface you created for your cms editor. Now you have properties and tabs in some content nodes which are never used. Dont you wish you could hide them?

Scenario 2:
You are told "the client doesnt need that functionality". You KNOW that they will ask for it eventually because IT JUST MAKES SENSE. So you add the properties and tabs to the document type anyway because it will save you a world of pain having to do it later. But dont you wish you could hide those properties and tabs?

Is there a way to show and hide properties and tabs in a content node? There is now!

Simply add the uHidesy data type to the Properties tab of the document types you wish to have control over. In the content node Properties tab, uHidesy lists the tabs and properties you can click on to toggle. Click save (or publish) and you're done!


Download it here:




Monday, 11 April 2011

Mars rover exercise

A recruiter wanted to put me forward for a contract. Below is the programming test that they wanted me to perform. Further down is my approach to solving the problem.

Keep in mind that the recruiter told me that the “test” is likely not do-able in 1 hour, and that the company was more interested in my approach to the problem.

I'd like to point out that this is a serious solution and approach to the problem. It is a real world solution to a problem which was not do-able in the given time. I think it shows ingenuity and thinking out of the box.


Here is the programming task:


Software Engineer MARS Rover Exercise

As a guide you should spend 1 hour working on this task.

1. MARS Rover

Objective

The purpose of this test is to enable you to demonstrate your proficiency in solving problems using software engineering tools and processes.

Read the specification below and produce a solution. Your solution should be in the form of completed code.

If you are unsure of any part of the specification then you should ask to speak to a member of the Software Engineering team either via your recruitment agent or HR contact.

The problem specified below requires a solution that receives input, does some processing and then returns some output. You are free to implement any mechanism for feeding input into your solution. You should provide sufficient evidence that your solution is complete by, as a minimum, indicating that it works correctly against the supplied test data. Using a unit testing framework would satisfy these requirements.

The interviewer will be interested in:

· Your ability to read and interpret the specification below.

· The architectural design of your solution.

· The readability of your code.

· Your overall approach to this exercise.

Specification

A squad of robotic rovers are to be landed by NASA on a plateau on Mars.

This plateau, which is curiously rectangular, must be navigated by the rovers so that their on board cameras can get a complete view of the surrounding terrain to send back to Earth.

A rover's position is represented by a combination of an x and y co-ordinates and a letter representing one of the four cardinal compass points. The plateau is divided up into a grid to simplify navigation. An example position might be 0, 0, N, which means the rover is in the bottom left corner and facing North.

In order to control a rover, NASA sends a simple string of letters. The possible letters are 'L', 'R' and 'M'. 'L' and 'R' makes the rover spin 90 degrees left or right respectively, without moving from its current spot.

'M' means move forward one grid point, and maintain the same heading.

Assume that the square directly North from (x, y) is (x, y+1).

Input:

The first line of input is the upper-right coordinates of the plateau, the lower-left coordinates are assumed to be 0,0.

The rest of the input is information pertaining to the rovers that have been deployed. Each rover has two lines of input. The first line gives the rover's position, and the second line is a series of instructions telling the rover how to explore the plateau.

The position is made up of two integers and a letter separated by spaces, corresponding to the x and y co-ordinates and the rover's orientation.

Each rover will be finished sequentially, which means that the second rover won't start to move until the first one has finished moving.

Output:

The output for each rover should be its final co-ordinates and heading.

Test Input:

5 5

1 2 N

LMLMLMLMM

3 3 E

MMRMMRMRRM

Expected Output:

1 3 N

5 1 E



My approach to the Mars Rover Excercise

Upon reading the task, it dawned on me that a complete elegant solution might not be possible within the time frame of 1 hour. So I did what any good developer would do... check to see if there already existed a solution to my problem which I could re-implement. So I googled "Mars Rover Exercise".

The first link that appeared was a codeplex project:

http://marsroverexercise.codeplex.com/

Upon reading the description, it seemed that the task was EXACTLY the same as the one I was given. Upon inspection, it seemed that the code did what I needed it to do, so I downloaded the source.

I do not have Visual Studio 2010 at my current place of work, so I created a new 2008 solution, loaded in the files, did some minor refactoring to get the solution neat, and then built the solution.

I ran the project in debug mode and stepped through everything. The solution seemed to be the “solution” to my problem.

So then I zipped it up, wrote this document and presented it.

Time spent: 30mins


Saturday, 12 March 2011

Export Umbraco members as a CSV




Last week I had to write a tool to get Umbraco members as a CSV file.

I started looking into the database tables and decided very quickly that raw SQL was going to be a pain. So I used Linq to SQL :)

This is a quick example of what was required.
There are a few things you have to be careful about. Look at what order your member properties are in. For instance, in my example I know that data[0].dataNvarchar is the first name. I used the dataNvarchar property because I know it's a string. For data[3] I used the dataInt property because it was a bool.


Here's the code.



public string GetMemberCSV()
{
MyDataContext db = new MyDataContext();
var members = (from m in db.cmsMembers select m);
StringBuilder sb = new StringBuilder();
sb.Append("Firstname, Lastname, Email, Opt-In, Verification Id, Verified, Created\n");

List emails = new List();

foreach (var m in members)
{
// get the properties
var data = m.umbracoNode.cmsPropertyDatas;
var firstName = data[0].dataNvarchar;
var lastName = data[1].dataNvarchar;
var email = data[2].dataNvarchar;
var optIn = data[3].dataInt ?? 0;
var verificationGuid = data[4].dataNvarchar;
var verified = data[5].dataInt ?? 1;
var created = m.umbracoNode.createDate.ToString();

if (!string.IsNullOrEmpty(email) && !emails.Contains(email))
{
sb.Append(string.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}\n", firstName, lastName, email, optIn, verificationGuid, verified, created));
emails.Add(email);
}
}

return sb.ToString();
}



I hope that was helpful.


Friday, 24 December 2010

Android 2.2 update breaks 3G on O2

So my HTC Magic got the Froyo update last week. The problem was that it broke "the internet".

I thought it was due to the fact that my phone was an Australian Vodaphone branded HTC Magic and the update was through a UK network intended for UK/European versions of the phone. I was going to get a new phone anyway (The Nexus S) so I didn't mind, and put it aside for a later date.

Well it turns out that the mobile internet was also broken on the Nexus S (see my previous blog). In any case, once I fixed the configuration issue on the Nexus, I tried the settings on the HTC and it worked! So here are the settings I used:

APN: payandgo.co.uk
username: payandgo
password: password
MCC: 234
MNC: 10
APN type: internet

Leave everything else blank! Even the proxy!

Hopefully this works for you.

Mobile internet on Nexus S with O2 is broken

I bought the new (Samsung) Google Nexus S this week. I have to say that it is amazing! It is faster and more responsive than anything I have tried. The only problem I had was that the mobile internet was not working with the retrieved settings.

After googling the hell out of this, checking the manual settings on the O2 website, and even calling tech support, I finally figured out that the settings on the website AND the ones tech support told me were wrong.

Without any further adue, I give to you...

APN: payandgo.co.uk
username: payandgo
password: password
MCC: 234
MNC: 10
APN type: internet

If you're having this issue, hopefully these settings will do the trick.

Thursday, 16 December 2010

Cannot delete document type - Umbraco

This has been my week of Umbraco database corruption hell!

Today I wanted to delete a document type that just didn't want to budge. There was nothing in the log table, so I opened up firebug and saw this little error:


{"Message":"Umbraco Exception (DataLayer): SQL helper exception in ExecuteNonQuery","StackTrace":" at umbraco.DataLayer.SqlHelper`1.ExecuteNonQuery(String commandText, IParameter[] parameters)\r\n at umbraco.cms.businesslogic.ContentType.Tab.Delete()\r\n at umbraco.cms.businesslogic.ContentType.delete()\r\n at umbraco.cms.businesslogic.web.DocumentType.delete()\r\n at umbraco.nodetypeTasks.Delete()\r\n at umbraco.presentation.create.dialogHandler_temp.Delete(String NodeType, Int32 NodeId, String Text)\r\n at umbraco.presentation.webservices.legacyAjaxCalls.Delete(String nodeId, String alias, String nodeType)","ExceptionType":"umbraco.DataLayer.SqlHelperException"}


I started to delete the properties and tabs manually. Umbraco crashed when trying to delete a tab. It was another foreign key issue.

So again, the solution was to change a delete rule (see my last 2 posts). This time it was cmsPropertyType_cmsTab. I changed it to cascade.

Now I was able to delete the tab as normal.

After that tab was deleted, I was able to delete the document type.

I win again!


Wednesday, 15 December 2010

The DELETE statement conflicted with the REFERENCE constraint "FK_cmsPreviewXml_cmsContentVersion". - Swap Master Doc Type Error in Umbraco

Today is my day of Umbraco database hell!

I tried to swap a master doc type. I clicked ok, confirm, yes, ok etc and then nothing!

I looked into the error logs and came cross this:


At /umbraco/theoutfield/doctypeextensions/dialogs/SwapMasterDocType.aspx?id=1071&rndo=27.8 (Referred by: http://localhost/umbraco/theoutfield/doctypeextensions/dialogs/SwapMasterDocType.aspx?id=1071&rndo=27.8): System.Data.SqlClient.SqlException: The DELETE statement conflicted with the REFERENCE constraint "FK_cmsPreviewXml_cmsContentVersion". The conflict occurred in database "LOTUS_DEV", table "dbo.cmsPreviewXml", column 'versionId'. The DELETE statement conflicted with the REFERENCE constraint "FK_cmsPreviewXml_cmsContentVersion". The conflict occurred in database "LOTUS_DEV", table "dbo.cmsPreviewXml", column 'versionId'. The DELETE statement conflicted with the REFERENCE constraint "FK_cmsPreviewXml_cmsContentVersion". The conflict occurred in database "LOTUS_DEV", table "dbo.cmsPreviewXml", column 'versionId'. The statement has been terminated. The statement has been terminated. The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at TheOutfield.UmbExt.DocTypeExtensions.Dialogs.SwapMasterDocType.DoSwitch() at TheOutfield.UmbExt.DocTypeExtensions.Dialogs.SwapMasterDocType.btnConfirm_Click(Object sender, EventArgs e) at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)



The solution is identical to my previous post...

Open up SQL Management Studio.
Change delete rule for the relationship between cmsPreviewXml and cmsContentVersionto "cascade".


Now you can swap those master doc types!