Posts

Showing posts from March, 2011

Segmenting the Queue across Multiple Instances in Windows Azure

A common usage pattern in cloud computing is to process all tasks that are similar in the same instance, at the same time leveraging the scalability of cloud computing by running multiple instances for all the tasks. Grouping like tasks within an instance is done for a couple of reasons: Avoid data contention across tenants. For example, if you are aggregating data you might want to performance all the aggregation in memory before writing the data to storage. If you can segment the data that need to be aggregated together on a single tenant you will not have another tenant beating you to the write. Optimize your local memory cache. If you are caching expensive to retrieve data in the instance, segmenting your tasks to a instance with the task appropriate cache can increase your cache hit ratio. In other words different cached data specific to the work that the instance is doing. This article will talk about how to successfully accomplish task segmentation in Windows Azure.

SQL Server: Rounding DateTime to Intervals

Image
There are times when you are wanting to produce bar charts that you wish to round times to the quarter hour and keep it as a time. The typical solution is to cast as a varchar() and use the string, unfortunately this works well only for some intervals. Doing this properly is not hard, but you need to be careful not to have numeric calculation artifacts creeping in. Below, I am trying to round everything to the closest quarter hour, other periods just require some change of numbers. 15 minutes –> 24 x 4 =96 Intervals 10 minutes –> 24 x 6 = 144 Intervals 1 minute –> 24 x 60 =1440 Intervals.   The Oops not perfect solution The function below seems to create the needed result – until you test it and discover that the times are not always precise (arithmetic approximation  issues). This can cause problems with some usages.   ALTER FUNCTION QtrHr ( @When DateTime ) RETURNS DateTime AS BEGIN DECLARE @est numeric( 38 , 30 ) Set @est =

WP7 Pivot’s TitleTemplate contains Title & Subtitle

Image
I tried to add to Textblocks to the Pivot':TitleTemplate and got an error "The property 'VisualTree' is set more than once." In order to work around this, I had to add a containing object (Stackpanel) that could contain both objects. In order to do that, create a TitleTemplate that contains a StackPanel with your Title and Subtitle Textblocks inside. The image below shows the Title and Subtitle above the pivot header. The XAML to produce this is below: 1: < controls:Pivot.TitleTemplate > 2: < DataTemplate > 3: < StackPanel > 4: < TextBlock x:Name ="TextBlockPivotDeploymentItemHeading" 5: Text ="Title" 6: FontSize ="20" 7: TextWrapping ="Wrap" /> 8: < TextBlock x:Name ="subtitle" 9:

IT Hiring: Time to reread Huxley’s Brave New World?

Actually for many managers today, read it for the first time. (It’s on line here )   “It's an absurdity. An Alpha-decanted, Alpha-conditioned man would go mad if he had to do Epsilon Semi-Moron work–go mad, or start smashing things up. Alphas can be completely socialized–but only on condition that you make them do Alpha work. Only an Epsilon can be expected to make Epsilon sacrifices, for the good reason that for him they aren't sacrifices; they're the line of least resistance. His conditioning has laid down rails along which he's got to run. He can't help himself; he's foredoomed.” For the illiterate, Alpha’s are the  smartest ones. The Harvard Business Review just made a video available called “ Hiring: Finding People Who Fit ” which echo similar thoughts.   Recently I have been mentoring several younger folks, and for some, I see the definite attitude that “ All people should be made in my image ”. No ability (or even consideration) of walking i

Client Web Sites, Licensing and breach of contract

Yesterday I spent a hour and a half with a local developer who develops websites for local firms. He called because of my earlier posts on copyright issues. After getting a night to sleep on it, I suddenly said “dung, it’s a legal mine field today”. I will scenario two cases: A site using some form of open license software (i.e. JQUERY etc) A site using some 3rd party component that the developer is licensed for (for example, FLASH, TELERIK etc) “Our contract says that the customer owns the code” Without a lot of clean legal qualification of what the exactly means – you are in breach of contract with both of the above scenarios! The customer would need to sign the dozen of pages of legalesse required to qualify this. Why???? If you are giving them ownership of the code and using JQUERY, then you are saying that they own JQUERY and can legally sue anyone else that uses the JQUERY. If you exclude 3rd party components but supply code that sets or alter properties

Litigation: People in LLC Houses…

Lately I have been attempting to assist two former business partners in resolving a dispute. The problem arose because one of them resigned in writing from a LLC leaving the LLC completely in the hands of the other. There can be many reasons for someone doing so: The LLC is getting into murky legal waters and the person wishes to wash their hands of it to avoid being tainted with potential future problems; The LLC is financially underwater (which I believe is correct in this case) and the person decides that future efforts of getting it viable is not worthwhile the effort Typically, the person bailing out will form a new LLC and may pursue a similar business model. The dispute is an interesting one because it is akin to an employee quitting a company and then turning around and demanding severance, their chair, their PC and all of the software on it that was purchased by the corporation. It appears to be a combination of a sense of over-entitlement and not under

Silverlight WP7 Change TextBlock Foreground in Item class code

