DAVIDEVANS.COM
 PHOTO GALLERIES FOR THE EVANS FAMILY ON THE WEB SINCE 1995
Sunday 05
September 2010
Sign In
Blog Recent Blog Entries
Monday 09 August 2010   
Family
Tegwen and Tess - Southern Belles in Goldfield, AZ


Left-to-Right: Tess, Tegwen
Goldfield, AZ
Sunday August 8th, 2010


Thursday 05 August 2010   
.NET Software Development
Team Foundation Server (TFS)
Attention all Visual Studio developers!

I must be a creature of habit.  I have spent the last 5+ years living every work day inside Visual Source Safe.  Although I have upgraded every version of Visual Studio at the first possible opportunity I have avoided changing my source control behaviour.  Simply because the one time I tried Ankh/Tortoise and that open source garbage I came unglued.

Well thank you Microsoft.  Finally I have upgraded to TFS - Team Foundation Server.  I cannot explain it - but everything is fast, smooth, and I am flying through edits like never before.  VS 2010 is responsive and all my previous gripes about it have vanished. 

I never realized that VSS was the source (forgive the pun) of so many problems.

It's a whole new day with TFS.  If anyone reads this and cares... go for it. And if you come unglued with TFS, email me and I'll try and help.  I believe in it that much.

Cheers, David

Thursday 15 July 2010   
Family
Happy Birthday Tegwen!

Wednesday 12 May 2010   
Family
Leah Graduates from NYU! Class of 2010






Wednesday 05 May 2010   
Family
Happy Birthday Leah!

Thursday 25 March 2010   
Family
Tegwen's Team Wins Lacrosse Championship


Congratulations Tegwen!
Tegwen's Lacrosse Team won the Tr-State Lacrosse Winter League North Middle School title at Turf City in Wayne, NJ last month.
I'm so proud!
Love you Tegwen, Dad xx


Saturday 20 March 2010   
In The News
Large Hadron Collider Squishes 3 Mosquitos


The Large Hadron Collider is now the world's most powerful particle accelerator, several times over.  The Swiss are a happy bunch of folks in white suits (scientists not insane asylum inmates) to be sure.

The news wires are chattering about this enormous number - getting beams to 3.5 TeV - as a testimony to their outstanding skill and mankinds latest triumph.

Piffle.

That's right, piffle.

We often talk big numbers (like when we talk about the US deficit) in billions and trillions and think we're so clever.  But why am I not impressed with this gigantic 3.5 TeV number?

Well, first, do you know what even 1 eV is?  What is an electron volt?  It's the amount of energy it takes to accelerate one lonely electron through an electric potential of one volt.  In other words, 1 eV = 1.602 x 10^-19 J.  (J = Joules)

So, ok, still getting excited about that 3.5 TeV?  Well what's the T tell us? That is a million million times... so 3.5 TeV = 3,500,000,000,000 eV. 

To put this in perspective, that's about the same amount of kinetic energy of three flying mosquitos.

Can you believe that the cost of the Large Hadron Collider and its 10,000 scientists and engineers, plus the energy (and polution) and all that construction have amounted to $4.6 billion?

All to throw light beams together equivalent to squishing 3 mosquitos.

I'm not impressed. In fact, this is a pitiful waste of time and money.

Wednesday 17 February 2010   
.NET Software Development
Using Reflection to DeDupe object arrays

Hi,

Here's a handy bit of code that I developed, with some help from my friend Bill O'Toole, to dedupe various object arrays using Reflection.

