Today, Mark and I announced the winner of the 3rd Madgex Coding Challenge. This coding challenge was announced on the 3rd June and entries needed to be in on the 30th June. The email announcement said:
So, the challenge this time is all around compression.
Take a string, compress it into a byte[], record the size, decompress it.
You can use any algorithm you chose, but it must be coded by you and not included from an external library
I have defined an Interface ICompress as follows:
public interface ICompress { /// <summary> /// Take a string and convert it into a byte[] /// </summary> /// <param name="source">The string to be converted</param> /// <returns>The converted byte[]</returns> byte[] Compress(string source);
/// <summary> /// Take the bytearray produced by the call to Compress, and decompress it /// </summary> /// <param name="compressedData">The data to be decompressed</param> /// <returns>The string</returns> string DeCompress(byte[] compressedData); }
I have provided a solution with the interface (Interface), a console app (CodingChallenge3) and an implementation of the interface (Compressor) (which just converts from string to byte[] and back again, no compression) on the development file share.
The source string is provided through the app.config file of the CodingChallenge3 project (the console app).
What do you need to submit? - A Compressor project that I can plug in to the provided solution - A couple of paragraphs explaining how your algorithm works
We had 4 solutions submitted, and they were all of a really high standard. I tested them with 6 different input scenarios: - The original provided sample - the text for "Mary had a little lamb" - An empty string - which caused a few exceptions to be raised - A single space - A string of numbers - The contents of war and peace - The contents of the 3 musketeers in French
Each sample was run through each person's solution, and the most compressed result won that round. In the end, one person won 2 rounds (having implemented their own algorithm) and one won 4 rounds (having implemented 3 different methods and selected the one with the highest compression).
I'm delighted with how these are going, and the interest and general communication that they generate - lots of discussion, hints of secrecy, and comparisons between each other - and then lots of discussion once the results have been announced, and the code is available for scrutiny. So, I'm now busy thinking up ideas for Madgex Coding Challenge 4 - if anyone has any suggestions or resources for me to use, please pop them in the comments
SQL: Building a comma separated list from a select clause
A colleague asked me today about generating a comma separated list of values based on the results of a SELECT statement. A quick google later and I found Using COALESCE to Build Comma-Delimited String
So, for my table Continent, and my usual SELECT of SELECT [Name] FROM Continent with just a variable declaration and a use of COALESCE and hey presto, we get our required result of Africa, Antarctica, Asia, Australia and Oceania, Europe, North America, South America
The code is now: DECLARE @List VARCHAR(1000)
SELECT @List = COALESCE(@List + ', ', '') + Name FROM Continent
I use toodledo to manage my todo list, and this works fine, except that it means I have my browser open all the time and don't really plan my days too well being a bit more reactive than proactive. A few weeks ago I stumbled across a tweet from Craig Murphy linking to the ebook version of a (very well written) Pomodoro manual (Pomodoro being a time mangement system). I've been using the Do It Tomorrow technique with toodledo, but haven't really embraced the daily system. Combining the two looks like it'll work well for me, allowing me to focus on what I need to do each day, whilst still recording other items (tomorrow and beyond) in toodledo.
I also recently stumbled across the PocketMod books from paper concept, and have been using a simple one as my work week planner for the last couple of weeks. Today I went one stage further and used Natalie's Pocket Project html/css work to create a Pocket Pomodoro template for myself to use.
It has a week view on the front page - so I can put known appointments in there, allowing me to carry my calendar around the office with me. And then 5 pages of todos, one per week day with an Unplanned and Urgent section to note down extra items. I haven't put any checkboxes in as the number of pomodoros taken to fulfill a task will dictate this. There is an Activity Inventory page, to put any of the items that appear that are not do it today urgent - these will be put into toodledo at an opportune moment. Finally there is a notes page, to jot down anything that comes up during my week. Over time, as I use this more, this may become a second Activity Inventory page, so watch this space.
As with Natalie's example, it only works on Webkit based browsers so I've also created it as a PDF for anyone who is interested in using this but isn't using a webkit based browser.
And of course, once you've got your PocketMod printed, you'll need to fold it, and this YouTube video does a great job of explaining how to do that
So now instead of the call spu_generateinsert @table = 'LanguageData' producing INSERT INTO [LanguageData] ([liID], [Value])VALUES (7,'D''Artagnan raconte qu''à sa première visite à') it produces INSERT INTO [LanguageData] ([liID], [Value])VALUES (7,N'D''Artagnan raconte qu''à sa première visite à')
As usual, the script is available here And again as usual, leave me a comment if you think of some new functionality I should include, or any issues you come across.
When using App_offline.htm files to take down a site in IIS, if the file size isn't 512 bytes of content or greater then IE may choose to default to the "Show Friendly Http Errors". Comments count towards the byte size so client side comments will work too.
A lot of our sites use a url mapper, so when setting up the sites within IIS we map extension .* to the appropriate aspnet_isapi.dll.
I'd got carried away when setting up the webservice and did the same thing, resulting in a The HTTP verb POST used to access path '/WebService/WebService.asmx/DoSomething' is not allowed. error. Removing the .* mapping fixes this.
Definitely under the note to self category this one...
I've been working with installing a service and took the base code from our platform. Part of the command line specifies a parameter to be used within the installer, but no matter what I did I could not get the parameter to be picked up.
An example of the installation command line is "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\installUtil.exe" "C:\Services\MyService.exe" /SERVICENAME="My Special Service" which, at least in theory, allows the service to be created so that in the Services dialog it is listed under the name "My Special Service"
In my case, the code was even simpler than the example as I was specifically looking for only one parameter, the service name, and so my OnBeforeInstall and OnBeforeUninstall become protected override void OnBeforeInstall(System.Collections.IDictionary savedState) { base.OnBeforeInstall(savedState); SetServiceNameFromCommandLineParameter(); }