Image
Introduction This post is a result of research I did for my own app project. I needed to change the Foreground color of a TextBlock via code based on the value of a property at runtime. The app is a Windows Phone 7 Pivot app with the default MVVM classes (provided by VS2010 during project creation). I found plenty of explanation and some sample code but couldn't make it work in my own app. I found the WinMilk app  source code on CodePlex and knew that app did something very much like what I wanted to do. Thanks to the app authors for making the code available. Feature Description The data concept was of a collection of Items, where each item has a status and a color associated with that status. The visual concept was a PivotItem with a ListBox. The ListBox is bound to the data collection. The ListBox's StackPanel contains a TextBlock for the Item's Name. The Item's Name needs to change color based on the Item status. Since the object is from a collection, it wasn&

Entrepreneurs Coffee: Personal Kanban and Lean Startup Methodology

Image
I attended Entrepreneurs Coffee this morning, see a lot of familiar faces and a few new ones. The speaker was Jim Benson, the author of the newly released book " Personal Kanban " as one of the founders of the Seattle's Lean Coffee. A few interesting notes that I took are: Jim and his partner(in DC) or clients will by on Skype 100% of the working day, not having a conversation – rather just hearing each other clicking away. When an issue arose, there is no need to make a telephone call or start a Skype conversation… he just speaks up !  Elegant approach. Sharing a virtual skype cubicle. Economy of scale does not work for Knowledge Workers – the more of them that you get involved, the lower the return per employee. I have seen this often and have been known to say “Don’t give me two developers to help me meet the deadline unless you really want to miss the deadline!”. Solo-coding (for me) often results in the highest output. Passing information and making sur

Entity Framework Parameter Differences

When using EF there is no constructor on DbParameter that takes arguments, and that makes sense. It is meant to be overridden by the concrete type under it, usually SqlDbParameter. Because of this there is also no method for AddWithValue on the DbParameterCollection, which confuses people on occasion.   I just posted a handy extension method to MSDN forums to help turn this:   1: var p = cmd.CreateParameter(); 2: p.ParameterName = "Latitude" ; 3: p.Value = ( double ?) this .latitude; 4: cmd.Parameters.Add(p);   Into this:   1: cmd.AddParameterWithValue( "Latitude" , ( double ?) this .latitude);   Here is the method: 1: /// <summary> 2: /// Adds a parameter to the command. 3: /// </summary> 4: /// <param name="command"> 5: /// The command. 6: /// </param> 7: /// <param

VisualStateManager.GoToState not working?

I’ve had issues with this on and off for a while and thought I should note my solution quickly.   Expression Blend will actually use ExtendedVisualStateManager, but the base class VisualStateManager has this solution as well. Basically, due to a bug that was supposed to be fixed, but for whatever reason still exists, the visual state sometimes won’t change using this method. The GoToState method takes a control, a state name string, and Boolean whether to use transition animations.   The solution is simple. There is another method called GotoElementState that takes a FrameworkElement, and the rest. Just use this instead and your problems go away.   1: // Avoid this. 2: VisualStateManager.GoToState(ctrl, stateName, true ); 3:   4: // Use this. 5: VisualStateManager.GoToElementState(ctrl, stateName, true );

Copyright, Open Source, Clean Rooms and Ignorance of the Law

Recently I was reminded (by being an observer to some drama) of the legal constraints that developers should know but frequently do not know – especially the new self-taught developers. I suspect that even some Computer Science graduates are ignorant here. Monkey See, Monkey Do –Lawyers Knock! Jack develops websites and a customer points him to a website that he wants emulated. Jack goes to the site and copy portions of the code from the site. Often the code is nothing more than a JavaScript function or a chunk of CSS. He uses these code fragments exactly as written (no renaming variables, changing line orders etc). He brings in a graphic designer that does a brilliant original design.   The site is ready, the customer is happy, Jack drops a check in his pocket.   Two months later, the customer phones Jack – he has just received a letter from a lawyer to take down the web site because it contains copyrighted material. Jack talks the customer into leaving it up. The site provi

FYI: I am doing a series of posts for Enterprise Applications on Microsoft’s SQL Server

These will generally be SQL Server focused and are available at: http://blogs.technet.com/b/sql_server_isv/ Some topics covered are how much RAM per core is ideal. How to secure SQL Server better – for example how to time-out SQL Server Sessions after 15 minutes of being idled.   Check out the posts and pass them around!

Full Employment and Freedom

Last night I watched a retrospective on Alistair Cooke, the classic presenter on PBS (Mystery etc) and one of the signs on a civil rights era protests caught my eye, I remember only the end of it “.. + full employment = freedom”.   Looking at history, the truth of this becomes obvious. The end of the Serf system in Europe did not happen by a peasant revolt, but due to the Black Death. It resulted in a labor shortage so serfs could exit their positions and earn income from a land owner whose own serfs were decimated.  High unemployment have been a constant motivation for many revolutions. One of the pro-forma argument in the Communist versus US brand of Freedom days was:   “In the Soviet Union we have freedom from hunger, lack of medical care, homelessness, etc. In the US you have freedom to exploit your neighbor, freedom from social contracts between employer and employee, etc.” So the question becomes, if you are destitute and unemployed with 30% unemployment, with loved