Cheers, D

        public class DupeChecks

        {

                public class DupeChecksStrings

                {

                        private List<string> _dupeChecks;

                        private bool _ignoreCase;

                        public bool IgnoreCase

                        {

                                get { return _ignoreCase; }

                                set { _ignoreCase = value; }

                        }

                        public DupeChecksStrings()

                        {

                                _dupeChecks = new List<string>();

                                _ignoreCase = true;

                        }

                        public bool Has(string str)

                        {

                                bool rv = false;

                                foreach (string _dupeCheck in _dupeChecks)

                                {

                                        if (_ignoreCase)

                                        {

                                                if (_dupeCheck.ToLower() == str.ToLower())

                                                {

                                                        rv = true;

                                                }

                                        }

                                        else

                                        {

                                                if (_dupeCheck == str)

                                                {

                                                        rv = true;

                                                }

                                        }

                                }

 

                                if (!rv)

                                {

                                        _dupeChecks.Add(str);

                                }

 

                                return rv;

                        }

                }

                public class DupeChecksInts

                {

                        private List<int> _dupeChecks;

                        public DupeChecksInts()

                        {

                                _dupeChecks = new List<int>();

                        }

                        public bool Has(int i)

                        {

                                bool rv = false;

                                foreach (int _dupeCheck in _dupeChecks)

                                {

                                        if (_dupeCheck == i)

                                        {

                                                rv = true;

                                        }

                                }

 

                                if (!rv)

                                {

                                        _dupeChecks.Add(i);

                                }

 

                                return rv;

                        }

                }

                public class ByObject

                {

                        private List<object> store;

                        public ByObject()

                        {

                                store = new List<object>();

                        }

                        public List<object> DeDupe(List<object> source, string propertyName)

                        {

                                if (source.Count > 0)

                                {

                                        Type type = source[0].GetType();

                                        PropertyInfo[] sourceProperties = type.GetProperties();

                                        bool foundProperty = false;

                                        foreach (PropertyInfo sourceProperty in sourceProperties)

                                        {

                                                if (sourceProperty.Name == propertyName)

                                                {

                                                        foundProperty = true;

                                                }

                                        }

                                        if (foundProperty)

                                        {

                                                foreach (object obj in source)

                                                {

                                                        if (!StoreHas(obj, propertyName))

                                                        {

                                                                store.Add(obj);

                                                        }

                                                }

                                        }

                                }

                                return store;

                        }

                        private bool StoreHas(object item, string propertyName)

                        {

                                bool rv = false;

 

                                Type itemType = item.GetType();

                                PropertyInfo[] itemPIs = itemType.GetProperties();

 

                                foreach (object obj in store)

                                {

                                        Type storeType = obj.GetType();

                                        foreach (PropertyInfo storePI in storeType.GetProperties())

                                        {

                                                if (storePI.Name == propertyName)

                                                {

                                                        foreach (PropertyInfo itemPI in itemPIs)

                                                        {

                                                                if (itemPI.Name == propertyName)

                                                                {

                                                                        if (itemPI.GetValue(item, null).ToString() == storePI.GetValue(obj, null).ToString())

                                                                        {

                                                                                rv = true;

                                                                        }

                                                                }

                                                        }

                                                }

                                        }

                                }

 

                                return rv;

                        }

                }

        }


Tuesday 09 February 2010   
Faith
First Things First - Brenda & Kurt Warner

Hi,

One of the best books I've read in ages! Brenda & Kurt Warner do a wonderful job of tag-teaming the writing and share their daily lives and "rules" of the house. Great for faith-building your family and marriage.



Cheers, D

Friday 05 February 2010   
3D Computer Animation
Pluto - Computers Have Great Imaginations

Hi,

I saw this article about Pluto.  If you read the details (after the hype) they say this:



<<
To build the new portraits of Pluto, Buie's team gathered 384 Hubble images of the dwarf planet between 2002 and 2003. But in each image, Pluto appears only as a tiny dot of light. So the team employed a technique called “dithering” to generate images slightly offset from each other. The individual images emerged after seven years of processing on 20 homemade computers running in parallel.
>>

Dithering? Dithering?

Dithering = Noise (Random) = We have no idea what Pluto looks like.

Question: if we can't see one of our own planets properly, how the heck should we believe anything we "see" that's billions of light years away. 

45 year old men in white lab coats with PhD's should not be taken too seriously.  Some of them, for example, are bankers.

Cheers, D

Sunday 31 January 2010   
.NET Software Development
C# .NET Google Maps Latitude Longitude


Hi,

This is a handy little bit of C# that will help you convert an address into a Latitude and Longitude using hte Google Maps API.

Cheers, D     

