<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"><title type="text">Ken Egozi's blog</title><id>http://kenegozi.com/blog</id><updated>2012-10-11T17:30:38Z</updated><author><name>Ken Egozi</name><uri>http://kenegozi.com/blog</uri><email>mail@kenegozi.com</email></author><generator>Ken's blog engine, running on ASP.NET MVC3</generator><link rel="alternate" type="text/html" href="http://kenegozi.com/blog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/kenegozi" /><feedburner:info uri="kenegozi" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry><id>http://kenegozi.com/blog/2012/10/11/two-years-and-one-baby-later</id><title type="html">Two years and one baby later</title><published>2012-10-11T17:30:38Z</published><updated>2012-10-11T17:30:38Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/kenegozi/~3/awPEDFuWWsU/two-years-and-one-baby-later" /><category term="personal" /><content type="html">&lt;p&gt;two years ago, my Noam (who was 1y and a wee back then) got caught on camera doing this:&lt;/p&gt; &lt;p&gt;&lt;a href="http://kenegozi.com/blog/uploaded/WindowsLiveWriter/Babysmashonbigscreen_1138F/8b274b5a-3d2c-4b18-9bcd-5de63d03fd61.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="IMG_2370" border="0" alt="IMG_2370" src="http://kenegozi.com/blog/uploaded/WindowsLiveWriter/Babysmashonbigscreen_1138F/9940be20-38ab-4442-8318-45e8977431ee.jpg" width="244" height="184"&gt;&lt;/a&gt;&lt;br&gt;(from &lt;a href="http://kenegozi.com/blog/2010/10/07/baby-smash-on-big-screen"&gt;http://kenegozi.com/blog/2010/10/07/baby-smash-on-big-screen&lt;/a&gt;)&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;And now, Alma (8 months) is doing that:&lt;/p&gt; &lt;p&gt;&lt;a href="http://kenegozi.com/blog/uploaded/windows-live-writer/two-years-and-one-baby-later_9055/alma_smash_2.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="alma_smash" border="0" alt="alma_smash" src="http://kenegozi.com/blog/uploaded/windows-live-writer/two-years-and-one-baby-later_9055/alma_smash_thumb.jpg" width="244" height="184"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;smaller screen, shorter hair, the rest is quite the same&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=awPEDFuWWsU:xpveHp0tbUg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=awPEDFuWWsU:xpveHp0tbUg:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?i=awPEDFuWWsU:xpveHp0tbUg:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=awPEDFuWWsU:xpveHp0tbUg:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?i=awPEDFuWWsU:xpveHp0tbUg:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=awPEDFuWWsU:xpveHp0tbUg:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/kenegozi/~4/awPEDFuWWsU" height="1" width="1"/&gt;</content><feedburner:origLink>http://kenegozi.com/blog/2012/10/11/two-years-and-one-baby-later</feedburner:origLink></entry><entry><id>http://kenegozi.com/blog/2012/09/11/excel-and-mobile-services-take-2</id><title type="html">Excel and Mobile Services take 2</title><published>2012-09-11T07:51:28Z</published><updated>2012-09-11T07:51:28Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/kenegozi/~3/WKkfUO4d7fw/excel-and-mobile-services-take-2" /><category term="azure" /><category term="mobileservices" /><content type="html">&lt;p&gt;I have updated the code from my recent post, &lt;a href="http://kenegozi.com/blog/2012/09/07/using-excel-to-edit-azure-mobile-service-table-data"&gt;Using Excel to edit Azure Mobile Service table data&lt;/a&gt;, to support Insert and Update.&lt;/p&gt; &lt;p&gt;In order to delete a record, you’d need to have a cell from that record selected, then click on the Delete icon on the Add-Ins ribbon menu. The only requirement is to actually have a value in the first cell of that line.&lt;/p&gt; &lt;p&gt;In order to Insert a record, you’d need to set the fields, and keep the id empty, then click on the Add (plus) icon on the Add-Ins ribbon menu when a cell in that new record’s row is selected.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=WKkfUO4d7fw:jx4Nh0S1lb8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=WKkfUO4d7fw:jx4Nh0S1lb8:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?i=WKkfUO4d7fw:jx4Nh0S1lb8:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=WKkfUO4d7fw:jx4Nh0S1lb8:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?i=WKkfUO4d7fw:jx4Nh0S1lb8:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=WKkfUO4d7fw:jx4Nh0S1lb8:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/kenegozi/~4/WKkfUO4d7fw" height="1" width="1"/&gt;</content><feedburner:origLink>http://kenegozi.com/blog/2012/09/11/excel-and-mobile-services-take-2</feedburner:origLink></entry><entry><id>http://kenegozi.com/blog/2012/09/07/using-excel-to-edit-azure-mobile-service-table-data</id><title type="html">Using Excel to edit Azure Mobile Service table data</title><published>2012-09-07T08:31:39Z</published><updated>2012-09-07T08:31:39Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/kenegozi/~3/JHADcYLBMjY/using-excel-to-edit-azure-mobile-service-table-data" /><category term="azure" /><category term="mobileservices" /><content type="html">&lt;p&gt;When building apps for Mobile Services, you often need to manipulate the data stored in your table from an admin point of view.&lt;/p&gt; &lt;p&gt;The management portal of Azure does let you browse your data, but not edit it.&lt;/p&gt; &lt;p&gt;A few days back, &lt;a href="http://blog.amitapple.com/post/30386974705/azure-mobile-services-admin-table-viewer-sample"&gt;Amit showed on his blog&lt;/a&gt; a way to create a simple data manager as a Windows 8 Application, using the official SDK.&lt;/p&gt; &lt;p&gt;I however like the UI of Excel for data editing, so I wanted to create a simple editor that taps to Excel mechanisms, and uses the unofficial SDK to communicate with the mobile service.&lt;/p&gt; &lt;p&gt;The results can be seen &lt;a href="http://www.youtube.com/watch?v=c5F2G9-vIYE"&gt;in the following recording&lt;/a&gt; (you’d want to watch it in HD):&lt;/p&gt;&lt;iframe height="315" src="http://www.youtube.com/embed/c5F2G9-vIYE?rel=0" frameborder="0" width="560" allowfullscreen&gt;&lt;/iframe&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;How?&lt;/p&gt; &lt;p&gt;First, I created an Excel AddIn project in VS2012. Then I grabbed the &lt;a href="https://github.com/kenegozi/azure-mobile-csharp-sdk/blob/master/src/MobileServiceClient.cs"&gt;latest SDK file from github&lt;/a&gt;, and added it to the project. Lastly, I changed the AddIn code to look &lt;a href="https://gist.github.com/3664011"&gt;like that gist&lt;/a&gt; (you’d need to set your app url and key), and ran the project.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Current limitations:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;I am a very poor VSTO developer. There are probably million ways to do the Excel bits better. I’d appreciate constructive comments on the gist.  &lt;li&gt;&lt;strike&gt;The current implementation does not support row inserts and deletes. &lt;br&gt;&lt;/strike&gt;UPDATE [9/11/2012] Insert and Delete works now! &lt;li&gt;Dates will lose millisecond precision.  &lt;li&gt;And it will not work with “Authenticated only” tables.&lt;br&gt;I will be adding a support for the Admin Key that Amit showed on his blog to solve this&lt;/li&gt;&lt;/ol&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=JHADcYLBMjY:ETFRLvjR7YM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=JHADcYLBMjY:ETFRLvjR7YM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?i=JHADcYLBMjY:ETFRLvjR7YM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=JHADcYLBMjY:ETFRLvjR7YM:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?i=JHADcYLBMjY:ETFRLvjR7YM:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=JHADcYLBMjY:ETFRLvjR7YM:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/kenegozi/~4/JHADcYLBMjY" height="1" width="1"/&gt;</content><feedburner:origLink>http://kenegozi.com/blog/2012/09/07/using-excel-to-edit-azure-mobile-service-table-data</feedburner:origLink></entry><entry><id>http://kenegozi.com/blog/2012/09/04/using-gists-in-your-blog-embed-them-into-your-feed</id><title type="html">Using gists in your blog? Embed them into your feed</title><published>2012-09-04T07:22:57Z</published><updated>2012-09-04T07:22:57Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/kenegozi/~3/t10vGp3jQRA/using-gists-in-your-blog-embed-them-into-your-feed" /><category term="blog-engine" /><category term="tools" /><category term="open-source-software" /><content type="html">&lt;p&gt;I love using github gists for code snippets on my blog. It has many pros, especially how easy it becomes for people to comment and suggest improvements, via the github mechanisms we all love.&lt;/p&gt; &lt;p&gt;There are however two drawbacks that people commonly refer to with regards to using gists that way:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Since the content of the code is no longer part of the post, it is not being indexed by search engines, and  &lt;li&gt;Since the content of the code is not part of the post, and since the embedding mechanism is JS based, people who consume the blog via the feed and use feed aggregators that does not run javascript (most of them don’t), will not get the contents.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;My answer to the first one is simple. I don’t really care. Not that I do not care about SEO, just that I do not need to have my post indexed and tagged under a bunch of irrelevant reserved words and common code. If the snippet is about using an interesting component ABC, I will mention that said ABC in the post content outside of the snippet, problem solved.&lt;/p&gt; &lt;p&gt;The latter is more interesting. I used to manually add a link to the gist page whenever embedding one, but it is not a very fun thing to do.&lt;/p&gt; &lt;p&gt;So, in order to overcome this, I wrote a small code snippet (yey) that upon saving a post (or updating it), will look for gists embeds, grab the gist source from github, stick in into the post as a “ContentForFeed” and serve with a link to the gist page, just for the fun of it.&lt;/p&gt; &lt;p&gt;And the code for it (it’s a hacky c#, but easily translatable to other languages, and/or to a cleaner form)&lt;/p&gt; &lt;p&gt;GistsResolver.cs:&lt;br/&gt;&lt;pre&gt;
public class GistsResolver {
&amp;#9;public static string CreateContentForFeedFrom(string content) {
&amp;#9;&amp;#9;try {
&amp;#9;&amp;#9;&amp;#9;return UnwrapGists(content, GetGist);
&amp;#9;&amp;#9;}
&amp;#9;&amp;#9;catch {
&amp;#9;&amp;#9;&amp;#9;return content;
&amp;#9;&amp;#9;}
&amp;#9;}

&amp;#9;static readonly Regex GistsFinder = new Regex(&amp;quot;&amp;lt;script src=\&amp;quot;https://gist.github.com/(?&amp;lt;gistid&amp;gt;\\d+).js(\\?file=(?&amp;lt;file&amp;gt;[^\&amp;quot;]+))?\&amp;quot;&amp;gt;\\s*&amp;lt;/script&amp;gt;&amp;quot;, RegexOptions.Compiled);
&amp;#9;static JObject GetGist(string gistId) {
&amp;#9;&amp;#9;try {
&amp;#9;&amp;#9;&amp;#9;var content =
&amp;#9;&amp;#9;&amp;#9;&amp;#9;new WebClient().DownloadString(&amp;quot;https://api.github.com/gists/&amp;quot; + gistId);
&amp;#9;&amp;#9;&amp;#9;var gist = JObject.Parse(content);
&amp;#9;&amp;#9;&amp;#9;return gist;
&amp;#9;&amp;#9;}
&amp;#9;&amp;#9;catch (Exception) {
&amp;#9;&amp;#9;&amp;#9;return null;
&amp;#9;&amp;#9;}
&amp;#9;}

&amp;#9;private static string ContentToHtml(JObject file) {
&amp;#9;&amp;#9;var content = file[&amp;quot;content&amp;quot;].Value&amp;lt;string&amp;gt;();
&amp;#9;&amp;#9;content = content.Replace(&amp;quot;\r\n&amp;quot;, &amp;quot;\n&amp;quot;).Replace(&amp;quot;\r&amp;quot;, &amp;quot;\n&amp;quot;).Replace(&amp;quot;\n&amp;quot;, &amp;quot;\r\n&amp;quot;);
&amp;#9;&amp;#9;content = Microsoft.Security.Application.Encoder.HtmlEncode(content, true);
&amp;#9;&amp;#9;content = content.Replace(&amp;quot;&amp;amp;#10;&amp;quot;, &amp;quot;\n&amp;quot;).Replace(&amp;quot;&amp;amp;#13;&amp;quot;, &amp;quot;\r&amp;quot;);
&amp;#9;&amp;#9;content = &amp;quot;&amp;lt;pre&amp;gt;&amp;quot; + content + &amp;quot;&amp;lt;/pre&amp;gt;&amp;quot;;
&amp;#9;&amp;#9;var name = file[&amp;quot;filename&amp;quot;].Value&amp;lt;string&amp;gt;();
&amp;#9;&amp;#9;if (!string.IsNullOrEmpty(name)) {
&amp;#9;&amp;#9;&amp;#9;content = Microsoft.Security.Application.Encoder.HtmlEncode(name, true)
&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;+ &amp;quot;:&amp;lt;br/&amp;gt;&amp;quot;
&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;+ content;
&amp;#9;&amp;#9;}
&amp;#9;&amp;#9;return content;
&amp;#9;}

&amp;#9;private static string UnwrapGists(string c, Func&amp;lt;string, JObject&amp;gt; gistGetter) {
&amp;#9;&amp;#9;return GistsFinder.Replace(c, match =&amp;gt; {
&amp;#9;&amp;#9;&amp;#9;try {
&amp;#9;&amp;#9;&amp;#9;&amp;#9;var gistId = match.Groups[&amp;quot;gistid&amp;quot;].Value;
&amp;#9;&amp;#9;&amp;#9;&amp;#9;var gistData = gistGetter(gistId);
&amp;#9;&amp;#9;&amp;#9;&amp;#9;var fileName = match.Groups[&amp;quot;file&amp;quot;].Success
&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;? match.Groups[&amp;quot;file&amp;quot;].Value
&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;: null;
&amp;#9;&amp;#9;&amp;#9;&amp;#9;var content = string.Empty;
&amp;#9;&amp;#9;&amp;#9;&amp;#9;var url = gistData[&amp;quot;url&amp;quot;].Value&amp;lt;string&amp;gt;();
&amp;#9;&amp;#9;&amp;#9;&amp;#9;if (fileName != null) {
&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;var file = (JObject)gistData[&amp;quot;files&amp;quot;][fileName];
&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;content = ContentToHtml(file);
&amp;#9;&amp;#9;&amp;#9;&amp;#9;}
&amp;#9;&amp;#9;&amp;#9;&amp;#9;else {
&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;foreach (JProperty fileProp in gistData[&amp;quot;files&amp;quot;]) {
&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;var file = fileProp.Value.Value&amp;lt;JObject&amp;gt;();
&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;content += ContentToHtml(file);
&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;}
&amp;#9;&amp;#9;&amp;#9;&amp;#9;}
&amp;#9;&amp;#9;&amp;#9;&amp;#9;content += &amp;quot;&amp;lt;br/&amp;gt;&amp;quot;
&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;+ &amp;quot;&amp;lt;a href=&amp;#39;&amp;quot; + Microsoft.Security.Application.Encoder.HtmlAttributeEncode(url) + &amp;quot;&amp;#39; title=&amp;#39;I &amp;amp;hearts; github&amp;#39;&amp;gt;&amp;quot;
&amp;#9;&amp;#9;&amp;#9;&amp;#9;&amp;#9;+ &amp;quot;(see the most recent version of this gist)&amp;lt;/a&amp;gt;&amp;quot;;

&amp;#9;&amp;#9;&amp;#9;&amp;#9;content = &amp;quot;&amp;lt;p&amp;gt;&amp;quot; + content + &amp;quot;&amp;lt;/p&amp;gt;&amp;quot;;
&amp;#9;&amp;#9;&amp;#9;&amp;#9;return content;
&amp;#9;&amp;#9;&amp;#9;}

&amp;#9;&amp;#9;&amp;#9;catch (Exception ex) {
&amp;#9;&amp;#9;&amp;#9;&amp;#9;return match.ToString();
&amp;#9;&amp;#9;&amp;#9;}
&amp;#9;&amp;#9;});
&amp;#9;}

}
&lt;/pre&gt;&lt;br/&gt;&lt;a href='https://gist.github.com/3617851' title='I &amp;hearts; github'&gt;(see the most recent version of this gist)&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Have fun reading snippets&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=t10vGp3jQRA:HhJFjYWd4Zc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=t10vGp3jQRA:HhJFjYWd4Zc:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?i=t10vGp3jQRA:HhJFjYWd4Zc:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=t10vGp3jQRA:HhJFjYWd4Zc:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?i=t10vGp3jQRA:HhJFjYWd4Zc:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=t10vGp3jQRA:HhJFjYWd4Zc:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/kenegozi/~4/t10vGp3jQRA" height="1" width="1"/&gt;</content><feedburner:origLink>http://kenegozi.com/blog/2012/09/04/using-gists-in-your-blog-embed-them-into-your-feed</feedburner:origLink></entry><entry><id>http://kenegozi.com/blog/2012/08/29/using-azure-mobile-services-with-windows-phone</id><title type="html">Using Azure Mobile Services with Windows Phone</title><published>2012-08-29T09:40:12Z</published><updated>2012-08-29T09:40:12Z</updated><link rel="alternate" href="http://feedproxy.google.com/~r/kenegozi/~3/H-VzY7JBXCY/using-azure-mobile-services-with-windows-phone" /><category term="azure" /><category term="mobileservices" /><content type="html">&lt;h4&gt;Windows 8 app building is great&lt;/h4&gt; &lt;p&gt;With the new awesomeness that is Azure Mobile Services, building a cloud-connected application became much easier.&lt;/p&gt; &lt;p&gt;Now you just probably say “I wish it would have worked with other client platforms as well as Windows 8”&lt;/p&gt; &lt;p&gt;Guess what?&lt;/p&gt; &lt;h4&gt;HTTP &lt;/h4&gt; &lt;p&gt;The service is actually talking to the SDK via HTTP, and the Windows 8 SDK that is published along is a (very rich, awesomely done) wrapper around that HTTP API. Given that, I jumped ahead and implemented a (very poor, awfully done) SDKs for Windows Phone*. &lt;/p&gt; &lt;blockquote&gt; &lt;h4&gt;Disclaimer #1&lt;/h4&gt;&lt;/blockquote&gt; &lt;blockquote&gt; &lt;p&gt;What you see here in this post and other related ones is 99.999% guaranteed to fail for you. It is a hack job that I put together in a few late-night hours, and it is *not* endorsed by the Mobile Services team. It is likely that if and when we do come up with an official WP SDK, it would be looking different. Very different. Even the HTTP api that I’m using here is likely to change by the time the service gets out of Preview mode.&lt;/p&gt;&lt;/blockquote&gt; &lt;h4&gt;&lt;/h4&gt; &lt;h4&gt;&lt;/h4&gt; &lt;h4&gt;codez&lt;/h4&gt; &lt;p&gt;You can peak at some of the usages for the API in the following gist:&lt;/p&gt;&lt;p&gt;MobileServices_WindowsPhone.cs:&lt;br/&gt;&lt;pre&gt;// in App.xaml.cs
public partial class App : Application
{
    public static readonly MobileServiceClient MobileServiceClient;
    public static User CurrentUser;

