tag:blogger.com,1999:blog-65937900938331378942024-03-18T21:48:38.473-07:00Doug's BlogDoug Mairhttp://www.blogger.com/profile/06172858840976577558noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-6593790093833137894.post-39100033042017197152018-12-12T22:32:00.000-08:002018-12-13T20:29:36.842-08:00Quick Introduction to C# Span.<h2>
</h2>
<div class="MsoNormal">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large; line-height: 107%;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large; line-height: 107%;"><em style="background-color: white; box-sizing: border-box; color: #515151; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif; font-size: 20px;">This post is a part of <a href="https://crosscuttingconcerns.com/The-Second-Annual-C-Advent" style="box-sizing: border-box; color: #268bd2; text-decoration-line: none;">The Second Annual C# Advent</a>. Check out many the other C# related posts there.</em></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large; line-height: 107%;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large; line-height: 107%;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large; line-height: 107%;">Span is a new C# keyword which was introduced in C#
version 7.2 on .NET Core 2.1.<span style="mso-spacerun: yes;"> </span></span><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">C# Span is used in the memory management domain. </span><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">It can be used to improve memory access performance in many scenarios.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">For those of us who also do "Html" development, don't confuse </span><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">the
“Html Span” with the C# Span.</span><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;"> They are completely different in scope and function.</span></div>
<div class="MsoNormal">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large; line-height: 107%;">Visual Studio and C# are developed in the open, so we can see
what the language designers are considering while adding new features to the C#
language.<span style="mso-spacerun: yes;"> </span></span><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large; line-height: 107%;">During the design of the C# 7
new features, Mads Torgersen wrote:</span><span style="background: white; color: #181818; font-family: "arial" , "helvetica" , sans-serif; font-size: large; line-height: 107%;"> </span></div>
<div class="MsoNormal">
<span style="background: white; color: #181818; font-family: "arial" , sans-serif; font-size: large; line-height: 107%;"><br /></span></div>
<div class="MsoNormal" style="margin-left: .5in;">
<span style="font-size: large;"><i style="mso-bidi-font-style: normal;"><span style="background: white; color: #181818; font-family: "arial" , sans-serif; line-height: 107%;">“</span></i><i style="mso-bidi-font-style: normal;"><span style="background: white; color: #24292e; font-family: "segoe ui" , sans-serif; line-height: 107%;">One
feature that could lead to a lot of efficiency would be the ability to have
"windows" into arrays - or even onto unmanaged swaths of memory
passed along through interop. The amount of copying that could be avoided in
some scenarios is probably very significant.</span></i><i style="mso-bidi-font-style: normal;"><span style="background: white; color: #181818; font-family: "arial" , sans-serif; line-height: 107%;">”<o:p></o:p></span></i></span></div>
<div class="MsoNormal" style="margin-left: .5in;">
<i style="mso-bidi-font-style: normal;"><span style="background: white; color: #181818; font-family: "arial" , sans-serif; font-size: large; line-height: 107%;"><br /></span></i></div>
<div class="MsoNormal">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large; line-height: 107%;">This “window” is what C# Span<t> enables.<span style="mso-spacerun: yes;"> </span><o:p></o:p></t></span></div>
<div class="MsoNormal">
<span style="background-color: white; color: #181818; font-family: "arial" , sans-serif; font-size: large;"><br /></span>
<span style="background-color: white; color: #181818; font-family: "arial" , sans-serif; font-size: large;">Let's look at a simple case where C# Span can help improve performance.</span><br />
<span style="background-color: white; color: #181818; font-family: "arial" , sans-serif; font-size: large;"><br /></span></div>
<h2>
<span style="background-color: white; color: #181818; font-family: "arial" , "helvetica" , sans-serif; font-size: x-large;">Example: C# Substring</span></h2>
<div>
<span style="background-color: white; color: #181818; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"></span><br />
<div class="MsoNormal" style="color: black; font-family: "Times New Roman"; font-size: medium; line-height: normal; margin: 0px 0px 0.0001pt;">
<span style="background-color: white; color: #181818; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">This code shows the typical way to get a substring from string using C#.<span style="mso-spacerun: yes;"> </span>This is great for getting a portion of a string.</span></span><br />
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr>
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><pre style="background: white; font-family: Consolas; font-size: 19px;"><ol>
<li>string fullName = <span style="color: #a31515;">"John Jacob Schmidt"</span>;</li>
<li>string middleName = fullName.Substring(5, 5);</li>
</ol>
</pre>
</td>
</tr>
</tbody></table>
<span style="background-color: white; color: #181818; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">
</span></span><br />
<div class="MsoNormal">
<br /></div>
</div>
</div>
<div class="MsoNormal">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Now, imagine that not only do we want to get the middle name, but we want to change certain letters in the <b>middleName </b>and have those changes also apply to the <b>fullName</b>. Without using Span we would have to modify both the <b>middleName </b>string and the <b>fullName </b>string separately.</span><br />
<div>
<br /></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Span<t> allocates the memory on the stack, the same way that C# Structs are created.<span style="mso-spacerun: yes;"> </span>This means the memory is contiguous and can be accessed through the window.</t></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><t></t></span></div>
<h2>
<span style="background-color: white; color: #181818; font-family: "arial" , "helvetica" , sans-serif; font-size: x-large;">Example: C# Span<t> slice</t></span></h2>
<div>
<span style="background-color: white; color: #181818; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"></span><br />
<div class="MsoNormal" style="color: black; font-family: "Times New Roman"; font-size: medium; line-height: normal; margin: 0px 0px 0.0001pt;">
</div>
<span style="background-color: white; color: #181818; font-family: "arial" , "helvetica" , sans-serif; font-size: large;">
</span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Here is similar source code, now using C# Span</span><br />
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr>
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><pre style="background: white; font-family: Consolas; font-size: 19px;"><ol>
<li>Span<<span style="color: blue;">char</span>> fullName = <span style="color: #a31515;">"John Jacob Schmidt"</span>.ToCharArray().AsSpan();</li>
<li>Span<<span style="color: blue;">char</span>> middleName = fullName.Slice(5, 5);</li>
<li> </li>
<li>middleName[2] = <span style="color: #a31515;">'k'</span>;</li>
<li> </li>
<li>Console.WriteLine(middleName.ToString()); <span style="color: green;">// Prints -> Jakob</span></li>
<li>Console.WriteLine(fullName.ToString()); <span style="color: green;">// Prints -> John Jakob Schmidt</span></li>
<li> </li>
<li>middleName[6] = <span style="color: #a31515;">'s'</span>; <span style="color: green;">// Throws Exception -> System.IndexOutOfRangeException'</span></li>
</ol>
</pre>
</td>
</tr>
</tbody></table>
<br />
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background-color: white; font-family: "arial" , "helvetica" , sans-serif; font-size: large;">On line 1 the Span is allocated. After that on line 2, a slice is created that encompasses the </span><b style="background-color: white; font-family: arial, helvetica, sans-serif; font-size: x-large;">middleName.</b><span style="background-color: white; font-family: "arial" , "helvetica" , sans-serif; font-size: large;"> </span></div>
<div style="background: white;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><br /></span></div>
<div style="background: white;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Line 4, shows changing the third letter of the <b>middleName</b> to the letter 'k'. Then the <b>middleName </b>and the <b>fullName </b>are both printed. Notice that the change to the <b>middleName </b>also affected the <b>fullName.</b></span></div>
<div style="background: white;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><b><br /></b></span></div>
<div style="background: white;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">On line 9, we see an access to the seventh character of the middle name. Since the slice was created to be only 5 characters long, an exception is thrown. So array bounds are enforced correctly</span><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">.</span></div>
<div style="background: white;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><br /></span></div>
<h2 style="background: white;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-large;">Conclusion</span></h2>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-large;"><br /></span></div>
<div style="background: white;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">This type of memory manipulation was possible before the introduction of C# Span<t>, but the code to do it was very complex and much harder to maintain. This post shows a simple way to use C# Span<t>. There are many more uses beyond the simple one shown here. For further reference look review these articles.</t></t></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><t><t><br /></t></t></span></div>
<h2 style="background: white;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-large;">C# Span<t style="background-color: transparent;"> References:</t></span></h2>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-large;"><t style="background-color: transparent;"><br /></t></span></div>
</div>
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184; width: 632px;">
<tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 116.75pt;" valign="top" width="256"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Code
Magazine:<o:p></o:p></span></div>
</td>
<td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 356.95pt;" valign="top" width="476"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><a href="https://www.codemag.com/Article/1807051/Introducing-.NET-Core-2.1-Flagship-Types-Span-T-and-Memory-T">https://www.codemag.com/Article/1807051/Introducing-.NET-Core-2.1-Flagship-Types-Span-T-and-Memory-T</a><o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 1;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 116.75pt;" valign="top" width="156"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Coding Blast
Blog:<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 356.95pt;" valign="top" width="476"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><a href="https://codingblast.com/span-of-t/">https://codingblast.com/span-of-t/</a><o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 2;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 116.75pt;" valign="top" width="156"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">MSDN Channel
9:<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 356.95pt;" valign="top" width="476"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><a href="https://channel9.msdn.com/Events/Connect/2017/T125">https://channel9.msdn.com/Events/Connect/2017/T125</a><o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 3;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 116.75pt;" valign="top" width="156"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">Mads
Torgersen:<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 356.95pt;" valign="top" width="476"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><a href="https://blogs.msdn.microsoft.com/dotnet/2018/12/05/take-c-8-0-for-a-spin/">https://blogs.msdn.microsoft.com/dotnet/2018/12/05/take-c-8-0-for-a-spin/</a><o:p></o:p></span></div>
</td>
</tr>
<tr style="mso-yfti-irow: 4; mso-yfti-lastrow: yes;">
<td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 116.75pt;" valign="top" width="156"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;">MSDN
Magazine:<o:p></o:p></span></div>
</td>
<td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 356.95pt;" valign="top" width="476"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "arial" , "helvetica" , sans-serif; font-size: large;"><a href="https://msdn.microsoft.com/en-us/magazine/mt814808.aspx">https://msdn.microsoft.com/en-us/magazine/mt814808.aspx</a><o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
<br />Doug Mairhttp://www.blogger.com/profile/06172858840976577558noreply@blogger.com0tag:blogger.com,1999:blog-6593790093833137894.post-12625557366372472702018-01-28T10:28:00.001-08:002018-01-28T10:28:13.223-08:00Recap of .NET Hands on Lab by Phil Japikse<img src="https://pbs.twimg.com/card_img/957002510182559744/I5YC33Rw?format=png&name=600x314" /><br />
<br />
I usually sleep in on Saturday mornings, but on this morning I woke at 6:30, got cleaned up and began my journy to the <b>.NET Core Hands on Lab with Phil Japikse - {Cincinnati}</b><br />
<br />
<a href="https://twitter.com/skimedic/status/944300358200905729">https://twitter.com/skimedic/status/944300358200905729</a><br />
<br />
It was presented by Phil Japikse and hosted by TechElevator (@TechElevator) and Cincinnati DotNet User Group (@cinnug).<br />
<br />
The weather was a slight rain, but the 1.5 hour drive was smooth and uneventful. The workshop started at 9:00 and I arrived at 9:02, just as Phil was introducing himself. I picked up a doughnut and water and got situated for a day of learning.<br />
<br />
Phil began by introducing .NET Core and talking about the pre-reqs for the workshop. Luckily, I have done a bit of .NET Core 2.0 and tend to keep my Visual Studio up to date, so, I didn't have to install anything in order to get started.<br />
<br />
Phil gave us the WIFI info and his workshop GitHub repo. I downloaded the zip, which included PDFs for all of the labs for the day and a completed workshop project. I won't be including any links to Phil's repos or information from the workshop, because this course is actually part of a paid educational series.<br />
<br />
Several folks were having trouble getting started, but Phil's lab assistant was able to make the rounds and get most of them up and running. Unfortunately, a couple attendees had to do a full VS download / install.<br />
<br />
The first set of labs were about getting our Models and Databases setup. The PDF's walked us through the process with minimal issues. Here's a tip: When cutting and pasting from PDF's, Microsoft Edge tends to remove line returns. Chrome handles this without an issue.<br />
<br />
The day continued on with Phil speaking for about an hour and then labs for a 1/2 hour, back and forth.<br />
<br />
Pizza lunch was at 11:30 and was right on time. It really hit the spot.<br />
<br />
I won't go into all of the details of the workshop, but I will say that it far exceeded my expectations. Before the workshop, my impression of .NET Core was that it was a lesser version of ASP.NET. Boy, did this misconception get blown away. Over the course of the workshop, Phil was able to at least introduce every major area of .NET Core. Wow, it's massive. I could easily see his training material spread out over a week or 2 week long course.<br />
<br />
The one topic, that I was concerned with, going into the lab was deployment with IIS. It was part of the workshop, but we really didn't have time to focus on it. I'll have to read through the workshop notes to get a better understanding.<br />
<br />
Towards the end of the day, Phil told us that the $5.00 we each donated to Hands Against Hunger would buy around 1000 meals for children in need. I'm glad that I could help and learn at the same time.<br />
<br />
At the end of the workshop, I thanked Phil for presenting and helping us. I said, "this should be a book". He said, it is a book and showed me the book he co-authored, which covers all of the details in depth. It's titled:<br />
<blockquote class="tr_bq">
<b>Building Web Applications with Visual Studio 2017</b><b>Using .NET Core and Modern JavaScript Frameworks</b></blockquote>
<blockquote class="tr_bq">
Here the link: <a href="https://www.apress.com/us/book/9781484224779">https://www.apress.com/us/book/9781484224779</a> or <a href="https://www.amazon.com/Building-Applications-Visual-Studio-2017/dp/1484224779/ref=sr_1_1?ie=UTF8&qid=1517163070&sr=8-1&keywords=Building+Web+Applications+with+Visual+Studio+2017+Using+.NET+Core+and+Modern+JavaScript+Frameworks">On Amazon</a></blockquote>
<blockquote class="tr_bq">
<img src="https://images.springer.com/sgw/books/medium/9781484224779.jpg" /> </blockquote>
<br />
At 4:00pm I drove back to Columbus and reflected on everything I learned over the day. When I got home, I took a nap to let my brain catch up with everything I learned that day. Later, I ordered a copy of the book.<br />
<br />
I really enjoyed the .NET Core 2.0 Hands On Lab hosted by TechElevator and Cincinnati DotNet User Group. $5 for breakfast, lunch, hands on lab, presentation and charity donation. It was time well spent.<br />
<br />
Thanks,<br />
Doug Mair<br />
<br />
<br />Doug Mairhttp://www.blogger.com/profile/06172858840976577558noreply@blogger.com0tag:blogger.com,1999:blog-6593790093833137894.post-56384863857615780402017-04-09T22:11:00.000-07:002017-04-09T22:21:49.322-07:00What's new in Visual Studio 2017 & C# 7<br />
I recently presented a session on the Visual Studio Productivity Improvements and C# 7 language changes.<br />
<br />
The slides from the presentation are here:<br />
<br />
<a class="OYKEW4D-gc-a" href="https://www.blogger.com/null" kind="click"> </a><br />
<div class="OYKEW4D-gc-f">
<a href="https://www.slideshare.net/dougmair/visual-studio-2017-product-launch">https://www.slideshare.net/dougmair/visual-studio-2017-product-launch</a><br />
<br />
<br /></div>
<br />
<iframe src="https://www.slideshare.net/dougmair/slideshelf" width="760px" height="570px" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" style="border:none;" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>
Doug Mairhttp://www.blogger.com/profile/06172858840976577558noreply@blogger.com0tag:blogger.com,1999:blog-6593790093833137894.post-70592791173412074922010-10-03T15:58:00.000-07:002010-10-03T16:09:56.428-07:00Windows Phone 7 Launch EventOn Tuesday, Octomber 12th Microsoft will be launching the new Windows Phone 7.<br /><br />You can find out more at: <a href="http://www.msdnevents.com/wp7devlaunch/">http://www.msdnevents.com/wp7devlaunch/</a><br /><br />I will be listening online. Hope you can attend a session or listen too.<br /><br /><p align="left"><img style="TEXT-ALIGN: left; MARGIN: 0px auto 10px; WIDTH: 141px; DISPLAY: block; HEIGHT: 70px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5523958786755539282" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeAFAxg-nWN0pXWN8CChuuRNooRi2_uCPVfKNnqDsV0FyvUxj8cqYEJ8t4D8wxdKqhF4kxYx13ok2Azu7Io7Cf5-ZRWeepwmS_WOt8BhP36klvBzD2w6f22GScexQOLIWi19gmq0bL3Mhw/s320/wp7_signature_banner_sm.jpg" /></p>Doug Mairhttp://www.blogger.com/profile/06172858840976577558noreply@blogger.com0tag:blogger.com,1999:blog-6593790093833137894.post-21283918242004426852010-05-13T16:10:00.000-07:002010-05-13T16:32:53.204-07:00The .NET Rocks! Visual Studio 2010 Road Trip<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR4aWufwZGa7J0UlfwcA99qPS7049_T7aA_nLgDU1inWuws_qm957BIwoS3XgjH4LEnhJreKULt_CIMQSNrJUzgYaS7dAhhyphenhyphen5PQpsixBToDMihxbp0L49SULgUNQZOwO5hyxGOZkDBRYtG/s1600/IMAG0078.jpg"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 190px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR4aWufwZGa7J0UlfwcA99qPS7049_T7aA_nLgDU1inWuws_qm957BIwoS3XgjH4LEnhJreKULt_CIMQSNrJUzgYaS7dAhhyphenhyphen5PQpsixBToDMihxbp0L49SULgUNQZOwO5hyxGOZkDBRYtG/s320/IMAG0078.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5470896845186396178" /></a><br />I saw the DotNet Rocks Roadtrip while attending the Chicago Code Camp. Carl and Richard were very entertaining. Their special guests were Rocky Lhotka and Jay Schmelzer. They all talked about VS 2010 in general and how it will affect development in the future.<br /><br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidsG8eV8txsUGSTqGDu8aGN6qDWCHHS2bSvVVdBa61CKaj7LPevkahrVemUGT8SiHsCXc7U0UOS6d02NHSk8GTIItVtyxpWyNl9MdAH_J7_okhoU9_Ebrw80hP15GIHMlg38I4QHD1bU0q/s1600/IMAG0079.jpg"><img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 320px; height: 190px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidsG8eV8txsUGSTqGDu8aGN6qDWCHHS2bSvVVdBa61CKaj7LPevkahrVemUGT8SiHsCXc7U0UOS6d02NHSk8GTIItVtyxpWyNl9MdAH_J7_okhoU9_Ebrw80hP15GIHMlg38I4QHD1bU0q/s320/IMAG0079.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5470897055877161554" /></a><br /><br />At the end of the day, Carl and Richard hosted the raffle in the 64 bit question style. It was a blast!!. Unfortunately for me, the conference ran out of raffle tickets before I could get one. Some people had multiple raffle tickets while a few of us didn't get one. It was fun despite that.<br /><br /><br />The sessions I attended at the code camp were good quality, especially for a free event. I definitely wanted more intense Windows Phone 7 and Silverlight talks. I have been to several entry level Win Phone7 talks and watched all of the MIX10 Windows Phone 7 videos, but I still want more.<br /><br /><br />Thanks you DotNetRocks for your Roadtrip. I enjoyed listening to your all of the shows, and have had a fun time learning alot about VS 2010.<br /><br /><br />Thanks again,<br />Doug Mair, doug.mair@gmail.comDoug Mairhttp://www.blogger.com/profile/06172858840976577558noreply@blogger.com1tag:blogger.com,1999:blog-6593790093833137894.post-69046961552940895732008-03-29T15:26:00.001-07:002008-12-09T11:47:50.663-08:00Learning Visual Python<div align="left">This last January I went to <a href="http://www.codemash.org/">CodeMash</a> in Sandusky OH. It was a great two days of sessions and keynotes. Thanks to everyone who put it together.<br /><br />Anyway, my goal at the conference was to attend some sessions that improved my C# understanding and also to attend some sessions that would expand my overall programming experience.<br /><br />I was most impressed by the F# and Python presentations. I went to 3 seperate sessions on Python. One of them was presented by <a href="http://catherinedevlin.blogspot.com/">Catherine Devlin</a> and showed how to use <a href="http://www.vpython.org/">Visual </a>with Python to do some planetary simulations very easily.<br /><br />It looked so easy to do some pretty incredible things, so I decided to try it out for myself. Here is what I came up with.<br /><br />I made a Rubik's Cube Simulation and a Magnetic Disc simulation.<br /><br />I was able to make the Rubik's Cube into an executable using py2exe. It ended up being 40 files in all (YIKES). I then made that exe into a Windows screen saver by changing the extension to .SCR and copying all 40 files into the Windows\System32 sub directory. It's pretty neat, but kinda messy to have to copy so many files.<br /><br />Here is the source: </div><ul><p align="left"><a href="http://doug.mair.googlepages.com/pyCube.py">PyCube.py</a><br /><a href="http://doug.mair.googlepages.com/MagDisc.py">MagDisc.py</a><span style="font-family:times new roman;font-size:78%;"> I added them to <a class="tr_pseudo-link" id="tr_site-url" onclick="TR_execViewLive('');" href="http://doug.mair.googlepages.com/">http://doug.mair.googlepages.com/</a></span></p></ul><p><span style="font-family:times new roman;"><span style="font-family:lucida grande;"><span style="font-size:130%;"><strong><span style="font-family:georgia;">Descriptions of the programs:</span></strong><br /></span></span><span style="font-family:trebuchet ms;"><span style="color:#000066;">Program 1: <a href="http://doug.mair.googlepages.com/pyCube.py">PyCube.py</a> - Rubiks cube simulation.</span> </span></span><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEia0i-IAI4E5rnSmQCN19WC8bDzSTbFrjrVX2djc_QTRRdawf5ETzOt1xYPS24ocnZO4HkkFdOiTGj37VCSeSxPsesbAfPTObov6frM32azbwYEPS6bdb-GGOz1PlGMoDKe2sx1Jd82SZEe/s1600-h/Rubik+Screen+1.jpg"><img id="BLOGGER_PHOTO_ID_5183548401934952834" style="FLOAT: right; MARGIN: 0px 0px 10px 10px; WIDTH: 141px; CURSOR: hand; HEIGHT: 129px" height="244" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEia0i-IAI4E5rnSmQCN19WC8bDzSTbFrjrVX2djc_QTRRdawf5ETzOt1xYPS24ocnZO4HkkFdOiTGj37VCSeSxPsesbAfPTObov6frM32azbwYEPS6bdb-GGOz1PlGMoDKe2sx1Jd82SZEe/s320/Rubik+Screen+1.jpg" width="230" border="0" /></a> <span style="font-family:arial;"><br /></p></span><br /><blockquote><p><span style="font-family:arial;">215 lines in all!! Amazing. It works, but it probably isn't<br />very python-like. I know there has to be better Python ways to do some of what I did in this program. </span></p><p><span style="font-family:arial;">Keys: Q - Toggles Demo Mode. F - Toggles flying the camera around.<br />Click on the edges of the face pieces to make them rotate. </span></p></blockquote><span style="font-family:arial;"><p></span></p><span style="font-family:times new roman;"><span style="font-family:trebuchet ms;"><span style="color:#000099;">Program 2: <a href="http://doug.mair.googlepages.com/MagDisc.py">MagDisc.py</a> - Simulation of Magnets which are fixed on a rotating disc.</span> </span></span><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiT5sFy6u5zmYj4LJ2EuFfFmiOGoW-sOgelAxmoVFc-96Akk6SLpsoaO7rok7DjZr0Lhcs3axIZckZbS4WnuFV3G5ZEfPgIOXrbgfkp_CpCOHZ49zBSCSiZ6w5d8fRqSlstAl-A8IhCP4ZD/s1600-h/MagDisc+Screen1.jpg"><img id="BLOGGER_PHOTO_ID_5183550914490821010" style="FLOAT: right; MARGIN: 0px 0px 10px 10px; WIDTH: 150px; CURSOR: hand; HEIGHT: 123px" height="191" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiT5sFy6u5zmYj4LJ2EuFfFmiOGoW-sOgelAxmoVFc-96Akk6SLpsoaO7rok7DjZr0Lhcs3axIZckZbS4WnuFV3G5ZEfPgIOXrbgfkp_CpCOHZ49zBSCSiZ6w5d8fRqSlstAl-A8IhCP4ZD/s320/MagDisc+Screen1.jpg" width="228" border="0" /></a><span style="font-family:times new roman;"><span style="font-family:arial;"><br /><blockquote><p><span style="font-family:times new roman;"><span style="font-family:arial;">I'm studying the interactions and forces between the discs. The forces between magnets are shown as gold cylinders shooting out of the front of the magnets. </span></span></p><p><span style="font-family:times new roman;"><span style="font-family:arial;">I think my force equations are correct, but I'm having trouble converting the force between the magnets into the angular momentum of the disc. The discs also have a friction equation built into them,<br />so they should slow down and stop. They seem to work except when they are at their closest point. At which point the large disc spins out of control.</span></span></p><p><span style="font-family:times new roman;"><span style="font-family:arial;">You can drag and drop the disc to move them around. Also left/right clicking on a disc increases it's speed clockwise or counter-clockwise. It's only 150 lines so far. WOW.<br /></span></span></span></span><span style="font-family:times new roman;"><span style="font-family:arial;"></p></blockquote></span></span>Doug Mairhttp://www.blogger.com/profile/06172858840976577558noreply@blogger.com0