Monday, May 31, 2010

Words - callithump

callithump • \KAL-uh-thump\  • noun
: a noisy boisterous band or parade

Thursday, May 27, 2010

Defeating SSL

Defeating SSL via man in the middle attacks, SSL Striping - “Moxie Marlinspike - More Tricks for Defeating SSL”.

16 minutes in – what is a certificate

19 minutes in – what is wrong with the certificate provisioning process today

23 minutes in – null characters in certificate CN – how to get a certificate with someone else’s domain name – SCARY!

30 minutes in – long code will have some bug – this time it is in NSS which is used in Mozilla browsers.

 

Notes:

NSS - http://www.mozilla.org/projects/security/pki/nss/ssl/

Nikon D40 – Using the remote control

Its easy if you know where to look!

Under the custom settings menu (the pencil icon), set the remote on duration (option 17). This specifies how long the camera will stay on waiting for a command from the remote once it has been put into the remote mode. I like a setting of 10 minutes. But be aware that the longer this setting, the more it will drain your battery. This setting needs to be messed with only once:

image

Now, every time you want to use your remote to capture a picture, you need to put the camera into the remote shooting mode. You do this by going to the Shooting mode options (option 4) under the custom settings menu and selecting either the Delayed remote mode or the Quick response mode.

image 

Here is where you can buy a cheap Nikon remote that I can confirm works with the D40. (meritline)

Wednesday, May 26, 2010

Sr. Dev position at the City and County of Denver

via blog.allanglen.com:

We are looking for someone that has strong “Web 2.0″ development experience including strong JavaScript skills (Dojo and/or jQuery experience is a big plus).

Our team is skilled in the latest technologies including ArcGIS Server, the ArcGIS Server JavaScript API, Dojo,ASP.NET MVC, WCF (SOAP and RESTful JSON services), Entity Framework and the Visual Studio Team System.

C# version of DotNetNuke Released

The first ever version of DotNetNuke in C# has been released today (http://dotnetnuke.codeplex.com/releases/view/45478)

Important – this is an unsupported technology preview.

More info:  DotNetNuke source in C#. Yeah, Really.

Open Source Software is free only if your time has no value.

Open Source Software is free only if your time has no value.

Tuesday, May 25, 2010

Dan Pink – What Motivates Us?

Dan Pink’s original talk has been used with this animation to make the talk a lot more interesting.

Answer: Autonomy, Mastery and Purpose

Monday, May 24, 2010

VS 2010 C# Code Samples

VS 2010 C# 4.0 Code Samples are available at: http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=cs2010samples&DownloadId=10177

Here are the samples available

Language Samples

(links below do not work)

The language samples familiarize you with various C# language features. They are available in the LanguageSamples folder.

The C# 4.0-specific samples are called:

Here is the complete list of language samples:

  • Anonymous Delegates: Demonstrates the use of unnamed delegates to reduce application complexity.
  • Arrays: Shows how to use arrays.
  • Attributes: Shows how to create custom attribute classes, use them in code, and query them through reflection.
  • Collection Classes: Shows how to make non-generic collection classes that can be used with the foreach statement.
  • COM Interop Part I: Shows how to use C# to interoperate with COM objects.
  • COM Interop Part II: Shows how to a use a C# server together with a C++ COM client.
  • Commandline: Demonstrates simple command-line processing and array indexing.
  • Condiational Methods: Demonstrates conditional methods, which provide a powerful mechanism by which calls to methods can be included or omitted depending on whether a symbol is defined.
  • Delegates: Shows how delegates are declared, mapped to static and instance methods, and combined into multicast delegates.
  • Events: Shows how to declare, invoke, and configure events in C#.
  • Explicit Interface: Demonstrates how to explicitly implement interface members and how to access those members from interface instances.
  • Generics: Shows how to make generic collection classes that can be used with the foreach statement.
  • Hello World: A Hello World application.
  • Indexers Part I: Shows how C# classes can declare indexers to provide array-like access to objects.
  • Indexers Part II: Shows how to implement a class that uses indexed properties. Indexed properties enable you to use a class that represents an array-like collection.
  • Libraries: Shows how to use compiler options to create a DLL from multiple source files; also, how to use the library in other programs
  • Named and Optional (C# 4.0): Demonstrates Named and Optional parameters, an alternative to method overloads
  • Nullable: Demonstrates value types, such as double and bool, that can be set to null
  • Office Sample (C# 4.0): Demonstrates how Dynamic and COM Interop make it easy to call Microsoft Office in C# 4.0
  • OLEDB: Demonstrates how to use a Microsoft Access database from C# by creating a dataset and adding tables to it.
  • Operator Overloading: Shows how user-defined classes can overload operators
  • Partial Types: Demonstrates how classes and structures can be defined in multiple C# source-code files
  • PInvokeShows how to call exported DLL functions from C#
  • Properties: Shows how properties are declared and used; also demonstrates abstract properties
  • Python Sample (C# 4.0): Learn how to call a Python script by using the Dynamic feature in C# 4.0
  • Security: Discusses .NET Framework security and shows two ways to modify security permissions in C#: using permission classes and permission attributes
  • Simple Variance (C# 4.0): See how Covariance and Contravariance are supported in generic interfaces and delegates
  • Structs: Shows how to use structs in C#.
  • Threading: Demonstrates various thread activities such as creating and executing a thread, synchronizing threads, interacting between threads, and using a thread pool
  • Unsafe: Shows how to use unmanaged code (code that uses pointers) in C#
  • User Conversions: Shows how to define conversions to and from user-defined types
  • Versioning: Demonstrates versioning in C# by using the override and new keywords
  • XML Documents: Shows how to document code by using XML
  • Yield: Demonstrates how to use the yield keyword to filter items in a collection

LinqSamples

  • DynamicQuery: Code to create LINQ queries at run time.
  • LinqToNorthwind: A basic example of how to use LINQ To SQL to query a database
  • LinqToXmlDataBinding: Bind LINQ to XML code to WPF controls
  • ObjectDumper: A utility for writing the output from a LINQ query to the screen in text mode
  • PasteXmlAsLinq: A Visual Studio addin that automatically converts XML to LINQ to XML.
  • QueryVisualizer: Allows LINQ to SQL developers to see the SQL for their query, and also to see the results of the query in a grid.
  • Reflector: Use LINQ to right queries against the objects in your code using the Reflection APIs
  • RSS: This sample acts as a tiny web server that aggregates several RSS feeds
  • SampleQueries: This is the most important sample and contains about 500 examples of how to use each of the query operators in LINQ to Objects, LINQ to SQL, LINQ to XML and LINQ to DataSet.
  • SimpleLambdas: Several examples of how to write and use lambda expressions
  • SimpleLinqToObjects: The hello world of the LINQ samples. This shows you how easy it is to do simple queries of in-memory objects using LINQ to Objects.
  • SimpleLinqToXml: Get started using LINQ to XML.
  • WebServiceLinqProvider(TerraService): A custom LINQ provider and client for the TerraServer-USA Web service.
  • Whitepapers: The following papers are stored in this directory in Word format:
    • LINQ Project Overview
    • LINQ to SQL Overview for C# and VB
    • Standard Query Operators
    • LINQ to XML Overview
  • WinFormsDataBinding: Learn how to display LINQ queries with grids in a Windows form. It includes a one to many query example.
  • XQuery: Another simple LINQ to XML sample query. This sample shows the minimal code necessary to write a LINQ to XML query

VS 2010 keyboard shortcuts

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=92ced922-d505-457a-8c9c-84036160639f

Here are the shortcuts for C#:

image

image

image

Friday, May 21, 2010

XSD to UML

Ever needed to look at the XSD in a Web-Service WSDL as a UML diagram? Here is an awesome tool that does just that:

HyperModel for Eclipse: http://xmlmodeling.com/hypermodel

Just download the XSD files referenced by the WSDL and then load them up in HyperModel. Its an awesome tool and its free!

Friday, May 14, 2010

VS 2010 – Cool New Feature – Hierarchical Web.Config files

One of the coolest new features in VS 2010 is what I call “hierarchical web.config files”. The idea behind this feature is that you have one main web.config file that contains all the settings needed to run the application in your local environment. You then have multiple web.config files that inherit from this main web.config file, in which you specify only the changes needed on the main web.config file for your different environment.

I believe the official name for this feature is “web.config transformations”.

Note 1: An important point to note is that hierarchical web.config files is only available on web-application projects and not for web-site projects. This feature is also not available for app.config files.

Here is an example:

The main file, defines all the settings required by the web application.

The debug file, changes the connection string to use the TestStage server instead of the local “.\SqlExpress” defined in the main config file. This is done by using the xdt:Transform and the xdt:Locator attributes (shown in bold).

The production file, not only changes the connection string to use the production database server, it also removes the debug=”true” attribute, that was specified in the main.config file. (this on its own, makes this feature worth it to me – coz, I cant even begin counting the number of times I have pushed code to production and forgotten to remove this setting).

image

Note 2: The settings in Debug and Production do not take effect when you are debugging the application within Visual Studio (F5). The transformations specified only take effect when you publish or deploy the application and at that time, the transformation applied is dependent on the selected configuration.

More information:

http://msdn.microsoft.com/en-us/library/dd465326(VS.100).aspx

7 Harsh Realities in Social Media

Good info….

Tuesday, May 11, 2010

SilverLight Toolkit and Windows Phone 7

If you attempt to use the SilverLight Toolkit on the Windows Phone 7, you might get the error “Could not load file or assembly". Apparently the issue arises from a bug with running dlls signed with certs other than Windows Phone certs.

For now the only way to continue building apps is to remove the certs on these dlls.

Instructions for doing this can be found at: http://bit.ly/aODiLV

Note: you might have to run the following command before attempting to run the script on that site:

set-executionpolicy unrestricted

(the command set-executionpolicy remoteSigned, did not work for me). Also, remember to start your command prompt in Admin mode on Windows 7.

Monday, May 10, 2010

VS2010: Layer Diagrams

Layer diagrams is a new feature in VS2010 that is available in SKUs above VS2010 professional (premium and ultimate).

Here are some useful links about this new feature:

Guidelines: http://msdn.microsoft.com/en-us/library/dd418995(VS.100).aspx

Creating layer diagrams: http://msdn.microsoft.com/en-us/library/dd465141(VS.100).aspx

Validating layer diagrams: http://msdn.microsoft.com/en-us/library/dd409395(VS.100).aspx

Reference: http://msdn.microsoft.com/en-us/library/dd409462(v=VS.100).aspx

Application Architecture Guidelines VS plugin: http://visualstudiogallery.msdn.microsoft.com/en-us/237f823c-45b4-4f1f-b9e2-607fe66eaae7

Saturday, May 08, 2010

Testing web pages in different IE versions - Expression Web SuperPreview

A new free tool from Microsoft called “Expression Web SuperPreview ” is now available:

Expression Web SuperPreview for Internet Explorer speeds the essential task of debugging your web sites for cross-browser compatibility…..
Expression Web SuperPreview for Internet Explorer is a stand-alone visual debugging tool that makes it faster and easier to migrate your sites from Internet Explorer 6 to Internet Explorer 7 or 8…..
Expression Web SuperPreview for Internet Explorer shows your web pages rendered in Internet Explorer 6 and either Internet Explorer 7 or Internet Explorer 8, depending on which version you have installed on your machine. You can view the pages side by side or as an onion-skin overlay and use rulers, guides and zoom/pan tools to precisely identify differences in layout. You can even compare your page comp to how the targeted browsers render the page….
Expression Web SuperPreview for Internet Explorer is a standalone, free application with no expiration and no technical support from Microsoft.

Download it from: http://www.microsoft.com/downloads/details.aspx?FamilyID=8e6ac106-525d-45d0-84db-dccff3fae677&displaylang=en

Why you should always use trusted libraries for Cryptographic algorithms

Cryptography is an extremely hard subject with subtleties that are hard for most developers to understand. It is for this reason that you must always find trusted sources for your Cryptographic needs (eg: Microsoft’s System.Security.Cryptography namespace), because even if the vulnerability exists you know there is a large team of developers working on fixing the issue immediately.

Today I came across this paper that shows how even simple operations like comparison of values can be implemented in such a way that they can end up exposing your system.

The attack is called a “Remote Timing Attack”. Basically it uses the fact that when comparisons are performed between keys, the comparisons are performed byte by byte. This in turn means that the longer the comparison takes, the more bytes the attacker has correct in his attack key.

Here is a paper that goes more in depth into this type of attack “Remote Timing Attacks are Possible”: http://crypto.stanford.edu/~dabo/papers/ssl-timing.pdf

Bottom line: Never try to stoke your dev ego by implementing cryptographic algorithms for use in a production environment. Always find a trusted library from a trusted source.

Judgment! – Top down vs Bottom up

Its all a matter of perspective.

image001

Friday, May 07, 2010

The World’s Largest Data Centers

via: http://www.datacenterknowledge.com/special-report-the-worlds-largest-data-centers/

Interesting that Google’s data centers do not appear on this list, even though when I think of massive container style data-centers, the first name that pops to my head is Google.

On the worthy contenders list, here is what they have to say:

Where is Google? Many readers may have expected to see some Google data centers on the list. But Google’s new construction has focused on data center campuses featuring multiple facilities, rather than single huge buildings. As a result, Google has multiple data center buildings larger than 300,000 feet, but none (that we can find, anyway) larger than the 400,000 SF entry point for our list. For more on Google’s data centers, see our Google Data Center FAQ.

The cloud is here and it is here to stay!

Thursday, May 06, 2010

Using Lambda Expressions for Tree Traversal – C#

While learning about lambda expressions in C#, I found that trying to create a tree and traversing the tree using lambda expressions made for an interesting study in this topic (as you have to think of ways in which you can use the lambda expression to perform recursion).

The one thing I found is that if you want to use lambda’s for recursion, then you need to make them static.

Here is the code for the tree:

class Tree
{
#region Fields
public int? Id { get; set; }
public int? ParentId { get; set; }
public string Text { get; set; }
#endregion Fields

#region Tree properties
public bool IsRoot { get { return Id == null; } }
public bool IsLeaf { get { return _children == null || _children.Count <= 0; } }
#endregion tree properties

private List<Tree> _children = new List<Tree>();
public List<Tree> Children
{
get { return _children; }
}

public override string ToString()
{
return string.Format("Id:{0},ParentID:{1},Text:{2}", this.Id, this.ParentId, this.Text);
}

And the code for insertion of nodes, traversal and printing:

#region lambda expressions for tree traversal
public static Action<Tree, Action<Tree>> Traverse = (r, d) => r.Children.ForEach(c => { d(c); Traverse(c, d); });
public static Func<int?, Tree, Tree> Find = (id, root) =>
{
if (id == root.Id)
return root;
foreach (Tree c in root.Children)
{
Tree foundItem = Find(id, c);
if (foundItem != null)
return foundItem;
}
return null;
};
public static Func<Tree, Tree, bool> Insert = (root, gi) =>
{
Tree insertionNode = Find(gi.ParentId, root);
if (insertionNode != null)
insertionNode.Children.Add(gi);
return insertionNode != null;
};
public static Action<Tree, int> Print = (root, tab) =>
{
Console.WriteLine(string.Format("{0}{1}", new string(' ', tab), root.ToString()));
root.Children.ForEach(a => Print(a,tab+2));
};
#endregion lambda expressions for tree traversal

Here is some code for representing the tree using XML:

void LoadIntoXML(Tree rootItem)
{
XmlDocument xmlDoc = new XmlDocument();
XmlNode root = xmlDoc.AppendChild(xmlDoc.CreateElement("groups"));
Tree.GenerateXML(xmlDoc, root, rootItem);

StringWriter sw = new StringWriter();
XmlTextWriter writer = new XmlTextWriter(sw);
writer.Formatting = Formatting.Indented;
xmlDoc.WriteTo(writer);

Console.WriteLine(sw.ToString());

}
static void GenerateXML(XmlDocument xmlDocument, XmlNode xmlNode, Tree giNode)
{
if (!giNode.IsRoot)
{
XmlElement element = CreateGIElement(xmlDocument, giNode);
xmlNode = xmlNode.AppendChild(element);

if (!giNode.IsLeaf)
{
element = xmlDocument.CreateElement("children");
xmlNode = xmlNode.AppendChild(element);
}
}
foreach (Tree childGi in giNode.Children)
{
GenerateXML(xmlDocument, xmlNode, childGi);
}
}
static XmlElement CreateGIElement(XmlDocument xmlDocument, Tree giNode)
{
XmlElement element = xmlDocument.CreateElement("group");
element.SetAttribute("group", giNode.Id.ToString());
element.SetAttribute("parentId", giNode.ParentId.ToString());
element.SetAttribute("groupName", giNode.Text);
return element;
}

--------------

Here is some sample data (id, parentId, text, where if parentId is empty, then it is the root node):

1,,Group 1
2,1,Group 2
3,1,Group 3
4,2,Group 4
5,,Group 5
6,4,Group 6
7,5,Group 7

And the same data represented as XML using the above code:

<groups>
<group group="1" parentId="" groupName="Group 1">
<children>
<group group="2" parentId="1" groupName="Group 2">
<children>
<group group="4" parentId="2" groupName="Group 4">
<children>
<group group="6" parentId="4" groupName="Group 6" />
</children>
</group>
</children>
</group>
<group group="3" parentId="1" groupName="Group 3" />
</children>
</group>
<group group="5" parentId="" groupName="Group 5">
<children>
<group group="7" parentId="5" groupName="Group 7" />
</children>
</group>
</groups>

The Making of StreetSide in Bing Maps

The Making of StreetSide in Bing Maps

Get Microsoft Silverlight

Win 7 Taskbar Shortcuts

via LifeHacker: http://lifehacker.com/5532578/the-power-users-guide-to-the-windows-7-taskbar

  • Win+number (1-9): Starts the application pinned to the taskbar in that position, or switches to that program.
  • Shift+Win+number (1-9): Starts a new instance of the application pinned to the taskbar in that position.
  • Ctrl+Win+number (1-9): Cycles through open windows for the application pinned to the taskbar in that position.
  • Alt+Win+number (1-9): Opens the Jump List for the application pinned to the taskbar.
  • Win+T: Focus and scroll through items on the taskbar.
  • Win+B: Focuses the System Tray icons.
  • Drag+Drop taskbar buttons or System Tray icons: to reorganize them.
  • Shift+Click on a taskbar button: Open a program or quickly open another instance of a program.
  • Ctrl+Shift+Click on a taskbar button: Open a program as an administrator.
  • Shift+Right-click on a taskbar button: Show the window menu for the program (like XP does).
  • Shift+Right-click on a grouped taskbar button: Show the window menu for the group.
  • Ctrl+Click on a grouped taskbar button: Cycle through the windows of the group.
  • Drag a File to a taskbar button: to pin the file to the current application's Jump List.
  • Shift+Drag a File to a taskbar button: to open a file with the current application.
  • Middle-Click on a taskbar button: to open a new instance of the application.
  • Middle-Click on a Aero Thumbnail: to close that application instance.
  • Left-Click + Drag upwards: to open the Jump List for an application.

Visual Studio 2010 – Multiple Monitors – Display weirdness

I was having crazy problems/issues with Visual Studio 2010 and multiple monitors. Intelisense would not show up on the secondary monitor. Code would suddenly disappear. Detaching a window on the main monitor and then moving it to the secondary monitor would cause the detached window to permanently disappear.

It was getting to be very annoying.

Found a fix, which looks to me that the cause has something to do with VS2010 and support for my laptop’s display adapter.

Go to Tools –> Options –> General. Disable hardware acceleration.

image

Sample User Story - Scrum

User Stories are an important component of any Agile project. Here is a sample one (from the agile alliance):

Title: Search for providers by provider specialty.
Description:

As a provider search user, I need the ability to search for providers by specialty so that I can more efficiently refer patients to specialists.
Acceptance criteria:
The provider search mechanism has the ability to enter a specialty.
The specialty search will have a list of provider specialties from which to select.
Searching via the provider specialty will return a list of matching specialists or a message indicating that there are no matches.
If there are more results than can fit on one page, the system will provide the capability to view the list in pages or sections.

Tuesday, May 04, 2010

Entity Framework: Inserting objects with parent/child relationships

Test model:
image

Code to add a person object and associated addresses:

using (Model1Container mctx = new Model1Container())
{
Person person = new Person();
person.Name = "Raj";

Address address1 = new Address();
address1.Line1 = "Line 1";

person.Addresses.Add(address1);

Address address2 = new Address();
address2.Line1 = "Line 2";

person.Addresses.Add(address2);

mctx.People.AddObject(person);

mctx.SaveChanges();
}

Once SaveChanges is called, all objects (person, address1, address2) will all have the updated Id values, which can be used for other purposes in your code.

Internet Explorer crashes when you open an Office document in a Sharepoint portal

Problem: IE (7 and 8) crash when you try and open an Office document (word, excel, etc) that is part of a document library in a Sharepoint portal/site.

Fix:

- Check your MS office installation folder (typically: C:\Program Files\Microsoft Office)

- If you have 2 Office folders (named OfficeVersionNumber: Office11, Office12), then you probably have the same problem as me.

Basically there are 2 versions of Office on your machine and the version that is causing a conflict for IE when it tries to load the Office document from the Sharepoint site.

The specific DLL the conflict arises in is called “OWSSUPP.DLL”

- In my case we have Office 2003, so it should use the OWSSUPP.DLL in the Office11 folder, so all I had to do was rename the OWSSUPP.DLL to OWSSUPP.bak in the Office12 folder.
Once that was done – everything started working properly.

Sunday, May 02, 2010

C# – Useful generic delegates

Useful generic delegates, especially when you are working with lambda expressions.

Action<T> Delegate:

public delegate void Action<in T>(T obj)

Predicate<T> Delegate:

public delegate bool Predicate<in T>(T obj)

Func<T, TResult> Delegate:

public delegate TResult Func<in T, out TResult>(T arg)

Comparison<T> Delegate:

public delegate int Comparison<in T>(T x,T y)

Converter<TInput, TOutput> Delegate:

public delegate TOutput Converter<in TInput, out TOutput>(TInput input)

EventHandler<TEventArgs> Delegate:

public delegate void EventHandler<TEventArgs>(Object sender,TEventArgs e) where TEventArgs : EventArgs

VS2010 – New Feature – Searching/Navigation

Incremental Search: Find as you type in the current file

To enter incremental search mode: CTRL + I

Begin typing

To find next occurrence: F3

Navigate To: Find occurrences across all files. The new feature is that the navigate to dialog allows you find methods, files, etc using pascal casing, i.e., find “ClickMeButton_Click” by just typing CMBC.

To bring up the dialog: CTRL + ,

And if you dont already know:

CTRL + F: Find in current file

CTRL + SHIFT + F: Find in solution

VS 2010 New Feature – Multi Line Editing

This feature allows you to edit multiple lines in one go. Why? ever wanted to change the access on multiple class members (eg: private to public).

Basically you hold down the ALT key and drag a selection rectangle in front of the lines where you want the edits to appear and then start typing. Though this is hard, especially when you are working on your laptop.

So instead, use the shortcut key ALT+SHIFT+(down or up arrow key) to create the selection rectangle (in the red circle) and then start typing

image  image

Saturday, May 01, 2010

Hello World – Windows Phone 7

image

Loading an image in SilverLight at run-time.

Drag an image control onto the design surface. Call it SampleImage.

if (Uri.IsWellFormedUriString(UrlTextBox.Text, UriKind.RelativeOrAbsolute))
{
BitmapImage bi = new BitmapImage();
bi.UriSource = new Uri(UrlTextBox.Text, UriKind.RelativeOrAbsolute);
SampleImage.Source = bi;
}

And here is a sample URL that you can use: http://bit.ly/dp9R26 (links to the Windows phone image shown above).