    static App()
    {
        // Get this data from the management portal&amp;#39;s quickstart page
        // in the &amp;#39;connect to existing apps&amp;#39; section
        MobileServiceClient = new MobileServiceClient(
            &amp;quot;https://YOUR_APP.azure-mobile.net/&amp;quot;,
            &amp;quot;YOUR_APP_KEY&amp;quot;
        );
    }
    
    // the rest of App.xaml.cs here ...
}

// elsewhere:
MobileServiceTable&amp;lt;TodoItem&amp;gt; todoItemTable = App.MobileServiceClient.GetTable&amp;lt;TodoItem&amp;gt;();


// insert
var item = new TodoItem { Text = &amp;quot;Do this!&amp;quot; };
todoItemTable.Insert(item, (res, err) =&amp;gt; {
    if (err != null) {
        //handle it
        return;
    }
    item = res;
});


// Update (sorry, no typed version yet):
var updates = new JObject();
updates[&amp;quot;text&amp;quot;] = &amp;quot;The text&amp;quot;;
todoItemTable.Update(updates, err =&amp;gt; {
    if (err != null) {
        //handle it
    }
});


// Get all
todoItemTable.GetAll((res, err) =&amp;gt; {
    if (err != null) {
        //handle it
        return;
    }
    foreach (TodoItem in res) {
    }
});


