Origin of "Left" and "Right"

by Mark 20. April 2012 09:19

(This was sent to me in an email from a friend... and it made since to me!)

I have often wondered why it is that Conservatives are called the "right" and Liberals are called the "left."

By chance I stumbled upon this verse in the Bible:

 

"The heart of the wise inclines to the right, but the heart of the fool to the left."
Ecclesiastes 10:2 (NIV)

Thus sayeth the Lord. Amen.

Can't get any simpler than that.

Knockout JavaScript library

by Mark 3. August 2011 15:28

Probably should think about putting this into your web developers toolbox... especialy if you like the MVVM pattern. 

http://knockoutjs.com

 

Here's the description from their website:

Knockout is a JavaScript library that helps you to create rich, responsive display and editor user interfaces with a clean underlying data model. Any time you have sections of UI that update dynamically (e.g., changing depending on the user’s actions or when an external data source changes), KO can help you implement it more simply and maintainably.

How To Sort An ObservableCollection(Of T) In Silverlight

by Mark 11. May 2011 07:12
Found this post elsewhere.  It needs to be converted to C#, but never the less I thought it was useful to keep around.
 
The ObservableCollection(Of T) doesn’t provide a simple sorting mechanism. One can use the OrderBy method but trying this I ended up in a mess of code. As I started I had a simple class for my Data objects called Debitor:
Imports System.ComponentModel

Public Class Debitor

#Region " Contructors "

     Sub New()
          ' nix tun
     End Sub


     Public Sub New(ByVal name As String)
          Me._name = name
     End Sub

#End Region

#Region " Private Fields "

     Private _name As String

#End Region

#Region " ReadOnly Properties "

     Public ReadOnly Property Name() As String
          Get
               Return _name
          End Get
     End Property

#End Region


End Class
 
In MainPage I build an ObservableCollection(Of Debitor):
<UserControl.Resources>
<local:Debitor x:Key="DebitorDataSource"
d:IsDataSource="True" />
</UserControl.Resources>

<Grid x:Name="LayoutRoot"
Background="White"
DataContext="{Binding Source={StaticResource DebitorDataSource}}">
<ListBox x:Name="lbDebitors"
Margin="115,115,77,151"
IsSynchronizedWithCurrentItem="False"
ItemsSource="{Binding Name, Mode=OneWay}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Private Sub MainPage_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
     lbDebitors.ItemsSource = DebitorOC
End Sub
Everything was fine. But the problem was, that I wanted the Listbox to show the Items sorted. After trying different things I finally found a solution with five lines of code. Here it is:
Private Sub SortObservableCollection()
     Dim ied As IEnumerable(Of Debitor) = From d In DebitorOC Order By (d.Name)
     For Each i In ied
          DebitorOC.Remove(i)
          DebitorOC.Add(i)
     Next
End Sub
And this is how it works:
I declare an IEnumerable(Of Debitor) to which I set the result of a LINQ query that is using the Order By clause:
Dim ied As IEnumerable(Of Debitor) = _
From d In DebitorOC Order By (d.Name)
The result is a sorted IEnumerable(Of Debitor). But to cast the IEnumerable(Of Debitor) to an ObservableCollection(Of Debitor) doesn’t work. I could set the IEnumerable(Of Debitor) ied as the ItemsSource of my Listbox to display sorted items but I didn’t want to touch my Data Binding. That’s where it getting tricky:
For Each i In ied
     DebitorOC.Remove(i)
     DebitorOC.Add(i)
Next
The above code is holding the working item in the variable i, round by round it removes the item out of the ObservableCollection(Of Debitor) and instantly adds it again at the end. The result is a sorted ObservableCollection(Of Debitor). That’s it.
Download SampleProject
Best regards,
M. (SilverLaw)

StyleCop

by Mark 26. April 2011 07:01

Download the latest 4.5RC build from: http://stylecop.codeplex.com/4.5 RC


Project Description