public class Address

      {

            public static string googleMapsAPIKey = "";

            public string Street = "";

            public string City = "";

            public string State = "";

            public string Zip = "";

            public string Country = "";

            public float Latitude = 0.0F;

            public float Longitude = 0.0F;

            public string Status = "";

            public int StatusCode = 0;

 

            public Address()

            {

                  googleMapsAPIKey = ConfigurationManager.AppSettings["MyGoogleMapsAPIKey"];

                  Street = "";

                  City = "";

                  State = "";

                  Zip = "";

                  Country = "";

                  Latitude = 0.0F;

                  Longitude = 0.0F;

                  Status = "";

                  StatusCode = 0;

            }

 

            override public string ToString()

            {

                  string rv = Street + " " + City + " " + State + " " + Zip + " " + Country;

 

                  return rv;

            }

            public static Address EncodeLatLong(string location)

            {

                  googleMapsAPIKey = ConfigurationManager.AppSettings["MyGoogleMapsAPIKey "];

                  Address oAddress = new Address();

 

                  string urlStart = "http://maps.google.com/maps/geo?q=";

                  string urlMiddle = Uri.EscapeDataString(location);

                  string urlEnd = "&output=csv&key=" + googleMapsAPIKey;

                  string url = urlStart + urlMiddle + urlEnd;

 

                  try

                  {

                        HttpWebRequest HttpWReq = (HttpWebRequest)WebRequest.Create(url);

                        HttpWebResponse HttpWResp = (HttpWebResponse)HttpWReq.GetResponse();

                        Stream stream = HttpWResp.GetResponseStream();

                        StreamReader sr = new StreamReader(stream, Encoding.UTF8);

                        string response = sr.ReadToEnd();

                        string[] pieces = response.Split(',');

 

                        if (pieces.Length == 4)

                        {

                              try { oAddress.StatusCode = int.Parse(pieces[0]); }

                              catch { }

                              try { oAddress.Latitude = float.Parse(pieces[2]); }

                              catch { }

                              try { oAddress.Longitude = float.Parse(pieces[3]); }

                              catch { }

                        }

                  }

                  catch { }

 

                  return oAddress;

            }

      }


Sunday 24 January 2010   
Business
mPower

Hi,

We've been working hard on mPower - the best Personal Financial Management system you could want.  Not only can you access and budget with all you accounts in one place, but we give you tools to reduce credit card debt, accelerate your mortgage and give you your credit score and credit report, every month.

You should check it out for FREE for 7-days.  After that, it's only $19.95 per month.

Cheers, David


Tuesday 19 January 2010   
Silverlight
Telerik RadMediaPlayer

Hi,

I recently had the opportunity to use Telerik's RadMediaPlayer control for Silverlight and ASP.NET applications.  Talk about easy.  In just a few lines of code, I could call a .wmv file and have an elegant UI for the streaming video (which you can see in action here).

Here's the XAML code:

<UserControl x:Class="radVideoTest.MainPage"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

            xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.MediaPlayer"

    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">

  <Grid x:Name="LayoutRoot">

            <telerik:RadMediaPlayer Width="720" Height="480">

                  <telerik:RadMediaItem Source="http://www.davidevans.com/userfiles/video/4thLaw.wmv"

                        ImageSource="http://www.davidevans.com/userfiles/video/4thLaw.jpg" Title="'4th Robot Law', by David Evans (3:17)">

                  </telerik:RadMediaItem>

            </telerik:RadMediaPlayer>

  </Grid>

</UserControl>


After you compile the XAML app you get a .xap file which you add to your project in a ClientBin directory.  Along with some other basics you then simply plop the object on the page like this:

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">

              <param name="source" value="ClientBin/radVideoTest.xap"/>

              <param name="onError" value="onSilverlightError" />

              <param name="background" value="white" />

              <param name="minRuntimeVersion" value="3.0.40818.0" />

              <param name="autoUpgrade" value="true" />

              <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40818.0" style="text-decoration:none">

                    <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/>

              </a>

          </object>


Couldn't be cleaner.

 

 

By the way, I just love that you can write XAML apps using C# .NET code behind.  You can't do that in Adobe Flash.

Cheers, D

 

 

 


