<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>pete and repete</title>
	<atom:link href="http://peternewhook.com/feed" rel="self" type="application/rss+xml" />
	<link>http://peternewhook.com</link>
	<description>a place for my stuff</description>
	<lastBuildDate>Mon, 06 Feb 2012 15:37:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>What Are My Tweeps Using?</title>
		<link>http://peternewhook.com/2012/02/what-are-my-tweeps-using/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=what-are-my-tweeps-using</link>
		<comments>http://peternewhook.com/2012/02/what-are-my-tweeps-using/#comments</comments>
		<pubDate>Sun, 05 Feb 2012 20:05:34 +0000</pubDate>
		<dc:creator>Peter Newhook</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[DevTO]]></category>
		<category><![CDATA[I can't believe I spent a Saturday night doing this]]></category>
		<category><![CDATA[I'm going to die alone]]></category>
		<category><![CDATA[Ladies Learning Code]]></category>
		<category><![CDATA[Pie]]></category>
		<category><![CDATA[Pie Charts]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://peternewhook.com/?p=416</guid>
		<description><![CDATA[Have you ever wondered what Twitter client was the most popular for a given hash tag? I did. Now I have pie charts.]]></description>
			<content:encoded><![CDATA[<p>We often find similarities in those we keep near to us. I like to be around runners and geeks. Maybe you think we get along because we&#8217;re both Aries. There&#8217;s always that commonality that bonds people. Up until recently I thought there was another indicator of a simpatico relationship: smart phone choice.</p>
<p>I&#8217;ve spent a fair bit of time over the last month working with the good people of <a title="DevTO" href="http://devto.ca/">DevTO </a>and <a title="Ladies Learning Code" href="http://ladieslearningcode.com/">Ladies Learning Code</a>, two tech groups that make Toronto more amazing every day. And with most other tech focused crowds, they tweet. A lot. I always felt a certain kinship with those two groups, and assumed their client of choice was similar to my own Android.</p>
<p>Evidently, I was wrong.</p>
<p>I put together a little R script that queries the Twitter search API and spits out a pie chart and a table summarizing clients used. You can find the script in<a title="GitHub Gist of my R function" href="https://gist.github.com/1747724"> this Gist</a>, I won&#8217;t go into it here, it&#8217;s nothing special. The pie chart shows the top 10 most popular clients, the table lists everything.</p>
<h2>DevTO</h2>
<p style="text-align: center;"><a href="http://peternewhook.com/wp-content/uploads/2012/02/devtopie.jpg"><img class="size-full wp-image-420 aligncenter" title="devtopie" src="http://peternewhook.com/wp-content/uploads/2012/02/devtopie.jpg" alt="DevTO Twitter Client Pie Chart" width="517" height="411" /></a></p>
<table width="292" border="0" cellspacing="0" cellpadding="0">
<colgroup>
<col width="228" />
<col width="64" /> </colgroup>
<tbody>
<tr>
<td width="228" height="20">Client</td>
<td width="64">Freq</td>
</tr>
<tr>
<td height="20">        Twitter for iPhone</td>
<td align="right">168</td>
</tr>
<tr>
<td height="20">                       web</td>
<td align="right">93</td>
</tr>
<tr>
<td height="20">                 HootSuite</td>
<td align="right">63</td>
</tr>
<tr>
<td height="20">                 TweetDeck</td>
<td align="right">48</td>
</tr>
<tr>
<td height="20">       Twitter for Android</td>
<td align="right">25</td>
</tr>
<tr>
<td height="20">       Tweetbot for iPhone</td>
<td align="right">18</td>
</tr>
<tr>
<td height="20">           Twitter for Mac</td>
<td align="right">11</td>
</tr>
<tr>
<td height="20">   TweetCaster for Android</td>
<td align="right">9</td>
</tr>
<tr>
<td height="20">                 instagram</td>
<td align="right">7</td>
</tr>
<tr>
<td height="20">             Camera on iOS</td>
<td align="right">6</td>
</tr>
<tr>
<td height="20">                foursquare</td>
<td align="right">6</td>
</tr>
<tr>
<td height="20">       PlumeÂ forÂ Android</td>
<td align="right">6</td>
</tr>
<tr>
<td height="20">                  Path 2.0</td>
<td align="right">5</td>
</tr>
<tr>
<td height="20">          Twitter for iPad</td>
<td align="right">5</td>
</tr>
<tr>
<td height="20">                    Digsby</td>
<td align="right">4</td>
</tr>
<tr>
<td height="20">              Tweet Button</td>
<td align="right">4</td>
</tr>
<tr>
<td height="20">                   Twitpic</td>
<td align="right">4</td>
</tr>
<tr>
<td height="20">                   Echofon</td>
<td align="right">3</td>
</tr>
<tr>
<td height="20">                  Facebook</td>
<td align="right">3</td>
</tr>
<tr>
<td height="20">ÃœberSocial for BlackBerry</td>
<td align="right">2</td>
</tr>
<tr>
<td height="20">                   Seesmic</td>
<td align="right">2</td>
</tr>
<tr>
<td height="20">  Twitter for BlackBerryÂ®</td>
<td align="right">2</td>
</tr>
<tr>
<td height="20">                   Visibli</td>
<td align="right">2</td>
</tr>
<tr>
<td height="20">                     yoono</td>
<td align="right">2</td>
</tr>
<tr>
<td height="20">              360 Panorama</td>
<td align="right">1</td>
</tr>
<tr>
<td height="20">                Mobile Web</td>
<td align="right">1</td>
</tr>
</tbody>
</table>
<h2>Ladies Learning Code</h2>
<p><a href="http://peternewhook.com/wp-content/uploads/2012/02/llcpie.jpg"><img class="aligncenter size-full wp-image-421" title="llcpie" src="http://peternewhook.com/wp-content/uploads/2012/02/llcpie.jpg" alt="Ladies Learning Code Twitter Client Pie Chart" width="599" height="415" /></a></p>
<table width="243" border="0" cellspacing="0" cellpadding="0">
<colgroup>
<col width="179" />
<col width="64" /> </colgroup>
<tbody>
<tr>
<td width="179" height="20"><strong>Client</strong></td>
<td width="64"><strong>Freq</strong></td>
</tr>
<tr>
<td height="20">                       web</td>
<td>90</td>
</tr>
<tr>
<td height="20">        Twitter for iPhone</td>
<td>34</td>
</tr>
<tr>
<td height="20">                 TweetDeck</td>
<td>22</td>
</tr>
<tr>
<td height="20">                 HootSuite</td>
<td>10</td>
</tr>
<tr>
<td height="20">              Tweet Button</td>
<td>5</td>
</tr>
<tr>
<td height="20">       Tweetbot for iPhone</td>
<td>5</td>
</tr>
<tr>
<td height="20">                      kiwi</td>
<td>3</td>
</tr>
<tr>
<td height="20">   TweetCaster for Android</td>
<td>3</td>
</tr>
<tr>
<td height="20">       Twitter for Android</td>
<td>3</td>
</tr>
<tr>
<td height="20">                   CoTweet</td>
<td>2</td>
</tr>
<tr>
<td height="20">                  Facebook</td>
<td>2</td>
</tr>
<tr>
<td height="20">                  Paper.li</td>
<td>2</td>
</tr>
<tr>
<td height="20">  Twitter for BlackBerryÂ®</td>
<td>2</td>
</tr>
<tr>
<td height="20">ÃœberSocial for BlackBerry</td>
<td>1</td>
</tr>
<tr>
<td height="20">                 instagram</td>
<td>1</td>
</tr>
<tr>
<td height="20">                MeetupXApp</td>
<td>1</td>
</tr>
<tr>
<td height="20">                   tGadget</td>
<td>1</td>
</tr>
<tr>
<td height="20">           Twitter for Mac</td>
<td>1</td>
</tr>
</tbody>
</table>
<p>You can imagine my horror when I discovered that for the better part of the last month I&#8217;d been cavorting with Jobs-worshiping, ironic-glasses-wearing iPhone users. I felt lied to. I felt abandoned. I felt dirty.</p>
<p>But the more I thought about it, the more I realized that I was being small minded. iPhone users are people too. They put their (skinny) jeans on one leg at a time. We both need a hit of coffee in the morning, even if they give their drinks insufferable names like &#8216;grande, no-fat, sugar-free Cinnamon Dolce Latte, no whip&#8217;. And who am I to judge a fellow geek or geekette if they like having a small computer attached to them at the hip.</p>
<p>I&#8217;ve learned that maybe we can get along even if you&#8217;re an iPhone user. So long as you&#8217;re an Aries.</p>
]]></content:encoded>
			<wfw:commentRss>http://peternewhook.com/2012/02/what-are-my-tweeps-using/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DevTO Presentation Slides</title>
		<link>http://peternewhook.com/2012/02/devto-presentation-slides/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=devto-presentation-slides</link>
		<comments>http://peternewhook.com/2012/02/devto-presentation-slides/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 03:17:05 +0000</pubDate>
		<dc:creator>Peter Newhook</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[DevTO]]></category>
		<category><![CDATA[Pauthor]]></category>
		<category><![CDATA[PivotViewer]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://peternewhook.com/?p=408</guid>
		<description><![CDATA[Slides from my PivotViewer talk at #DevTO ]]></description>
			<content:encoded><![CDATA[<p>If you were one of the 60 or so that made it out to DevTO last night, you were treated to a pretty fantastic show. I wasn&#8217;t bad either. I embedded a few resources into my  slides so here they are for your bedtime reading</p>
<p><iframe style="padding: 0; background-color: #fcfcfc;" title="Preview" src="https://r.office.microsoft.com/r/rlidPowerPointEmbed?p1=1&amp;p2=1&amp;p3=SDF56549E79BB0E4F2!323&amp;p4=&amp;ak=!AHcx-cZ0zq25O20&amp;kip=1&amp;authkey=!AHcx-cZ0zq25O20" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" width="402px" height="327px"></iframe></p>
<p><a href="https://skydrive.live.com/redir.aspx?cid=f56549e79bb0e4f2&amp;resid=F56549E79BB0E4F2!323&amp;parid=F56549E79BB0E4F2!336&amp;authkey=!AIMtd_9EHueZWfc">https://skydrive.live.com/redir.aspx?cid=f56549e79bb0e4f2&amp;resid=F56549E79BB0E4F2!323&amp;parid=F56549E79BB0E4F2!336&amp;authkey=!AIMtd_9EHueZWfc</a></p>
<p>Take a look at the notes as occasionally I add a little extra information. If you have any other questions, feel free to <a title="About" href="http://peternewhook.com/about/">drop me a line</a>.</p>
<p>And if you haven&#8217;t already seen them, photos are in a <a title="DevTO 9 Photos" href="https://www.facebook.com/media/set/?set=a.208279802602391.44443.142361512527554&amp;type=3&amp;l=f68b407125">Facebook album</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://peternewhook.com/2012/02/devto-presentation-slides/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ladies Learning Code Introduction to WordPress Next Steps</title>
		<link>http://peternewhook.com/2012/01/ladies-learning-code-introduction-to-wordpress-next-steps/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ladies-learning-code-introduction-to-wordpress-next-steps</link>
		<comments>http://peternewhook.com/2012/01/ladies-learning-code-introduction-to-wordpress-next-steps/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 02:36:43 +0000</pubDate>
		<dc:creator>Peter Newhook</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[Ladies Learning Code]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://peternewhook.com/?p=374</guid>
		<description><![CDATA[Following yesterdays Ladies Learning Code Introduction to Wordpress, I've compiled some next steps for our new developers.]]></description>
			<content:encoded><![CDATA[<p>Yesterday I was fortunate to mentor in the <a title="Ladies Learning Code" href="http://ladieslearningcode.com" target="_blank">Ladies Learning Code</a>  Wordpress class which was lead for the second time by <a title="Wes Bos Homepage" href="http://wesbos.com/" target="_blank">Wes Bos</a>. 75 women, and a few men, spent the day with Wes and <a title="Ladies Learning Code Introduction to Wordpes  Mentors" href="http://ladieslearningcode.com/2012/01/here-are-our-intro-to-wordpress-2-workshop-mentors/" target="_blank">the mentors</a> to learn how to build an awesome website using WordPress.</p>
<p>I thought I&#8217;d offer some advice to attendees on what to do next.</p>
<h1>Finishing Touches</h1>
<p>The class brought your theme 80% of the way, but there&#8217;s still work to do to make it production ready. Make sure the content of your home page is laid out how you want it, and you&#8217;ll probably want to revisit the background colour/image. Check out <a title="BgPatterns" href="http://bgpatterns.com/" target="_blank">BgPatterns</a> for more subdued background options.</p>
<p>Picking complimentary colours is a bit of an art, so if you&#8217;re like me and artistically useless, you&#8217;ll appreciate <a title="kuler" href="http://kuler.adobe.com/#" target="_blank">kuler</a>, a palette picker recommended by LLC mentor Anne Thomas. <a title="Anne Thomas Twitter Stream" href="https://twitter.com/#!/AlfalfaAnne" target="_blank">Read her tweets</a> for other great design tips.</p>
<p>To really make your theme your own, you&#8217;ll need to dig a little deeper into HTML/CSS. Take a look at these <a title="Google Code University" href="http://code.google.com/edu/submissions/html-css-javascript/" target="_blank">videos from Google</a> to bring yourself up to speed. Or keep an eye on the Ladies Learning Code site for future classes. Wink.</p>
<p>If you like having your Twitter feed in your site, make sure it&#8217;s now working. Same goes for the Flickr widget.</p>
<p>I don&#8217;t care what Wes says, tag clouds are rad. Use them.</p>
<p>You&#8217;ll also want to know how many people are visiting your <a title="Matt Barnes Wikipedia Article" href="http://en.wikipedia.org/wiki/Matt_Barnes" target="_blank">Matt Barnes</a> fan site (Yes, someone was developing this. He was their background and everything.) Tools like <a title="Google Analytics" href="http://www.google.com/analytics/" target="_blank">Google Analytics</a> give you great detail into how much traffic your site is getting, where they come from, and what they&#8217;re looking at.</p>
<p>If you find you&#8217;re running into trouble while developing, consider<a title="Wordpress debugging" href="http://codex.wordpress.org/Editing_wp-config.php#Debug" target="_blank"> turning on debugging</a><strong>. However, do not leave this turned on in a production site!!!(!).</strong> This could lead to massive security problems, should the wrong information be shown to malicious users.</p>
<h1>Getting the Tools</h1>
<p>At the end of the day, after the attendees left, the mentors had a rousing discussion about text editors. I&#8217;m not kidding. Developers spend a lot of time learning their tools, and develop loyalty to certain products. While a mentor was helping you, you may have noticed they insisted on installing a certain editor, or viewing your site in a specific browser. You&#8217;ll quickly become the same way. The good news is, there&#8217;s plenty of software available to you, absolutely free.</p>
<p>On the browser side, <a title="Google Chrome" href="https://www.google.com/chrome/?hl=en&amp;brand=chmo" target="_blank">Google Chrome</a> and <a title="Firefox" href="http://www.mozilla.org/en-US/firefox/new/" target="_blank">Firefox </a>currently rule the roost when it comes to developer preferred browsers. Chrome comes with excellent developer tools built in , but if you choose Firefox, you&#8217;ll also want to install a plugin called <a title="Firebug" href="http://getfirebug.com/" target="_blank">Firebug</a>. Take a minute to familiarize yourself with the developer tools in your browser. Start by right clicking and selecting <em>Inspect Element.</em></p>
<p>Ask a developer which text editors they use and you may accidentally start a holy war. If you&#8217;re on Windows, <a title="Notepad++" href="http://notepad-plus-plus.org/" target="_blank">Notepad++</a> is a great choice. Mac users can take the lead of Mr. Bos (can we please start calling him that) and use <a title="Sublime Text" href="http://www.sublimetext.com/" target="_blank">Sublime Text</a> (free for evaluation) or <a title="Komodo Edit" href="http://www.activestate.com/komodo-edit" target="_blank">Komodo Edit</a>, which is also an option on Windows. Good text editors will have syntax highlighting (colour coding your PHP files) and some even auto-complete as you type. If you need advanced features, you might want to start looking at an Integrated Development Environment (IDE) like <a title="Eclipse PHP" href="http://eclipse.org/proposals/php-ide/" target="_blank">Eclipse for PHP</a>, but it&#8217;s best to learn with simpler tools.</p>
<p>These are just suggestions, and a starting point for your research. Feel free to mention any other tools I&#8217;ve missed in the comments.</p>
<h1>Hosting</h1>
<p>Web hosting has become a comodity in recent years. Essentially what you want to look for is PHP support to install WordPress, and unlimited bandwidth and storage, in case your site gets really popular all of a sudden. Some hosts offer free domain registration, which is nice. Most plans shouldn&#8217;t cost more than $8 a month.</p>
<p>While on the subject of domain registration I&#8217;d like to give a little extra guidance. I absolutely advocate everyone claiming their piece of the internet by registering YourName.com. But when searching for registrars, look for those that offer free who.is privacy. Otherwise, people will be able to look up some of your personal information based on the URL you&#8217;ve registered.</p>
<p>I use <a title="Arvixe" href="http://www.arvixe.com/" target="_blank">Arvix </a>for my hosting. I&#8217;ve been happy with them.</p>
<h1>Content</h1>
<p>You need something for people to read when they get to your site! Get those pages in top shape, and start blogging like the digital citizen you are. Stuck for topics? Why not write about Ladies Learning Code.</p>
<h1>On a Personal Note</h1>
<p>Finally I&#8217;d like to say thank you to the organizers and the students. The Ladies Learning Code team did a fantastic job. Registration was orderly, the network was solid, and lunch was excellent. All I had to do was show up and geek out for a few hour. It&#8217;s pretty clear why these  events sell out in minutes.</p>
<p>As a technologist I often find I&#8217;m teaching tech. But my audience is never anywhere near as receptive as they were yesterday. Everybody showed up ready to learn and was extremely pleasant to work with. Having students like I did definitely makes me want to volunteer again.</p>
]]></content:encoded>
			<wfw:commentRss>http://peternewhook.com/2012/01/ladies-learning-code-introduction-to-wordpress-next-steps/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Steve Martin plays &#8220;The Great Remember (for Nancy)&#8221;</title>
		<link>http://peternewhook.com/2012/01/steve-martin-plays-the-great-remember-for-nancy-on-abc-news/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=steve-martin-plays-the-great-remember-for-nancy-on-abc-news</link>
		<comments>http://peternewhook.com/2012/01/steve-martin-plays-the-great-remember-for-nancy-on-abc-news/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 04:26:09 +0000</pubDate>
		<dc:creator>Peter Newhook</dc:creator>
				<category><![CDATA[Human]]></category>
		<category><![CDATA[Banjo]]></category>
		<category><![CDATA[bluegrass]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Steve Martin]]></category>

		<guid isPermaLink="false">http://peternewhook.com/?p=365</guid>
		<description><![CDATA[Beautiful banjo music. Really.]]></description>
			<content:encoded><![CDATA[<p>Easily the best claw hammer banjo you&#8217;re going to hear all day. I guarantee it.</p>
<p style="text-align: center;">
<object id="kaltura_player_1326082941" width="392" height="221" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowScriptAccess" value="always" /><param name="allowNetworking" value="all" /><param name="allowFullScreen" value="true" /><param name="flashVars" value="referer=http://abcnews.go.com/WNT/video/steve-martin-great-remember-nancy-14692648&amp;autoPlay=false" /><param name="src" value="http://cdnapi.kaltura.com/index.php/kwidget/wid/0_x7lhyby9/uiconf_id/6501231" /><param name="allowscriptaccess" value="always" /><param name="allownetworking" value="all" /><param name="allowfullscreen" value="true" /><param name="flashvars" value="referer=http://abcnews.go.com/WNT/video/steve-martin-great-remember-nancy-14692648&amp;autoPlay=false" /><embed id="kaltura_player_1326082941" width="392" height="221" type="application/x-shockwave-flash" src="http://cdnapi.kaltura.com/index.php/kwidget/wid/0_x7lhyby9/uiconf_id/6501231" allowScriptAccess="always" allowNetworking="all" allowFullScreen="true" flashVars="referer=http://abcnews.go.com/WNT/video/steve-martin-great-remember-nancy-14692648&amp;autoPlay=false" allowscriptaccess="always" allownetworking="all" allowfullscreen="true" flashvars="referer=http://abcnews.go.com/WNT/video/steve-martin-great-remember-nancy-14692648&amp;autoPlay=false" /><a href="http://corp.kaltura.com">video platform</a> <a href="http://corp.kaltura.com/video_platform/video_management">video management</a> <a href="http://corp.kaltura.com/solutions/video_solution">video solutions</a> <a href="http://corp.kaltura.com/video_platform/video_publishing">video player</a></object></p>
<p style="text-align: center;">
]]></content:encoded>
			<wfw:commentRss>http://peternewhook.com/2012/01/steve-martin-plays-the-great-remember-for-nancy-on-abc-news/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>In Defense of MySpace</title>
		<link>http://peternewhook.com/2011/07/defense-myspace/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=defense-myspace</link>
		<comments>http://peternewhook.com/2011/07/defense-myspace/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 23:53:00 +0000</pubDate>
		<dc:creator>Peter Newhook</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[Abandoned Amusment Park]]></category>
		<category><![CDATA[MapReduce]]></category>
		<category><![CDATA[MySpace]]></category>

		<guid isPermaLink="false">http://www.peternewhook.com/?p=293</guid>
		<description><![CDATA[MySpace is often thought of a backwards web property for the modifications they let their users make. But behind those awful profile pages was some very impressive, and open sorce, .Net software.]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s easy to dump on MySpace. It was the twenty-first century equivalent of GeoCities, but with an even lower barrier to entry. When MySpace lost the social network race to Facebook very few people were sad to let go of, what Seth Meyers once called, &#8216;abandoned amusement park of the internet.&#8217;</p>
<p>But for a certain group, it&#8217;s time to look a little closer MySpace. That group is .Net developers.</p>
<p>For a brief period, MySpace was the most visited site on the internet and .Net technologies were powering it. Virtually no other company, Micrsoft itself excluded, has ever run .Net at the sort of scale that MySpace was innovating at the bleeding-edge of the CLR to keep up. And with little fanfare, they open-sourced a number of their projects. That work is still ahead of it&#8217;s time in many ways, and it&#8217;s time .Net devs took notice.</p>
<h1>qizmt</h1>
<p><a href="http://code.google.com/p/qizmt/"><img class="alignleft size-full wp-image-337" title="Qizmt logo" src="http://peternewhook.com/wp-content/uploads/2011/07/Qizmt_logo.png" alt="Qizmt logo" width="153" height="53" /></a>MapReduce is the framework that lets Google scale it&#8217;s data to massive commodity clusters in a reliable way. This method for distributing computation has been so successful Yahoo!, Facebook, LinkedIn and countless others are now using an open source competitor, Hadoop. By far my favourite project to come out of MySpace was qizmt. qizmt is an open source MapReduce framework for .Net. It allowed you to horizontally scale as your computational load increased. The source is hosted on Google Code at <a href="http://qizmt.myspace.com/">http://qizmt.myspace.com/</a>.</p>
<h1>MSFast</h1>
<p>Many web developers will be used to tools like Firebug or the WebKit Inspector, but if you are using Internet Explorer, especially a pre-8 version, you&#8217;re mostly out of luck. MySpace built their own browser debugger that they released for free. It brought IE 8 very close to feature parity with the above mentioned tools, but it could also be used with browsers as old as IE 6! The plugin is available from their site with links to the project on Google Code, <a href="http://msfast.myspace.com/">http://msfast.myspace.com</a>.</p>
<p><span class="Apple-style-span" style="font-size: 26px; font-weight: bold;">Data Relay</span></p>
<p>My company recently built their own framework to speed up intercommunication between systems. Had we known about Data Relay, we may not have needed to reinvent the wheel. Data Relay is a middle-tier framework to facilitate message passing at scale. This is the sort of heavy weight architectural project that seems to thrive in the non-.Net open source community, but doesn&#8217;t get the same focus in Microsoft shops because it&#8217;s not provided out of the box. This project isn&#8217;t as well documented, but you can find the code on Codeplex <a href="http://datarelay.codeplex.com/">http://datarelay.codeplex.com/</a><span class="Apple-style-span">. There&#8217;s also an interesting mention of it by a former MySpace engineer on his blog, </span><a href="http://www.metafilter.com/104479/Im-not-quite-certain-who-this-space-belongs-to-any-more#3752867">http://www.metafilter.com/104479/Im-not-quite-certain-who-this-space-belongs-to-any-more#3752867</a></p>
<p>It&#8217;s easy to look at a loud profile page on MySpace and assume the engineering behind the scenes was equally frightening. But the fact is you don&#8217;t rise to the top spot on the Alexa rankings without some pretty serious brainpower on the development team. I think it&#8217;s time developers, and the .Net crowd in particular, paid their dues.</p>
]]></content:encoded>
			<wfw:commentRss>http://peternewhook.com/2011/07/defense-myspace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight vs HTML5 Is Stupid</title>
		<link>http://peternewhook.com/2010/11/silverlight-html5-stupid/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-html5-stupid</link>
		<comments>http://peternewhook.com/2010/11/silverlight-html5-stupid/#comments</comments>
		<pubDate>Thu, 04 Nov 2010 00:12:07 +0000</pubDate>
		<dc:creator>Peter Newhook</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[Holy Wars]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.peternewhook.com/?p=164</guid>
		<description><![CDATA[When Bob Muglia said "Our Silverlight strategy and focus going forward has shifted." at PDC 2010, he probably didn't know the can of worms he was opening.]]></description>
			<content:encoded><![CDATA[<p>This &#8216;Death of Silverlight&#8217; debate is getting pretty idiotic. If you&#8217;ve been avoiding it, maybe doing real work while <a title="Mary-Jo Foley tries her hand at sensationalism" href="http://www.zdnet.com/blog/microsoft/microsoft-our-strategy-with-silverlight-has-shifted/7834?tag=mantle_skin;content">tech</a> <a title="Some Arts grad at Tech Crunch proves there are too many bloggers" href="http://techcrunch.com/2010/10/30/rip-silverlight-on-the-web/" target="_blank">pundits </a>enjoyed their pissing match, it all started with this little sentence from Bob Muglia, President of the Server and Tools Division at Microsoft:</p>
<p><a href="http://peternewhook.com.yew.arvixe.com/wp-content/uploads/2010/11/BobMugliaShareHisThoughtOnSilverlight.jpg"><img class="aligncenter size-full wp-image-300" title="Bob Muglia Shares His Thoughts On Silverlight" src="http://peternewhook.com.yew.arvixe.com/wp-content/uploads/2010/11/BobMugliaShareHisThoughtOnSilverlight.jpg" alt="Bob Muglia sharing the future of Silverlight." width="600" height="400" /></a></p>
<p style="text-align: left;">Hide the women and children and number zero! Muglia has lost his shit and is taking out every .Net developer at the knees!</p>
<p style="text-align: left;">This is stupid. Please stop.</p>
<p style="text-align: left;">There has been a lot of suggestion that Silverlight was never meant to replace HTML. This is revisionist history, and doesn&#8217;t help anyone. Silverlight was pretty clearly Microsoft&#8217;s attempt to overpower the conventional rich web stack with their own tools. And I do mean overpower. With Silverlight Microsoft brought a Sherman Tank to a knife fight. When Silverlight 1.0 was introduced in 2007 the web was a very different place. The only way to deliver video was through Flash, jQuery was just coming of age and Google Chrome (with all it&#8217;s V8 hotness) wasn&#8217;t even out yet. Silverlight represented a competitor to Adobe&#8217;s de-facto plugin, and Silverlight 2.0 gave .Net developers an opportunity to put their skills directly in the browser.</p>
<p style="text-align: left;">But their attempts were misguided. Building Bing Maps in Silverlight seemed like overkill and  many Microsoft product web sites (SharePoint comes to mind) used Silverlight for landing pages. The problem seemed to lay in Microsoft&#8217;s threshold for &#8220;Rich Internet Application.&#8221; Microsoft still seemed content to build the basics in HTML+CSS, but as soon as you started moving elements around a page, it was time to pull out the plug-in. Even the Silverlight Navigation template looks like a normal web page. Both of the above examples have since been converted to HTML, I suspect this is the &#8216;shift&#8217; Bob is talking about. If that wasn&#8217;t their original strategy, what have they shifted from?</p>
<p>Frankly, Silverlight development is  lovely and in many ways better than HTML + JavaScript + CSS. The tooling is far superior, the functionality is much stronger (<strong>DO NOT</strong> argue with this, does your HTML5 application use a webcam?) and performance is generally better for intense applications.</p>
<p>But Silverlight is far from perfect. It never really made sense for general web development for a few reasons.</p>
<p><strong><span style="font-weight: normal;"><strong>Silverlight isn&#8217;t crawlable/accessible.</strong> When you&#8217;re talking web, you can&#8217;t ignore the 800lb. gorilla in the room named Google. If Google can&#8217;t find you, you&#8217;re S.O.L. and Google can&#8217;t find Silverlight. A Silverlight app is a big amorphous blob of binary so without going out of your way to expose your Silverlight embedded content, search engine&#8217;s won&#8217;t find you. Closely related to searchability is accessibility. Again, because Silverlight is an amorphous binary blob screen readers and other devices have a hard time getting to the content.</span></strong></p>
<p><strong> </strong><strong>C</strong><strong>opy and paste is a pain.</strong> In my mind, this just about sums up why Silverlight isn&#8217;t a suitable general purpose web tool. Copy and paste is just one example of niceties that users have come to expect that are not out of the box in Silverlight. Right-click, navigation and printing also come to mind as examples of things that are onerous to put in Silverlight projects.</p>
<p><strong> Microsoft Controlled. </strong>The other large vendors simply can&#8217;t use Silverlight over flash, because siding with Microsoft is like hitching a ride on the Death Star. For better or for worse, a single entity controls the platform. Google is now finding out just how fun it is to depend on a competitors platform. Oracle is trying to <a title="Oracle suing Google over Dalvik" href="http://www.techradar.com/news/computing/oracle-sues-google-over-use-of-java-in-android-710123" target="_blank">sue the pants off them for their JVM</a>.</p>
<p><strong>Plug-ins are an extra step.</strong> Getting users to install an extra plugin is ultimately one more hurdle you need to overcome. It may be simple but there are so many issues that could get in the way. Security settings. Computer literacy. New devices may not even support the plugin. (iAnyging, Android, BlackBerry, etc)</p>
<p>If you were building entire sites in Silverlight, you probably had a little too much Microsoft Kool-Aid. If you can&#8217;t distinguish between best-practices and marketing, you probably shouldn&#8217;t be developing in the first place.</p>
<h2>Why Silverlight Is Still Relevant</h2>
<p>Despite the above knocks on Silverlight it&#8217;s still a pretty good place to hang you RIA hat.</p>
<p><strong>Microsoft is able to innovate faster than web standards. </strong>Silverlight was able to put video in the browser while the HTML5 video spec was in it&#8217;s infancy because plugins aren&#8217;t bound to any standards process. Standards boards move slowly because of all the players involved, but if Microsoft wants to try something, they&#8217;ve got their own sandbox to experiment in.  Right now, Smooth Streaming is the killer app for Silverlight. I suspect the video tag will catch up in time, but right now there&#8217;s no great story for streaming HTML5 video. Same with webcam and audio input.</p>
<p><strong>Internet Explorer 9 doesn&#8217;t run on Windows XP. </strong>If you&#8217;re not a fan of the new Aero UI, there isn&#8217;t much reason to upgrade to Windows 7. There, I said it. Sure, there are optimizations that come from a new operating system, but unless you&#8217;re a power user, you probably won&#8217;t notice them. And if  you are a power user, you probably don&#8217;t use Internet Explorer anyways. So what of these remaining users? They&#8217;re still happily rocking their XP boxes running Internet Explorer 6 through 8. &#8216;Far superior performance in other browsers you say? Meh, Internet Explorer works for me.&#8217; And you know what I&#8217;m okay with that. It just means I need to provide an experience for users that don&#8217;t have HTML5 canvas/SVG, audio/video, validation etc. I used to believe that the average web user really wanted an open and free web. Then <a title="ReadWriteWeb confuses Farmville users" href="http://www.readwriteweb.com/archives/facebook_wants_to_be_your_one_true_login.php" target="_blank">Read Write Web ran a piece about the new Facebook authentication</a> other sites could use. Turns out when you put Facebook and Login in the title, the people Googling for &#8220;Facebook login&#8221; are going to stumble across your site and think they&#8217;ve arrived at Facebook. This lead to comments like these:</p>
<p style="text-align: center;"><a href="http://peternewhook.com.yew.arvixe.com/wp-content/uploads/2010/11/ReadWriteWeb-Facebook-Login-Fiasco.jpg"><img class="size-full wp-image-301 aligncenter" title="ReadWriteWeb Facebook Login Fiasco" src="http://peternewhook.com.yew.arvixe.com/wp-content/uploads/2010/11/ReadWriteWeb-Facebook-Login-Fiasco.jpg" alt="" width="642" height="514" /></a></p>
<p>These people weren&#8217;t stupid, they&#8217;re just not geeks like you and I that spend evenings reading blog posts about Silverlight. I think a lot of the behaviours we take for granted still needs to be learned by the less technically savvy. That includes using non-default browsers. And Google, Facebook, Twitter etc. haven&#8217;t been able to change their ways, your cat photo sharing app isn&#8217;t going to change that.</p>
<p><strong>DRM is a necessary evil.</strong> DRM sucks. Get over it. You like getting paid to write software/music/anything creative? If you are to have a hope of making a living you need a way to control it&#8217;s distribution. This may be an area HTML never embraces because it&#8217;s so anathema to the open web philosophy.</p>
<p><strong>.Net Developers Want a RIA Platform.</strong> All the above begs the question, then why not use Flash? Well here&#8217;s your answer Mr./Mrs. Smarty-Pants. I don&#8217;t know Flash. And I don&#8217;t care to learn it. Nothing wrong with Flash, per se. 20 billion users can&#8217;t be wrong. But I know C# and rather enjoy it, so if there&#8217;s an option to enhance a web page with my .Net skills, I&#8217;m going to use it.</p>
<p>So whether you&#8217;re a member of the HTML5 mafia or a Silverlight fan-boy, please calm down. There&#8217;s enough web to go around and we&#8217;re going to need to play nicely for years to come.</p>
]]></content:encoded>
			<wfw:commentRss>http://peternewhook.com/2010/11/silverlight-html5-stupid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft and Open source, At Least They&#8217;re Trying</title>
		<link>http://peternewhook.com/2010/10/microsoft-open-source/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=microsoft-open-source</link>
		<comments>http://peternewhook.com/2010/10/microsoft-open-source/#comments</comments>
		<pubDate>Fri, 22 Oct 2010 09:47:11 +0000</pubDate>
		<dc:creator>Peter Newhook</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[NuGet]]></category>
		<category><![CDATA[Nupack]]></category>

		<guid isPermaLink="false">http://www.peternewhook.com/?p=158</guid>
		<description><![CDATA[After much fanfare at it's launch, Microsoft will be renaming NuPack (the open source .Net package management tool) due to a naming conflict.]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>When Microsoft announced NuPack you would have thought they open sourced .Net and cured cancer in one fell swoop. Every softie with a blog (<a title="Scott Hansleman announces NuPack" href="http://www.hanselman.com/blog/IntroducingNuPackPackageManagementForNETAnotherPieceOfTheWebStack.aspx" target="_blank">Hansleman</a>, <a title="Phil Haack announces NuPack" href="http://haacked.com/archive/2010/10/06/introducing-nupack-package-manager.aspx" target="_blank">Haack</a>, <a title="Scott Guthrie announces NuPack" href="http://weblogs.asp.net/scottgu/archive/2010/10/06/announcing-nupack-asp-net-mvc-3-beta-and-webmatrix-beta-2.aspx" target="_blank">Guthrie</a>) made an announcement. Their blog were equal parts technical description, and self-loving for being so open and community driven.</p>
<p>But at the end of the day their heart was in the right place. It&#8217;s a clever project. It&#8217;s open source <strong>with the ability to take contributions</strong> and they even worked the the Nu guys to see what people were already doing. Microsoft really has evolved.</p>
<p>Turns out they&#8217;re <a href="http://www.outercurve.org/Blogs/EntryId/22/Changing-the-NuPack-Project-Name" target="_blank">renaming NuPack</a> because <a href="http://nupack.org/" target="_blank">someone else has already taken the name</a>.</p>
<p>**Face Palm**</p>
<p>NUPACK is already the name of a software package to analyze nucleic acids by those smartypants at Caltech. But in all fairness, it&#8217;s not like they were easy to find. I mean, they didn&#8217;t even have a website. Oh wait&#8230;<a href="www.NUPACK.org" target="_blank">www.NUPACK.org</a></p>
<p>**Double Face Palm**</p>
<p>But they&#8217;re remedying the situation as best as they can. You can now <a title="Voting on a new Name at Codeplex NuPack Issues List" href="http://nupack.codeplex.com/workitem/list/basic" target="_blank">vote for a new name at the Codeplex issues list</a>. I like NFetch, and it&#8217;s running away with the vote. But a little disapointed to see no &#8216;Nu-&#8217; options.</p>
]]></content:encoded>
			<wfw:commentRss>http://peternewhook.com/2010/10/microsoft-open-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automated Testing Using Page Objects and WebDriver</title>
		<link>http://peternewhook.com/2010/09/automated-testing-pageobjects-webdriver/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=automated-testing-pageobjects-webdriver</link>
		<comments>http://peternewhook.com/2010/09/automated-testing-pageobjects-webdriver/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 01:13:44 +0000</pubDate>
		<dc:creator>Peter Newhook</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[Page Objects]]></category>
		<category><![CDATA[Selenium2]]></category>
		<category><![CDATA[WebDriver]]></category>

		<guid isPermaLink="false">http://www.peternewhook.com/?p=109</guid>
		<description><![CDATA[When writing your automated test scripts it is helpful to abstract your interface from the assertions. One helpful method to do this is the the Page Objects pattern. Essentially, your interface is mapped into a class, with each object field representing a UI element on your page. With all your locators in one place, you [...]]]></description>
			<content:encoded><![CDATA[<p>When writing your automated test scripts it is helpful to abstract your interface from the assertions. One helpful method to do this is the the Page Objects pattern. Essentially, your interface is mapped into a class, with each object field representing a UI element on your page. With all your locators in one place, you have a single repository to update if your UI ever changes.</p>
<p>Page Objects are a popular pattern when using Selenium RC, a great resource for guidance is the <a href="http://www.theautomatedtester.co.uk/tutorials/selenium/page-object-pattern.htm" target="_blank">Selenium Page Object Pattern</a> post on The Automated Tester&#8217;s blog. If you&#8217;d like some more quality reading on basic Page Object implementation take a look at the <a title="Page Objects on the Selenium Google Code Wiki" href="http://code.google.com/p/selenium/wiki/PageObjects" target="_blank">Page Objects page on the Selenium Google Code Wiki</a>.</p>
<p>In Selenium 1.x Page Object implementation was simply a nice compliment to the tool, but outside the scope of the project itself. With Selenium2/WebDriver, you get the <a title="PageFactory on the Selenium Google Code Wiki" href="http://code.google.com/p/selenium/wiki/PageFactory" target="_blank">PageFactory </a>class which takes your custom class, and gives you a usable page. [Note: At the time of writing, September 2010, the support package was only available in the Java library. Hopefully other languages will be supported by the 2.0 release]</p>
<p>WebDriver does this by a combination of clever conventions, and magic. Mostly magic. Following the example on the PageFactory wiki page mentioned above, I&#8217;ll demonstrate a quick test on the Bing home page. First you want your search page class. You want this class to support both the elements you&#8217;ll work with, and the services it provides. The minimum elements you&#8217;ll need to support on a search page are the search box and submit button. The process of searching is a &#8216;service&#8217; the page provides, it will be provided as a method. To separate concerns, your test should have access to the services, but no knowledge of the underlying HTML. For this reason elements are private members and services are public methods. Services should return information about the page, or new Page Objects. Your search page may look something like this, notes below.</p>
<pre class="brush: java; title: ; notranslate">
package com.PeterNewhook;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.PageFactory;

public class SearchPage extends Page{

	public SearchPage(WebDriver driver) {
		super(driver);
	}

	private WebElement q; //Search box
	private WebElement go; //Search button

	public ResultsPage search(String searchStatement){
		sb_form_q.sendKeys(searchStatement);
		sb_form_go.click();
		return PageFactory.initElements(_driver, ResultsPage.class);
	}
}
</pre>
<p>Notice a few things a few things about this class</p>
<ul>
<li>It extends Page</li>
<li>search returns a ResultsPage object</li>
<li>q and go fields are used without using being instantiated.</li>
</ul>
<p>Page is my own class with a single constructor that requires a WedDriver object. Inheriting this class makes it easy for the PageObject class to instantiate your object and associate a driver with it. Unfortunately, I missed this in the WebDriver documentation and had to check the <a title="PageFactory Source Code" href="http://code.google.com/p/selenium/source/browse/trunk/support/src/java/org/openqa/selenium/support/PageFactory.java" target="_blank">PageFactory source</a> after seeing this in a few examples. The Page class would look something like this:</p>
<pre class="brush: java; title: ; notranslate">
package com.PeterNewhook;

import org.openqa.selenium.WebDriver;

public class Page {

	WebDriver _driver;
	public Page(WebDriver driver){
		this._driver=driver;
	}
}
</pre>
<p>By returning a ResultsPage object, the search method (or &#8216;service&#8217; in Page Object parlance) allows our tests to navigate through the application without any reliance of the structure. This page would be instantiated with all the services a search results page would have. It might look something like this.</p>
<pre class="brush: java; title: ; notranslate">
package com.PeterNewhook;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class ResultsPage extends Page{

	public ResultsPage(WebDriver driver) {
		super(driver);
	}

	private WebElement count;

	public String getPagesReturned(){
		return count.getText();
	}
}
</pre>
<p>Ordinarily you would expect using q and go this way to throw a Null Pointer exception. If you&#8217;re familiar with the WebDriver API you may expect to see something like driver.findElements(By.id(&#8220;q&#8221;);. But therein lies the magic of the PageObject class. Take a look at how the SearchPage could be used by a full WebDriver program.</p>
<pre class="brush: java; title: ; notranslate">
package com.PeterNewhook;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.PageFactory;

public class SearchRunner {

	public static void main(String[] args) {
		WebDriver driver = new FirefoxDriver();
		driver.get(&quot;http://bing.com/&quot;);
		SearchPage bingHome = PageFactory.initElements(driver, SearchPage.class);
		ResultsPage searchResults = bingHome.search(&quot;Page Object Pattern&quot;);
		System.out.println(searchResults.getPagesReturned());
		driver.close();
	}
}
</pre>
<p>The PageFactory.initElements static method takes your driver instance and the class type you want returned, and returns a Page Object with it&#8217;s fields fully initialized. By default, the PageFactory will search for elements on the page with a matching id. If that fails, it will search by the name attribute. Because q is the name of the search box, the element is found automatically, however it could have also been defined using the FindBy attribute</p>
<pre class="brush: java; title: ; notranslate">
@FindBy(how = How.NAME, using = &quot;q&quot;)
private WebElement searchBox;
</pre>
<p>or even more simply</p>
<pre class="brush: java; title: ; notranslate">
@FindBy(name &quot;q&quot;)
private WebElement searchBox;
</pre>
<p>Other location strategies, like xpath or className, are also available using the FindBy attribute. I generally prefer using descriptive name for my field names, so I like to explicitly declare the FindBy method. This also gives me the flexibility to change the field name at a later date without needing to hunt down variables used throughout the class.</p>
<p>Now that you have a basic understanding of the Page Object pattern, I strongly suggest reading <a title="Page Object Pattern wiki page" href="http://code.google.com/p/selenium/wiki/PageObjects" target="_blank">Simon Stewart&#8217;s wiki page</a> mentioned earlier. It gives great detail and goes into depth on the nature of the PageFactory helper class.</p>
]]></content:encoded>
			<wfw:commentRss>http://peternewhook.com/2010/09/automated-testing-pageobjects-webdriver/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Castle Project ActiveRecord for ASP.Net Tutorial: Part 1 Introduction and a Single Table</title>
		<link>http://peternewhook.com/2010/03/castle-project-activerecord-for-asp-net-tutorial-part-1-introduction-and-a-single-table/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=castle-project-activerecord-for-asp-net-tutorial-part-1-introduction-and-a-single-table</link>
		<comments>http://peternewhook.com/2010/03/castle-project-activerecord-for-asp-net-tutorial-part-1-introduction-and-a-single-table/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 23:29:26 +0000</pubDate>
		<dc:creator>Peter Newhook</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[ActiveRecord]]></category>
		<category><![CDATA[ORM]]></category>

		<guid isPermaLink="false">http:/?p=88</guid>
		<description><![CDATA[I recently began working with Castle ActiveRecord. It is an Object Relational Mapping (ORM) tool for .Net applications. If you&#8217;re reading this I probably don&#8217;t have to explain what an ORM is, but essentially, instead of using ADO.Net/SQL to interact with your data, you get to manipulate each database record as if it were a [...]]]></description>
			<content:encoded><![CDATA[<p>I recently began working with Castle ActiveRecord. It is an Object Relational Mapping (ORM) tool for .Net applications. If you&#8217;re reading this I probably don&#8217;t have to explain what an ORM is, but essentially, instead of using ADO.Net/SQL to interact with your data, you get to manipulate each database record as if it were a .Net object, with CRUD operations available directly as object methods. While the <a href="http://www.castleproject.org/activerecord/gettingstarted/index.html" target="_blank">getting started guide on the Castle Project website</a> is generally adequate, it&#8217;s for WinForms instead of ASP.Net, there&#8217;s a few typos/inconsistencies in code examples, and it&#8217;s getting a little dated. I wanted to document my experience here so that others don&#8217;t run into the same problems I did while learning. I&#8217;ll be making a very simple blog application that generally follows the getting started guide on the ActiveRecord website, but I&#8217;m going to break up my tutorial slightly differently. In part one we&#8217;ll setup the environment and write the code for a very simple, single table object. In part two we&#8217;ll introduce relationships into the application and pretty up the interface a bit. I assume some level of competency in C#, ASP.Net and Visual Studio, but you can be completely new to ActiveRecord, NHibernate, and ORMs in general. To begin, you&#8217;ll need:</p>
<ul>
<li>Visual Studio or the free Visual Web Developer Express Edition (I&#8217;ll be using Visual Web Developer 2008)</li>
<li>SQL Express, likely installed with your Visual Studio</li>
<li>The <a href="http://www.castleproject.org/castle/download.html">Castle Project AcriveRecord Binaries.</a> This tutorial is based on ActiveRecord 2.0</li>
</ul>
<p><strong>Adding References</strong></p>
<p><strong> </strong>Begin by creating a new website and calling it ActiveRecordTutorial. Right click on the web site in the solution explorer and click &#8220;Add References&#8230;&#8221; Browse to the place you extracted the ActiveRecord DLLs and add Castle.ActiveRecord.dll. This should automatically add a number of other references including, Castle.Components.Validator.dll, Castle.Core.dll, Iesi.Collections.dll, Lucene.Net.dll, NHibernate.dll, and NHibernate.Search.dll. Not included is NHibernate.ByteCode.Castle.dll, add this as well. The official getting started guide actually misses this resource.</p>
<p><strong>Creating The First Database Table</strong></p>
<p>Right click on the App_Data folder and select &#8220;Add New Item&#8230;&#8221; Select SQL Server, and name it ActiveRecordDB.mdf. Note that this is a SQL Server Express database. You may want to use the full version of SQL Server, or even PostgreSQL or MySQL, but I&#8217;ll be using Express as it&#8217;s the easiest to integrate with an ASP.Net web site. Then view the database in the Database Explorer, right click on the Tables folder and select &#8220;Add New Table&#8221;, this will be your Person table. The getting started guide used &#8220;User&#8221; but I found there was some conflict with the existing .Net User class, which made debugging slightly challenging. Create columns for Id (int), UserName (nvarchar(25)), and Password (nvarchar(25)). Id will be the primary key, and should also be an Identity column.  After saving this table as Person, it should look like the following:</p>
<p><a href="http://peternewhook.com/wp-content/uploads/2010/03/User-Table-Structure.jpg"><img class="aligncenter size-full wp-image-329" title="User-Table-Structure" src="http://peternewhook.com/wp-content/uploads/2010/03/User-Table-Structure.jpg" alt="" width="345" height="98" /></a></p>
<p><strong>Adding the Person Class</strong></p>
<p>For each table that you want to use in your application with ActiveRecord, you will create a corresponding class. Add a new class to your application called User.cs. You will get an alert prompting you to put this code file in the App_Code folder. Accept this option. You should then put the following code into this class.</p>
<pre class="brush: csharp; title: ; notranslate">
namespace ActiveRecordTutorial
{
    using System;
    using Castle.ActiveRecord;

    [ActiveRecord]
    public class Person : ActiveRecordBase&lt;person&gt;
    {
        private int id;
        private string username;
        private string password;

        public Person() { }

        public Person(string username, string password)
        {
            this.username = username;
            this.password = password;
        }

        [PrimaryKey]
        public int Id
        {
            get { return this.id; }
            set { this.id = value; }
        }

        [Property]
        public string Username
        {
            get { return this.username; }
            set { this.username = value; }
        }

        [Property]
        public string Password
        {
            get { return this.password; }
            set { this.password = value; }
        }
    }
}
</pre>
<p>There are at 4 things that separate this from a normal class.</p>
<ol>
<li>The ActiveRecord attribute on the class name.</li>
<li>Inheritance from ActiveRecordBase&lt;Person&gt;.</li>
<li>The PrimaryKey attribute on the Id property.</li>
<li>Property attributes on all remaining properties.</li>
</ol>
<p>All of these attributes are used by ActiveRecord define the relation between the table and the class.</p>
<p><strong>Initializing The Framework</strong></p>
<p><strong> </strong>Easily the most frustrating part of trying to adapt the official getting started guide to an ASP.Net application was configuring and initializing the framework. The guide creates an XML file to store settings, but ASP.Net already has an XML file handy, the web.config file. To begin, add the following just inside the configSections element, just before the sectionGroup for system.web.extensions</p>
<pre class="brush: xml; title: ; notranslate">
&lt;section name=&quot;activerecord&quot; type=&quot;Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord&quot;&gt;
</pre>
<p>Next, immediately following the empty connectionStrings element, add the following</p>
<pre class="brush: xml; title: ; notranslate">
&lt;activerecord isweb=&quot;true&quot;&gt;
  &lt;config&gt;
    &lt;add key=&quot;connection.driver_class&quot; value=&quot;NHibernate.Driver.SqlClientDriver&quot;&gt;
      &lt;add key=&quot;dialect&quot; value=&quot;NHibernate.Dialect.MsSql2008Dialect&quot;&gt;
        &lt;add key=&quot;connection.provider&quot; value=&quot;NHibernate.Connection.DriverConnectionProvider&quot;&gt;
          &lt;add key=&quot;connection.connection_string&quot; value=&quot;Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\ActiveRecordDB.mdf; Integrated Security=True;User Instance=True&quot;&gt;
            &lt;add key=&quot;proxyfactory.factory_class&quot; value=&quot;NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle&quot;&gt; &lt;/add&gt;
          &lt;/add&gt;
        &lt;/add&gt;
      &lt;/add&gt;
    &lt;/add&gt;
  &lt;/config&gt;
&lt;/activerecord&gt;
</pre>
<p>Notice that I am using the MsSql2008Dialect. There is no dialect specific to SQL Expres. MsSql2005Dialect also works against SQL Server 2008, but does not take advantage of some of the new Date data types in SQL Server 2008. See the <a href="http://nhforge.org/blogs/nhibernate/archive/2009/03/11/nhibernate-and-ms-sql-server-2008-date-time-datetime2-and-datetimeoffset.aspx" target="_blank">NHibernate blog post NHibernate and Ms Sql Server 2008</a> for more details. Finally you will need to add the following inside the httpModules element.</p>
<pre class="brush: xml; title: ; notranslate"> &lt;add name=&quot;ar.sessionscope&quot; type=&quot;Castle.ActiveRecord.Framework.SessionScopeWebModule, Castle.ActiveRecord&quot;&gt; </pre>
<p>This module provides default behaviour for SessionScope. You could replace this with custom code in the Global.asax file, but the module will do for now. Next, we need to run some code to initialize the application the first time it&#8217;s run. Create a Global.asax file and change it&#8217;s Inherits property to ActiveRecordTutorial.MyHttpApplication. We do this so that we can place code in a separate class called MyHttpApplication. It is also possible to write your code directly in the Global.asax file, but this was the approach taken by the getting started guide, so it&#8217;s what I follow here. Then create a new class called MyHttpApplication and place the following code in it.</p>
<pre class="brush: csharp; title: ; notranslate">
namespace ActiveRecordTutorial
{
    using System;
    using System.Web;
    using Castle.ActiveRecord;
    using Castle.ActiveRecord.Framework;
    using Castle.ActiveRecord.Framework.Config;
    public class MyHttpApplication : HttpApplication
    {
        protected void Application_Start(Object sender, EventArgs e)
        {
            //get the settings from web.config
            IConfigurationSource source = ActiveRecordSectionHandler.Instance;
            //register your objects with ActiveRecord
            ActiveRecordStarter.Initialize(source, new Type[] { typeof(Person) });
        }
    }
}
</pre>
<p><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px;">I have only skimmed the surface of configuration and initialization. For more information see the </span><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px;"><a href="http://www.castleproject.org/activerecord/gettingstarted/initandtest.html" target="_blank">initialization step</a></span><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px;"> of the getting started guide, and the </span><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px;"><a href="http://www.castleproject.org/activerecord/documentation/v1rc1/usersguide/web.html" target="_blank">Web Applications</a></span><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px;"> guide in the official documentation.</span><br />
<span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px;"><strong>Using the Person Class</strong></span><br />
<span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px;"><strong> </strong></span><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px;"> Finally, to test the Person class put the following in Default.aspx.cs</span></p>
<pre class="brush: csharp; title: ; notranslate">
using System;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ActiveRecordTutorial;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //create your new user and set properties
        Person myPerson = new Person();
        myPerson.Username = &quot;name&quot;; myPerson.Password = &quot;secret&quot;; try
        {
            //try to save myPerson to database
            myPerson.Create();
        }
        catch (Exception err) { string errReport = &quot;Failed trying to save user&quot;; errReport += err.Message; System.Diagnostics.Debug.Write(errReport); }
    }
}</pre>
<p><span style="font-family: 'Trebuchet MS',verdana,sans-serif; line-height: 22px;">Run the page with F5 and if you&#8217;re page successfully loads, you should have a user in the database.</span>�<br />
<a href="http://peternewhook.com/wp-content/uploads/2010/03/User-In-Database.jpg"><img class="aligncenter size-full wp-image-330" title="User-In-Database" src="http://peternewhook.com/wp-content/uploads/2010/03/User-In-Database.jpg" alt="" width="344" height="63" /></a><br />
<strong>Conclusion</strong> You have now created your first web site using Castle Project ActiveRecord. This framework not only greatly simplifies data access by abstracting SQL calls to objects, but also encourages OOP patterns, leading to more maintainable code. In part two I will be creating Blog and Post objects to illustrate relationships. Until then.</p>
]]></content:encoded>
			<wfw:commentRss>http://peternewhook.com/2010/03/castle-project-activerecord-for-asp-net-tutorial-part-1-introduction-and-a-single-table/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>JavaScript and SQL using Rhino and SQLite</title>
		<link>http://peternewhook.com/2009/07/javascript-and-sql-using-rhino-and-sqlite/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=javascript-and-sql-using-rhino-and-sqlite</link>
		<comments>http://peternewhook.com/2009/07/javascript-and-sql-using-rhino-and-sqlite/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 21:26:21 +0000</pubDate>
		<dc:creator>Peter Newhook</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Rhino]]></category>
		<category><![CDATA[SSJS]]></category>

		<guid isPermaLink="false">http://www.peternewhook.com/?p=53</guid>
		<description><![CDATA[My previous posts have revolved around running JavaScript in environments outside of the browser. After the disappointment of Microsoft dropping plans for Managed JScript, I’ve taken some time to work with Mozilla Rhino. As an aside, it’s been quite nice to work with a strictly open source product. My company is a heavy user of [...]]]></description>
			<content:encoded><![CDATA[<p>My previous posts have revolved around running JavaScript in environments outside of the browser. After the disappointment of Microsoft dropping plans for Managed JScript, I’ve taken some time to work with Mozilla Rhino.</p>
<p>As an aside, it’s been quite nice to work with a strictly open source product. My company is a heavy user of Microsoft products so I’m very much exposed to the .Net ecosystem. I think it’s very strong, but I do yearn for a little more open community.</p>
<p>Recently, I’ve become interested with SQLite, and I thought it would be a great exercise to use SQLite from Rhino. I could find all kinds of articles that cover similar topics, but none that covered exactly this, so I get to feel like I’m getting first tracks, even if down a smaller slope.</p>
<p>SQLite is kept small and nimble by only providing an API to C/C++ and Tcl. So you’ll need a way to bind Java to SQLite. I used<a title="SQLite Jdbc" href="http://www.zentus.com/sqlitejdbc/" target="_blank"> SQLite JDBC </a>That project appears to be under relatively active development, works on all platforms, and is available as a compiled jar. The jar contains all the code you need so you don’t even have to install SQLite separately.</p>
<p>Next start the Rhino shell including the SQLite jar on your classpath. I’m running Windows and use a batch file to do this, do my batch file looks like this:</p>
<pre class="brush: bash; title: ; notranslate">
@echo off
echo Starting Rhino
cd c:\Rhino1_7r2
java -cp &quot;.;C:\rhino1_7r2\jar\sqlitejdbc-v056.jar;;C:\rhino1_7r2\js.jar&quot; org.mozilla.javascript.tools.shell.Main
</pre>
<p>If you’re typing this in the interactive shell, I’ve added come some of the return statements in comments.</p>
<pre class="brush: jscript; title: ; notranslate">

//import the Java SQL package
importPackage(java.sql);
//load the SQLite driver
//importPackage does not work here
java.lang.Class.forName(&quot;org.sqlite.JDBC&quot;);
// returns:class org.sqlite.JDBC
//Create connection to test.db
//That database is created if it doesn’t exist.
//Normally, you could supply two more arguments here with
//username and password, but SQLite doesn’t support this
var conn = DriverManager.getConnection(&quot;jdbc:sqlite:test.db&quot;);

//Use the connection to create a Statement object
var stat = conn.createStatement();
stat.executeUpdate(&quot;drop table if exists people ;&quot;);
//returns: 0
stat.executeUpdate(&quot;create table people (name, occupation);&quot;);
//returns: 0
//Create a prepared statement object
var prep = conn.prepareStatement(&quot;insert into people values (?, ?);&quot;);
prep.setString(1, &quot;Gandhi&quot;);
prep.setString(2, &quot;politics&quot;);
prep.addBatch();
prep.setString(1, &quot;Turing&quot;);
prep.setString(2, &quot;Computers&quot;);
prep.addBatch();
conn.setAutoCommit(false);
//Execute the prepared statements
prep.executeBatch();
//returns: [I@6e1408
conn.setAutoCommit(true);
var resultSet = stat.executeQuery(&quot;select * from people;&quot;);
while (resultSet.next()){
print(resultSet.getString(&quot;name&quot;) + “ – “ + resultSet.getString(&quot;occupation&quot;));
}
//returns
// Gandhi - politics
// Turing – Computers
//cleanup
//While SQLite really isn’t the tool to use if
//data needs to be shared across multiple applications
// or users, be sure to close resultSet otherwise the
//db will stay locked
resultSet.close();
stat.close();
conn.close();
</pre>
<p>You can then launch your SQLite inspector of choice, I use the fantastic <a title="SQLiteman" href="http://sqliteman.com/" target="_blank">SQLiteman</a>. Select * from people and you will see what you’ve just added. Satisfying isn’t it?</p>
<p>Notice that I had to specify java.lang.Class.forName whereas most examples you see connecting to a SQL database will simply call Class.forName. This is because the lang package isn’t imported by default into Rhino, where is normally is in Java.</p>
]]></content:encoded>
			<wfw:commentRss>http://peternewhook.com/2009/07/javascript-and-sql-using-rhino-and-sqlite/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