StyleCop analyzes C# source code to enforce a set of style and consistency rules. It can be run from inside of Visual Studio or integrated into an MSBuild project. StyleCop has also been integrated into many third-party development tools.

Core Principles

  • StyleCop provides value by enforcing a common set of style rules for C# code. StyleCop will continue to ship with a single, consistent set of rules, with minimal rule configuration allowed. Developers can implement their own rules if they so choose.
  • StyleCop ships with the ability to seamlessly integrate with Visual Studio, MSBuild, TFS, etc. Developers are free to implement custom code to integrate StyleCop into other development and tooling environments, as described in the SDK documentation.

 

jQuery - Selecting ASP.NET Controls by ID

by Mark 26. February 2010 15:43

Selecting the control based on its ID can be difficult with ASP.NET Controls and even more so with those nested within Master Pages. There very well could be other selection methods that work as good or better, but this one works well for me.

Example:

$(“input[ID$=’_txtFirstName’]").xxx

 

How to enable jQuery intellisense in Visual Studio 2008?

by Mark 24. November 2009 08:45

I recently had some headaches with regards to getting jQuery intellisense working properly within Visual Studio 2008 (sp1).  If I included the "jquery-1.3.2-vsdoc2.js" file in my page directly, intellisense worked great.  However, as reported elsewhere in other blogs, you're suppose to only need the "*-vsdoc.js" file in the same folder, and Visual Studio 'automagically' knows it's there and provides the intellisense.  Not so for me, at least at first (read on).  Then, to add more frustration to the mix, when I would add in the UI library ("jquery-ui-1.7.2.custom.min.js" in my case), then intellisense would completely stop working (for jQuery).  After searching for a solution for this new problem, someone suggested that you place an empty "*-vsdoc.js" file in the same folder as the jQuery UI file.  So, in my case that would be "jquery-ui-1.7.2.custom.min-vsdoc.js".  Easy enough, but no joy.  Did not work for me.  

In the end, what finally worked was to rename the .js files to the following shorter versions:

jquery.js

jquery-vsdoc.js

jquery-ui.min.js

jquery-ui.min-vsdoc.js

 

Then, all worked as expected.  Below is some helpful information I found on another blog - and felt that re-posting it here might be helpful to you...

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

As we all know, visual studio 2008 already support JavaScript intellisense. To extend its intellisense support for jQuery, Microsoft released a patch KB958502 for visual studio 2008 with SP1.

 

Apart from providing jQuery intellisense, it will also add intellisense support to all the JavaScript files that we add to our solution. For example: if we have a JavaScript file called "CDvalidations.js", this new patch will look for its corresponding XML documentation file with "-vsdoc.js" appended to its name in the same folder to provide intellisense, in our case it will be CDvalidations-vsdoc.js.  We can have all the documentation in XML format in these doc files which will be displayed with the intellisense.

 

Download the xml documentation file for JQuery from here. Place the file in the same location where jQuery library is added.

 

To summarize the above points,

1.      Download jQuery library from jQuery official website here.

2.      Install the hotfix KB958502 for your Visual studio 2008 SP1. If you don't have SP1 installed already, you can download it from here.

3.      Download the jQuery doc file from here. Include this file in the same folder where jQuery library is present.

 

Entity Framework Series - how-to video series

by Mark 6. October 2009 13:17

“How Do I?” Videos — Data Platform Development

how-to video series is focused on the new ADO.NET Entity Framework.

 

http://msdn.microsoft.com/en-us/data/cc300162.aspx#entity

Gangster Government

by Mark 3. July 2009 10:31

You Tube: http://www.youtube.com/watch?v=thR-lVuztIY 

Rep. Michele Bachmann (R-Minn.) speaking on the House floor about the government take over of General Motors (now "Government Motors"): Now we have moved into the realm of 'gangster government'. We have gangster government when the Federal Government has set up a new cartel and private businesses now have to go begging with their hand out to their localhopefully well politically connected Congressman or their Senator so they can buy a peace offering for that local business. Is that the kind of country we are going to have in the future?