Saturday 16 January 2010   
NFL
Thanks for a great year, Kurt
Kurt Warner Well, we sort of new it was likely to happen. No one really gave the Arizona Cardinals the edge over the Saints for today's game. January 16th, 2010 at "the Dome" in New Orleans was a pretty tough day for the Cards, but Kurt and team gave us another great year. They played better than last year, but didn't go as far (didn't make it to the Superbowl) - go figure. But I can't wait to see how things gear up for next year.

Thanks Kurt, for a great year... I hope you come back for the next one.

Cheers, D

Friday 15 January 2010   
.NET Software Development
Image Resize in C# .NET
Here's a handy way to resize an image - perhaps one uploaded through a web site. It's good for making thumbnails as well. Make sure you use Server.MapPath to get the fully resolved fullFileNames. Make sure your web site has permission to read/write to the path.

protected void ResizeImageOverwrite(string fullFileNameSource, 
    string fullFileNameDest, int newHeightMax, int newWidthMax)

      {

            try

            {

                  FileStream fs = new FileStream(fullFileNameSource, 
                    FileMode
.Open, FileAccess.Read, FileShare.Read);

                  System.Drawing.Image 
                    newImage = System.Drawing.Image.FromStream(fs);

                  int fileWidth = newImage.Width;

                  int fileHeight = newImage.Height;

                  fs.Close();

                  fs = null;

 

                  float ratio = 1.0F;

                  try

                  {

                        ratio = (float)fileWidth / (float)fileHeight;

 

                        int newHeight = newHeightMax;

                        int newWidth = 
                            Convert.ToInt32((double)newHeightMax * ratio);

                        if (newWidth > newWidthMax)

                        {

                              newWidth = newWidthMax;

                              newHeight = 
                                   Convert.ToInt32((double)newWidthMax / ratio);

                        }

 

                        Bitmap bitmap = 
                            new Bitmap(newImage, newWidth, newHeight);

                        bitmap.Save(fullFileNameDest);

                  }

                  catch { }

            }

            catch { }

      }


Monday 11 January 2010   
College Football
Roll Tide

TUSCALOOSA, Ala. – Alabama junior linebacker Rolando McClain announced Monday that he would enter the 2010 NFL Draft. The Butkus Award winner was a 2009 team captain and led the Crimson Tide in total tackles in each of the last two seasons.

McClain was a unanimous first-team All-American this season and started at linebacker for Alabama the last three years. The Decatur, Ala. native is just the second Crimson Tide player to win the Butkus Award, joining Derrick Thomas (1988).

Quote from Head Coach Nick Saban
“Rolando McClain has been as great an ambassador for the University of Alabama probably as anyone ever has in terms of how he’s represented himself, his family, the university, the state of Alabama and our team. That’s not only in terms of being a great football player – probably the best defensive football player in the country, in my opinion, or one of them, and certainly at his position – but he always did things right. He’s done a great job academically. His leadership had as much impact on our team and our team’s success since he’s been here in the last three years – even in his freshman year – as anyone that I’ve ever been associated with. And we appreciate that.


Saturday 09 January 2010   
Family
Happy Birthday Holly!

Hi,

January is a great birthday month.  Happy Birthday to you Holly, Debbie (Christy's Mom) and David (me). 

Here's one of my favorite pics of Holly... Happy Birthday Holly! Papi loves you! xxx


Tuesday 05 January 2010   
Computers
SSD Awesomeness
   You may have seen that video on YouTube from the Samsung marketing folks in the UK where they hook up 24 SSD's to make a super-fast computer.  Well, on a lesser budget I bought 5 Crucial Extreme 64GB SSD's and plopped them onto my EVGA motherboard. Using only the built-in RAID 0 for a striped array I am getting 650MB/s throughput.  That's 35% of the Samsung's demo for about, well, 10% of the cost.  Pretty pleased with it.

Cheers, D

Friday 01 January 2010   
Uncategorized
Welcome to David Evans

Hi and welcome,

I'm not the greatest fan of Blogs.  There are too many, and for the most part they're dumb.  My goal here is not to write elqoquent prose nor rant.  My goal here is to collect and share a lot of useful .NET code snippets to help out anyone learning how to build web sites on the Microsoft frameworks of today.

Feedback always welcome.

Cheers, D