// OData query
var query = new MobileServiceQuery()
    .Filter(&amp;quot;text eq &amp;#39;whatever&amp;#39;&amp;quot;)
    .Top(1)
    .Skip(2)
    .OrderBy(&amp;quot;id desc&amp;quot;);

todoItemTable.Get(query, (res, err) =&amp;gt; {
    if (err != null) {
        //handle it
        return;
    }
    foreach (TodoItem in res) {
    }
});


// delete
testStuffTable.Delete(item.Id, err =&amp;gt; {
    if (err != null) {
        //handle it
    }
});


// login to Azure Mobile Services with the AuthenticationToken returned 
// from LiveAuthClient or the LiveLoginButton&amp;#39;s SessionChanged event           
App.MobileServiceClient.Login(e.Session.AuthenticationToken, (userId, err) =&amp;gt; {
   // do something with userId, perhaps call to LiveConnect for user details, etc.
});&lt;/pre&gt;&lt;br/&gt;&lt;a href='https://api.github.com/gists/3505665' title='I &amp;hearts; github'&gt;(see the most recent version of this gist)&lt;/a&gt;&lt;/p&gt; &lt;p&gt;In follow up posts, I will cover the API more, and I will also be adding xml comments to the SDK to make it easier to use.&lt;/p&gt; &lt;h4&gt;How to get it?&lt;/h4&gt; &lt;p&gt;Head over to &lt;a href="https://github.com/kenegozi/azure-mobile-csharp-sdk"&gt;https://github.com/kenegozi/azure-mobile-csharp-sdk&lt;/a&gt;.&lt;br&gt;you could either clone the repo, or just navigate to &lt;a href="https://github.com/kenegozi/azure-mobile-csharp-sdk/blob/master/src/MobileServiceClient.cs"&gt;/src/MobileServiceClient.cs&lt;/a&gt; , click on the ‘Raw’ button and save it in your project.&lt;br&gt;You’d need to have the latest &lt;a href="http://james.newtonking.com/projects/json-net.aspx"&gt;Newtonsoft’s Json.NET&lt;/a&gt; referenced as well (if you don’t have it already).&lt;br&gt;A NuGet based delivery is in the works.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;* I am also working on a similar SDK for Android. I’ll get to work on a iOS one as well once I get around to install Mountain Lion on my MBP&lt;/p&gt; &lt;blockquote&gt; &lt;h4&gt;Disclaimer #2&lt;/h4&gt;&lt;/blockquote&gt; &lt;blockquote&gt; &lt;p&gt;Although I do work on the Mobile Services feature in Azure, the opinions, code, and sub-par grammar I voice on this blog is completely my own, and does not reflect my employer’s opinions, code, or grammar. This is *not* where you will get any official Azure announcements, you’d need to check out other places (I’d suggest &lt;a href="http://WindowsAzure.com"&gt;http://WindowsAzure.com&lt;/a&gt; and &lt;a href="http://weblogs.asp.net/scottgu/"&gt;Scott Guthrie’s blog&lt;/a&gt; as good starting points)&lt;/p&gt;&lt;/blockquote&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=H-VzY7JBXCY:GHnriHdY6EE:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=H-VzY7JBXCY:GHnriHdY6EE:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?i=H-VzY7JBXCY:GHnriHdY6EE:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=H-VzY7JBXCY:GHnriHdY6EE:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?i=H-VzY7JBXCY:GHnriHdY6EE:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/kenegozi?a=H-VzY7JBXCY:GHnriHdY6EE:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/kenegozi?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/kenegozi/~4/H-VzY7JBXCY" height="1" width="1"/&gt;</content><feedburner:origLink>http://kenegozi.com/blog/2012/08/29/using-azure-mobile-services-with-windows-phone</feedburner:origLink></entry></feed>
