<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><description></description><title>Mike Olsen</title><generator>Tumblr (3.0; @artfulhacker)</generator><link>https://artfulhacker.com/</link><item><title>Guess latest Chrome version based on date?</title><description>&lt;p&gt;Using past two years of chrome releases from wikipedia: &lt;a href="https://en.wikipedia.org/wiki/Google_Chrome_version_history" target="_blank"&gt;https://en.wikipedia.org/wiki/Google_Chrome_version_history&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Curve fit with almost perfect fit, take the simple y = mx + b and we can guess the latest version of chrome based on the current epoch.&lt;/p&gt;&lt;img src="https://64.media.tumblr.com/cfcb05b71148a61a05256d89d6962e60/tumblr_inline_on0x0uvoRt1rfeip2_540.png" data-orig-height="785" data-orig-width="1100" width="800"/&gt;&lt;p&gt;javascript fiddle proof of concept: &lt;a href="https://jsfiddle.net/artfulhacker/e6c1qmff/" target="_blank"&gt;https://jsfiddle.net/artfulhacker/e6c1qmff/&lt;/a&gt;&lt;/p&gt;&lt;p&gt;var epoch = Date.now() / 1000;&lt;br/&gt;var slope = 0.000000251;&lt;br/&gt;var yintercept = -316;&lt;br/&gt;alert(Math.floor(epoch * slope + yintercept));&lt;/p&gt;</description><link>https://artfulhacker.com/post/158556111824</link><guid>https://artfulhacker.com/post/158556111824</guid><pubDate>Sat, 18 Mar 2017 11:41:39 -0700</pubDate></item><item><title>Beware, even things on Amazon come with embedded malware...</title><description>&lt;p&gt;I needed a simple set of good outdoor surveillance cameras for a friends home. Like everything else I buy, I turned to Amazon. I found (what seemed like) a great deal for a set of 6 poe cameras and the necessary recording equipment. Here is the link:&lt;/p&gt;&lt;figure data-orig-width="500" data-orig-height="500" class="tmblr-full"&gt;&lt;img src="https://64.media.tumblr.com/2b27526aaec57d6907a2ed820cf26251/tumblr_inline_o5dk4sQjEw1rfeip2_540.jpg" alt="image" data-orig-width="500" data-orig-height="500"/&gt;&lt;/figure&gt;&lt;p&gt;&lt;a href="http://www.amazon.com/Sony-Chip-Camera-1080P-CCTV/dp/B00YMEVSGA" target="_blank"&gt;http://www.amazon.com/Sony-Chip-Camera-1080P-CCTV/dp/B00YMEVSGA&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;When trying to get the cameras to work on my friends machine I simply logged into the admin webpage and went to configure it. First of all something seemed a bit off, the interface showed the camera feed but none of the normal controls or settings were available. Being one of those guys who assumes bad CSS, I went ahead and opened up developer tools. Maybe a bad style was hiding the options I needed. Instead what I found tucked at the bottom of the body tag was an iframe linking to a very strange looking host name. See the host name in the screenshots below:&lt;/p&gt;&lt;figure data-orig-width="921" data-orig-height="699" class="tmblr-full"&gt;&lt;img src="https://64.media.tumblr.com/dd9d041c6aa566545c9f3ef6927d8b53/tumblr_inline_o5djw0S8kD1rfeip2_540.png" alt="image" data-orig-width="921" data-orig-height="699"/&gt;&lt;/figure&gt;&lt;figure data-orig-width="280" data-orig-height="265"&gt;&lt;img src="https://64.media.tumblr.com/0b2ea8609e3349953513c97124065a58/tumblr_inline_o5dk9pg7R91rfeip2_540.png" alt="image" data-orig-width="280" data-orig-height="265"/&gt;&lt;/figure&gt;&lt;p&gt;At this point I went ahead and googled the domain, and guess what came up? &lt;i&gt;If you read the title you have an idea already.&lt;/i&gt;&lt;/p&gt;&lt;p&gt; &lt;b&gt;Malware&lt;/b&gt;. See this &lt;a href="https://blog.sucuri.net/2011/03/brenz-pl-is-back-with-malicious-iframes.html" target="_blank"&gt;page&lt;/a&gt; or just simply go through this &lt;a href="https://www.google.com/webhp?q=%22brenz.pl%22" target="_blank"&gt;google search&lt;/a&gt; for more information. My guess is many people have missed this. The seller has great ratings and the products are a good deal. So be careful what you buy!&lt;/p&gt;&lt;p&gt;Looks like it was pointed out in a forum a month ago here: &lt;a href="http://forums.whirlpool.net.au/forum-replies.cfm?t=2362073&amp;amp;p=11&amp;amp;#r211" target="_blank"&gt;http://forums.whirlpool.net.au/forum-replies.cfm?t=2362073&amp;amp;p=11&amp;amp;#r211&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;TLDR; First off, 223 words&amp;hellip; really?? Second, Amazon stuff can contain malware.&lt;/b&gt;&lt;/p&gt;</description><link>https://artfulhacker.com/post/142519805054</link><guid>https://artfulhacker.com/post/142519805054</guid><pubDate>Sat, 09 Apr 2016 09:30:46 -0700</pubDate></item><item><title>a year?</title><description>&lt;p&gt;it has officially been a year since my last post&amp;hellip;&lt;/p&gt;&lt;p&gt;#thestartuplife&lt;/p&gt;</description><link>https://artfulhacker.com/post/111844075474</link><guid>https://artfulhacker.com/post/111844075474</guid><pubDate>Mon, 23 Feb 2015 00:23:04 -0700</pubDate></item><item><title>Azure CDN now Supports CORS</title><description>&lt;p&gt;So we can finally host fonts in our Azure CDN!!!&lt;/p&gt;
&lt;p&gt;This goes for anything else subject to &lt;a href="http://www.w3.org/TR/cors/" target="_blank"&gt;cross-origin resource sharing&lt;/a&gt; restrictions.&lt;/p&gt;
&lt;p&gt;So update your azure storage client library to (&amp;gt; 3.0) and do something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code class="prettyprint"&gt;var client = storageAccount.CreateCloudBlobClient();
var properties = client.GetServiceProperties();

var cors = new CorsRule();
cors.AllowedOrigins.Add("artfulhacker.com");
cors.AllowedMethods = CorsHttpMethods.Get;
cors.MaxAgeInSeconds = 3600;
properties.Cors.CorsRules.Add(cors);            

client.SetServiceProperties(properties);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want to allow any parent calling domain use this instead:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cors.AllowedOrigins.Add("*");
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;More information on this can be found here:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/dn535601.aspx" target="_blank"&gt;http://msdn.microsoft.com/en-us/library/windowsazure/dn535601.aspx&lt;/a&gt;&lt;/p&gt;</description><link>https://artfulhacker.com/post/68513238081</link><guid>https://artfulhacker.com/post/68513238081</guid><pubDate>Fri, 29 Nov 2013 17:57:00 -0700</pubDate><category>c</category><category>cors</category><category>fonts</category><category>cdn</category><category>azure</category></item><item><title>What are some amazing secrets hidden within Disneyland and Disney World?</title><description>&lt;p&gt;Answer by Mike Olsen:&lt;/p&gt;&lt;blockquote&gt;When Walt originally purchased the land for Disneyland from the Dominguez family they had a stipulation. He had to keep a date palm that was presented to the family in 1896 from the Canary Islands. The tree was a wedding gift and held great sentimental value.&lt;br/&gt;&lt;br/&gt;To me what makes this an amazing hidden secret is the fact that Disneyland has still taken great care of preserving it, even now over a hundred years old it is not only still at the park but you can even touch it!&lt;br/&gt;&lt;br/&gt;Next time you visit the park, go get a fastpass for Indiana Jones, just before you enter the fast pass area, look to the right and you will see it (along with some bamboo growing next to it).&lt;br/&gt;&lt;br/&gt;&lt;div&gt;&lt;img class="qtext_image zoomable_in_feed" src="https://qph.is.quoracdn.net/main-qimg-423be951bf9967dcf7d4920e5bc51d25" master_src="https://qph.is.quoracdn.net/main-qimg-423be951bf9967dcf7d4920e5bc51d25" master_w="292" master_h="350"/&gt;&lt;/div&gt;&lt;br/&gt;This is an &amp;ldquo;amazing hidden secret&amp;rdquo; because it still shows the respect and values of the Disney company. They have owned the land long enough, this tree could easily have been removed by now. You can even see the great care taken when the new Jungle Cruise queue was built.&lt;/blockquote&gt;&lt;a href="http://www.quora.com/Disneyland/What-are-some-amazing-secrets-hidden-within-Disneyland-and-Disney-World/answer/Mike-Olsen-4" target="_blank"&gt;View Answer on Quora&lt;/a&gt;</description><link>https://artfulhacker.com/post/64889616150</link><guid>https://artfulhacker.com/post/64889616150</guid><pubDate>Wed, 23 Oct 2013 13:15:45 -0700</pubDate></item><item><title>Simple JSON Array Methods in C#</title><description>&lt;h1&gt;Echovoice.JSON&lt;/h1&gt;
&lt;p&gt;Echovoice JSON Array Encode, Decode and Pretty methods. Used internally until the public release of &lt;a href="http://ws3v.org" target="_blank"&gt;WS3V&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This library is available on Nuget as &lt;a href="https://www.nuget.org/packages/Echovoice.JSON/" target="_blank"&gt;Echovoice.JSON&lt;/a&gt;.&lt;/p&gt;
&lt;h1&gt;Why?&lt;/h1&gt;
&lt;p&gt;Json.net was too big for simple JSON array encoding and decoding, plus the way to use it was far too complex.&lt;/p&gt;
&lt;p&gt;JavascriptSerializer uses the odd JsonArray class, all we wanted was simple strings, arrays or numbers.&lt;/p&gt;
&lt;h1&gt;Decode Usage&lt;/h1&gt;
&lt;p&gt;Simple JSON array to string array &lt;code&gt;JSONDecoders.DecodeJsStringArray()&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class="csharp"&gt;string input = "[\"philcollins\",\"Ih8PeterG\"]"; string[] result = JSONDecoders.DecodeJsStringArray(input); &amp;lt;/code&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;result[0]: &lt;code&gt;philcollins&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;result[1]: &lt;code&gt;Ih8PeterG&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Complex JSON Array &lt;code&gt;JSONDecoders.DecodeJSONArray()&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class="csharp"&gt;string input = "[14,4,[14,\"data\"],[[5,\"10.186.122.15\"],[6,\"10.186.122.16\"]]]"; string[] result = JSONDecoders.DecodeJSONArray(input); string[] result2 = JSONDecoders.DecodeJSONArray(result[3]); &amp;lt;/code&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;result[0]: &lt;code&gt;14&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;result[1]: &lt;code&gt;4&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;result[2]: &lt;code&gt;[14,"data"]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;result[3]: &lt;code&gt;[[5,"10.186.122.15"],[6,"10.186.122.16"]]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;result2[0]: &lt;code&gt;[5,"10.186.122.15"]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;result2[1]: &lt;code&gt;[6,"10.186.122.16"]&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;Encode Usage&lt;/h1&gt;
&lt;p&gt;Simple object to JSON Array &lt;code&gt;EncodeJsObjectArray()&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class="csharp"&gt;public class dummyObject {     public string fake { get; set; }     public int id { get; set; }      public dummyObject()     {         fake = "dummy";         id = 5;     }      public override string ToString()     {         StringBuilder sb = new StringBuilder();         sb.Append('[');         sb.Append(id);         sb.Append(',');         sb.Append(JSONEncoders.EncodeJsString(fake));         sb.Append(']');          return sb.ToString();     } }  dummyObject[] dummys = new dummyObject[2]; dummys[0] = new dummyObject(); dummys[1] = new dummyObject();  dummys[0].fake = "mike"; dummys[0].id = 29;  string result = JSONEncoders.EncodeJsObjectArray(dummys); &amp;lt;/code&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Result: &lt;code&gt;[[29,"mike"],[5,"dummy"]]&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;Pretty Usage&lt;/h1&gt;
&lt;p&gt;Pretty print JSON Array &lt;code&gt;PrettyPrintJson()&lt;/code&gt; string extension method&lt;/p&gt;
&lt;pre&gt;&lt;code class="csharp"&gt;string input = "[14,4,[14,\"data\"],[[5,\"10.186.122.15\"],[6,\"10.186.122.16\"]]]"; string result = input.PrettyPrintJson(); &amp;lt;/code&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Result:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[
   14,
   4,
   [
      14,
      "data"
   ],
   [
      [
         5,
         "10.186.122.15"
      ],
      [
         6,
         "10.186.122.16"
      ]
   ]
]
&lt;/code&gt;&lt;/pre&gt;</description><link>https://artfulhacker.com/post/73674714971</link><guid>https://artfulhacker.com/post/73674714971</guid><pubDate>Wed, 16 Oct 2013 00:00:00 -0700</pubDate></item><item><title>Use Zopfli Compression in your CDN</title><description>&lt;p&gt;Several months ago Google released &lt;a href="https://code.google.com/p/zopfli/" target="_blank"&gt;Zopfli&lt;/a&gt;, which is a slow (~100 times slower than normal deflate) a compression algorithm that achieves about 4-8% better compression.&lt;/p&gt;
&lt;p&gt;Zopfli has also been adapted to be used in PNG compression:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;ZopfliPNG will do nothing more that read a png file, re-compress the DEFLATED parts (IDAT image data, and if the tool matures other compressed chunks like iTXt, zTXt, and iCCP) and write the modified file.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;When should we use this? The best place to use Zopfli is on your static content, so we choose to use it on our Azure CDN.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Zopfli is a compression algorithm that is compatible with the DEFLATE algorithm used in zlib, allowing it to be used seamlessly with already deployed programs and devices that support the standard. Zopfli produces files that are 4-8% smaller than zlib at the expense of being substantially slower to compress a file than other implementations of the DEFLATE algorithm.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;figure class="tmblr-full" data-orig-height="246" data-orig-width="548" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2159/t1.PNG"&gt;&lt;img alt="Picture" src="https://64.media.tumblr.com/324fb32f980526b9190a6db89c3f1804/tumblr_inline_pk245eMyfM1rfeip2_540.png" data-orig-height="246" data-orig-width="548" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2159/t1.PNG"/&gt;&lt;/figure&gt;&lt;figure class="tmblr-full" data-orig-height="231" data-orig-width="593" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2160/t2.PNG"&gt;&lt;img alt="Picture" src="https://64.media.tumblr.com/087a47c1643984a11284f3112c1c9d91/tumblr_inline_pk245f96VT1rfeip2_540.png" data-orig-height="231" data-orig-width="593" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2160/t2.PNG"/&gt;&lt;/figure&gt;&lt;figure class="tmblr-full" data-orig-height="267" data-orig-width="575" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2161/t3.PNG"&gt;&lt;img alt="Picture" src="https://64.media.tumblr.com/d4c537dab0f6dadf50c341653e10cd36/tumblr_inline_pk245fzlpO1rfeip2_540.png" data-orig-height="267" data-orig-width="575" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2161/t3.PNG"/&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Perfect fit, since CDN files are only uploaded once and compression only needs to happen on upload. Clients downloading compressed files will decompress them using the normal DEFLATE supported everywhere at the same speed (or faster, since they will be smaller in size).&lt;/p&gt;
&lt;p&gt;Our first step was to get Zopfli into C#. So we created a wrapper and released it under Apache 2.0&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/echovoice/libzopfli-sharp" target="_blank"&gt;https://github.com/echovoice/libzopfli-sharp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Nuget Package is also found here: &lt;a href="https://www.nuget.org/packages/libzopfli-sharp" target="_blank"&gt;https://www.nuget.org/packages/libzopfli-sharp&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;PNG Compression Usage&lt;/h1&gt;
&lt;p&gt;If you are working with .Net Image objects simply call &lt;code&gt;SaveAsPNG()&lt;/code&gt; Image extension method.&lt;/p&gt;
&lt;pre&gt;&lt;code class="csharp"&gt;Image testImage = Image.FromFile("files/ev.png"); testImage.SaveAsPNG(path_to_save_compressed_PNG); &amp;lt;/code&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can compress *.PNG files directly using the &lt;code&gt;ZopfliPNG.compress()&lt;/code&gt; method.&lt;/p&gt;
&lt;pre&gt;&lt;code class="csharp"&gt;string path = "files/ev.png"; ZopfliPNG.compress(path); &amp;lt;/code&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We also implemented a derived class of Stream called &lt;code&gt;ZopfliPNGStream&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class="csharp"&gt;byte[] uncompressed = File.ReadAllBytes("files/ev.png"); int before = uncompressed.Length; byte[] compressed; int after = 0;  using (MemoryStream compressStream = new MemoryStream()) using (ZopfliPNGStream compressor = new ZopfliPNGStream(compressStream)) {     compressor.Write(uncompressed, 0, before);     compressor.Close();     compressed = compressStream.ToArray();     after = compressed.Length; } &amp;lt;/code&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In addition to using the default compression options Zopfli exposes some additional options to fine tune compression. We extended this in the &lt;code&gt;ZopfliPNGOptions&lt;/code&gt; object.&lt;/p&gt;
&lt;pre&gt;&lt;code class="csharp"&gt;public class ZopfliPNGOptions {     // Allow altering hidden colors of fully transparent pixels     public Boolean lossy_transparent;      // Convert 16-bit per channel images to 8-bit per channel     public Boolean lossy_8bit;      // Filter strategies to try     public ZopfliPNGFilterStrategy[] filter_strategies;      // Automatically choose filter strategy using less good compression     public Boolean auto_filter_strategy;      // PNG chunks to keep     // chunks to literally copy over from the original PNG to the resulting one     public String[] keepchunks;      // Use Zopfli deflate compression     public Boolean use_zopfli;      // Zopfli number of iterations     public Int32 num_iterations;      // Zopfli number of iterations on large images     public Int32 num_iterations_large;      // 0=none, 1=first, 2=last, 3=both     public Int32 block_split_strategy; } &amp;lt;/code&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Gzip, Deflate and Zlib Compression Usage&lt;/h1&gt;
&lt;p&gt;For all 3 compression types we implemented a derived class of Stream &lt;code&gt;ZopfliStream&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class="csharp"&gt;byte[] uncompressed = File.ReadAllBytes("files/fp.log"); int before = uncompressed.Length; byte[] compressed; int after = 0;  using (MemoryStream compressStream = new MemoryStream()) using (ZopfliStream compressor = new ZopfliStream(compressStream, ZopfliFormat.ZOPFLI_FORMAT_DEFLATE)) {     compressor.Write(uncompressed, 0, before);     compressor.Close();     compressed = compressStream.ToArray();     after = compressed.Length; } &amp;lt;/code&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The second parameter for our derived Stream class is the type of compression to use.&lt;/p&gt;
&lt;pre&gt;&lt;code class="csharp"&gt;public enum ZopfliFormat {     ZOPFLI_FORMAT_GZIP,     ZOPFLI_FORMAT_ZLIB,     ZOPFLI_FORMAT_DEFLATE }; &amp;lt;/code&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In addition to using the default options Zopfli exposes some additional options used to fine tune compression. We extended this in the &lt;code&gt;ZopfliOptions&lt;/code&gt; object which can also be passed into the Stream.&lt;/p&gt;
&lt;pre&gt;&lt;code class="csharp"&gt;public class ZopfliOptions {     // Whether to print output     public Int32 verbose;      // Whether to print more detailed output     public Int32 verbose_more;      // Maximum amount of times to rerun forward and backward pass to optimize LZ77     // compression cost. Good values: 10, 15 for small files, 5 for files over     // several MB in size or it will be too slow.     public Int32 numiterations;      // If true, splits the data in multiple deflate blocks with optimal choice     // for the block boundaries. Block splitting gives better compression. Default:     // true (1).     public Int32 blocksplitting;      // If true, chooses the optimal block split points only after doing the iterative     // LZ77 compression. If false, chooses the block split points first, then does     // iterative LZ77 on each individual block. Depending on the file, either first     // or last gives the best compression. Default: false (0).     public Int32 blocksplittinglast;      // Maximum amount of blocks to split into (0 for unlimited, but this can give     // extreme results that hurt compression on some files). Default value: 15.     public Int32 blocksplittingmax; } &amp;lt;/code&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Where to go from here?&lt;/p&gt;
&lt;p&gt;Now that we have Zopfli working in C# you will want to wrap any of your Azure Blob uploads with the Zopfli stream.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
    CloudConfigurationManager.GetSetting("StorageConnectionString"));

// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");

// Retrieve reference to a blob named "myblob".
CloudBlockBlob blockBlob = container.GetBlockBlobReference("myblob");

// Create or overwrite the "myblob" blob with contents from a local file.
byte[] uncompressed = File.ReadAllBytes(@"path\myfile");
int before = uncompressed.Length;
byte[] compressed;

// test deflate stream compression code
using (MemoryStream compressStream = new MemoryStream())
using (ZopfliStream compressor = new ZopfliStream(compressStream,ZopfliFormat.ZOPFLI_FORMAT_DEFLATE))
{
    compressor.Write(uncompressed, 0, before);
    compressor.Close();
    blockBlob.UploadFromStream(compressStream);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;from MSDN &lt;a href="http://www.windowsazure.com/en-us/develop/net/how-to-guides/blob-storage/" target="_blank"&gt;http://www.windowsazure.com/en-us/develop/net/how-to-guides/blob-storage/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;MSDN has a great write up on enabling the CDN from a Blob.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.windowsazure.com/en-us/develop/net/common-tasks/cdn/" target="_blank"&gt;http://www.windowsazure.com/en-us/develop/net/common-tasks/cdn/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you still need help uploading to Azure or how to determine if compression is supported I would suggest viewing this (slightly outdated) tutorial:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://joelfillmore.com/serving-gzip-compressed-content-from-the-azure-cdn/" target="_blank"&gt;http://joelfillmore.com/serving-gzip-compressed-content-from-the-azure-cdn/&lt;/a&gt;&lt;/p&gt;</description><link>https://artfulhacker.com/post/73674970743</link><guid>https://artfulhacker.com/post/73674970743</guid><pubDate>Wed, 02 Oct 2013 00:00:00 -0700</pubDate></item><item><title>Fix Pixelated Font Icons in Chrome on Windows</title><description>&lt;p&gt;Firstly if you have not made the switch to font based icons, stop reading and check out this (awesome) free icon pack:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://fortawesome.github.io/Font-Awesome/" target="_blank"&gt;http://fortawesome.github.io/Font-Awesome/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So why use fonts instead of images?&lt;/p&gt;
&lt;p&gt;1.) Any size, clean and crisp at any resolution.&lt;/p&gt;
&lt;p&gt;2.) Small, font files are much smaller than a series of images, especially for those creating double sized images to support Retina displays.&lt;/p&gt;
&lt;p&gt;3.) Supported by all legacy, and modern browsers, any platform.&lt;/p&gt;
&lt;p&gt;Before you jump in, you should really check out &lt;a href="http://icomoon.io/app" target="_blank"&gt;IcoMoon&lt;/a&gt; by Keyamoon. I have never used a free web app of this quality before, the author has done a really good job.&lt;/p&gt;
&lt;p&gt;Getting back on topic, if you read here on IcoMoon’s blog: &lt;a href="http://icomoon.io/#post/318" target="_blank"&gt;http://icomoon.io/#post/318&lt;/a&gt; you will discover Chrome running under Windows has some real problems with font rendering.&lt;/p&gt;
&lt;p&gt;Here are some samples from Chrome, IE and Firefox (all on windows)&lt;/p&gt;
&lt;p&gt;Chrome [Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36]:&lt;/p&gt;
&lt;p&gt;&lt;figure data-orig-height="112" data-orig-width="190" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2111/chrome.png"&gt;&lt;img alt="Picture" src="https://64.media.tumblr.com/0798a6553909289a00fbf972cccc8d10/tumblr_inline_pk0xi1PGMA1rfeip2_540.png" data-orig-height="112" data-orig-width="190" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2111/chrome.png"/&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;IE10 [Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)]:&lt;/p&gt;
&lt;p&gt;&lt;figure data-orig-height="112" data-orig-width="190" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2112/ie.png"&gt;&lt;img alt="Picture" src="https://64.media.tumblr.com/c551f9f114b2637ef73e1c5e3f32f507/tumblr_inline_pk0xi2DX4y1rfeip2_540.png" data-orig-height="112" data-orig-width="190" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2112/ie.png"/&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;FF20 [Mozilla/5.0 (Windows NT 6.2; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0]:&lt;/p&gt;
&lt;p&gt;&lt;figure data-orig-height="112" data-orig-width="190" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2113/ff.png"&gt;&lt;img alt="Picture" src="https://64.media.tumblr.com/8121959b65dd779aa82ff25751b86bef/tumblr_inline_pk0xi3EcrJ1rfeip2_540.png" data-orig-height="112" data-orig-width="190" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2113/ff.png"/&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;How do we fix this?&lt;/p&gt;
&lt;p&gt;So the initial solution is to move SVG to the top:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@font-face
{
    font-family: 'echovoice';
        src: url('/fonts/echovoice.svg#echovoice') format('svg');
        ....
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Why is this &lt;strong&gt;BAD&lt;/strong&gt;?&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;ldquo;SVG fonts lack compression and therefore they are very large in size compared to other font formats&amp;rdquo;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Fine, lets use CSS to detect Chrome and force it to use SVG (from &lt;a href="http://stackoverflow.com/questions/13674808/chrome-svg-font-rendering-breaks-layout/14345363#14345363" target="_blank"&gt;stackoverflow.com&lt;/a&gt;)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@font-face
{
    font-family: 'echovoice';
    src:url('/fonts/echovoice.eot');
    src:url('/fonts/echovoice.eot?#iefix') format('embedded-opentype'),
            url('/fonts/echovoice.woff') format('woff'),
            url('/fonts/echovoice.ttf') format('truetype'),
            url('/fonts/echovoice.svg#icomoon') format('svg');
    font-weight: normal;
    font-style: normal;
}
@media screen and (-webkit-min-device-pixel-ratio:0)
{
    @font-face
    {
        font-family: 'echovoice';
        src: url('/fonts/echovoice.svg#echovoice') format('svg');
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Up until now all I have done is reiterate IcoMoon’s blog post.. now for the reason I decided to write this post…&lt;/p&gt;
&lt;p&gt;If you take a look at the network activity under Chrome you will see the following:&lt;/p&gt;
&lt;p&gt;&lt;figure class="tmblr-full" data-orig-height="176" data-orig-width="987" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2114/network.png"&gt;&lt;img alt="Picture" src="https://64.media.tumblr.com/99e6f1bfddec38e85a46fd33cc76a015/tumblr_inline_pk0xi3aKcx1rfeip2_540.png" data-orig-height="176" data-orig-width="987" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2114/network.png"/&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;So it loads both the svg and woff, this isn’t ideal at all.&lt;/p&gt;
&lt;p&gt;My solution is to move the above CSS to a separate stylesheet (echovoice.css), now that noscript tags are legal inside the head&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;noscript&amp;gt;
    &amp;lt;link href='/fonts/echovoice.css' rel='stylesheet' type='text/css'&amp;gt;
&amp;lt;/noscript&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will allow users with js disabled to pull in the styles to load the fonts.&lt;/p&gt;
&lt;p&gt;Then I added the following directly below the noscript tags in the head for our js users&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;script type="text/javascript"&amp;gt;
    var b="&amp;lt;style&amp;gt;@font-face{font-family:'echovoice';src:";/win/.test(navigator.userAgent.toLowerCase())&amp;amp;&amp;amp;/chrom(e|ium)/.test(navigator.userAgent.toLowerCase())||(b+="url('/fonts/echovoice.eot');src:url('/fonts/echovoice.eot?#iefix') format('embedded-opentype'),url('/fonts/echovoice.woff') format('woff'),url('/fonts/echovoice.ttf') format('truetype'),");b+="url('/fonts/echovoice.svg#icomoon') format('svg');font-weight:normal;font-style:normal}&amp;lt;/style&amp;gt;";
    document.write(b);
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What this simply does is test for the combination of chrome and windows, if that combination is found then it will only write the svg path for src, otherwise it will write paths for all the font options.&lt;/p&gt;
&lt;p&gt;Success, only the SVG file is downloaded in Chrome under Windows and no more fuzzy icons!&lt;/p&gt;</description><link>https://artfulhacker.com/post/73675189585</link><guid>https://artfulhacker.com/post/73675189585</guid><pubDate>Thu, 26 Sep 2013 00:00:00 -0700</pubDate></item><item><title>How to delete a project in Team Foundation Service (tfs.visualstudio.com)</title><description>&lt;p&gt;UPDATE: As of today there still isn’t a UI based option to remove a project in Team Foundation Service.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://stackoverflow.com/questions/13635889/delete-team-project-from-team-foundation-service/20061822#20061822" target="_blank"&gt;http://stackoverflow.com/questions/13635889/delete-team-project-from-team-foundation-service/20061822#20061822&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So how do we do it?&lt;/p&gt;
&lt;p&gt;Turns out to be much simpler than I had mentally prepared myself for.&lt;/p&gt;
&lt;p&gt;Open Administrator Command Prompt (win+x a), change directory to:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The run the following command substituting the values inside the [ ] brackets.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;TFSDeleteProject.exe /collection:"https://[name].visualstudio.com/DefaultCollection" "[project name]"
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You should then see a warning, press y to delete the project. Done.&lt;/p&gt;
&lt;p&gt;&lt;figure class="tmblr-full" data-orig-height="388" data-orig-width="672" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2028/TFSCapture.PNG"&gt;&lt;img alt="Picture" src="https://64.media.tumblr.com/0c6efed0db16a7c6c96ce98cfb2e25f4/tumblr_inline_pk17wklal71rfeip2_540.png" data-orig-height="388" data-orig-width="672" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2028/TFSCapture.PNG"/&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Note: I have VS2012 installed, and VS is already joined to my Team Foundation Service.&lt;/p&gt;</description><link>https://artfulhacker.com/post/73675524247</link><guid>https://artfulhacker.com/post/73675524247</guid><pubDate>Tue, 27 Aug 2013 00:00:00 -0700</pubDate></item><item><title>Latest Web UI Trend: Ajax Loading Bars</title><description>&lt;p&gt;When loading content in via ajax web browsers do not usually give clear indication they are fetching additional content. This is typically found with endless scrolling sites, however the latest UI trend as seen on Medium and Youtube is a top animated loading bar when fetching additional content. Here is a screenshot of the medium example:&lt;/p&gt;
&lt;p&gt;&lt;figure class="tmblr-full" data-orig-height="267" data-orig-width="744" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2003/medium.PNG"&gt;&lt;img alt="Picture" src="https://64.media.tumblr.com/5b443948d69de966fbcfe03761cc8a2a/tumblr_inline_pjzogsOiwZ1rfeip2_540.png" data-orig-height="267" data-orig-width="744" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2003/medium.PNG"/&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;So how do they do it?&lt;/p&gt;
&lt;p&gt;Well lets start with some basic HTML/CSS. When using developer tools in chrome on the page I noticed that they kept adding a class to the body tag:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;app-loading
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So I added the class manually and the loading bar showed up and stayed put.Still using developer tools I found the div that made up the loading bar down at the bottom of the html right above the closing script tags. here is the HTML that makes up the loading bar:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;div class="loading-bar"&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Super simple so far, now the CSS, by default the style applied is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;.loading-bar
{
    position: fixed;
    display: none;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    z-index: 800;
    background: #60d778;
    -webkit-transform: translateX(100%);
    -moz-transform: translateX(100%);
    -o-transform: translateX(100%);
    transform: translateX(100%);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Notice the &lt;strong&gt;display: none;&lt;/strong&gt; This hides the bar from view initially. When we continue to look through the CSS we see that app-loading class overrides this default display: none.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;.app-loading .loading-bar
{
    display: block;
    -webkit-animation: shift-rightwards 1s ease-in-out infinite;
    -moz-animation: shift-rightwards 1s ease-in-out infinite;
    -ms-animation: shift-rightwards 1s ease-in-out infinite;
    -o-animation: shift-rightwards 1s ease-in-out infinite;
    animation: shift-rightwards 1s ease-in-out infinite;
    -webkit-animation-delay: .4s;
    -moz-animation-delay: .4s;
    -o-animation-delay: .4s;
    animation-delay: .4s;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So by adding the app-loading class to the body while loading content into the page, you effectively get an animated loading bar fixed to the top of the page.&lt;/p&gt;
&lt;p&gt;Last code sample is the CSS3 animation we “hijacked” from Medium, they called it: shift-rightwards, so lets give that developer credit and keep the name in the demo.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@-webkit-keyframes shift-rightwards
{
    0%
    {
        -webkit-transform:translateX(-100%);
        -moz-transform:translateX(-100%);
        -o-transform:translateX(-100%);
        transform:translateX(-100%);
    }

    40%
    {
        -webkit-transform:translateX(0%);
        -moz-transform:translateX(0%);
        -o-transform:translateX(0%);
        transform:translateX(0%);
    }

    60%
    {
        -webkit-transform:translateX(0%);
        -moz-transform:translateX(0%);
        -o-transform:translateX(0%);
        transform:translateX(0%);
    }

    100%
    {
        -webkit-transform:translateX(100%);
        -moz-transform:translateX(100%);
        -o-transform:translateX(100%);
        transform:translateX(100%);
    }

}
@-moz-keyframes shift-rightwards
{
    0%
    {
        -webkit-transform:translateX(-100%);
        -moz-transform:translateX(-100%);
        -o-transform:translateX(-100%);
        transform:translateX(-100%);
    }

    40%
    {
        -webkit-transform:translateX(0%);
        -moz-transform:translateX(0%);
        -o-transform:translateX(0%);
        transform:translateX(0%);
    }

    60%
    {
        -webkit-transform:translateX(0%);
        -moz-transform:translateX(0%);
        -o-transform:translateX(0%);
        transform:translateX(0%);
    }

    100%
    {
        -webkit-transform:translateX(100%);
        -moz-transform:translateX(100%);
        -o-transform:translateX(100%);
        transform:translateX(100%);
    }

}
@-o-keyframes shift-rightwards
{
    0%
    {
        -webkit-transform:translateX(-100%);
        -moz-transform:translateX(-100%);
        -o-transform:translateX(-100%);
        transform:translateX(-100%);
    }

    40%
    {
        -webkit-transform:translateX(0%);
        -moz-transform:translateX(0%);
        -o-transform:translateX(0%);
        transform:translateX(0%);
    }

    60%
    {
        -webkit-transform:translateX(0%);
        -moz-transform:translateX(0%);
        -o-transform:translateX(0%);
        transform:translateX(0%);
    }

    100%
    {
        -webkit-transform:translateX(100%);
        -moz-transform:translateX(100%);
        -o-transform:translateX(100%);
        transform:translateX(100%);
    }

}
@keyframes shift-rightwards
{
    0%
    {
        -webkit-transform:translateX(-100%);
        -moz-transform:translateX(-100%);
        -o-transform:translateX(-100%);
        transform:translateX(-100%);
    }

    40%
    {
        -webkit-transform:translateX(0%);
        -moz-transform:translateX(0%);
        -o-transform:translateX(0%);
        transform:translateX(0%);
    }

    60%
    {
        -webkit-transform:translateX(0%);
        -moz-transform:translateX(0%);
        -o-transform:translateX(0%);
        transform:translateX(0%);
    }

    100%
    {
        -webkit-transform:translateX(100%);
        -moz-transform:translateX(100%);
        -o-transform:translateX(100%);
        transform:translateX(100%);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Easy enough, so how can we apply this to our own websites?&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;Just before making an ajax request add the class &lt;strong&gt;app-loading&lt;/strong&gt; to the &amp;lt; body / &amp;gt; tag.&lt;/li&gt;
&lt;li&gt;After the ajax has finished (make sure also to catch on timeout or error) remove the class from the body tag.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;Full Working Example using jQuery:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jsfiddle.net/MuVaa/" target="_blank"&gt;http://jsfiddle.net/MuVaa/&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;meta charset="utf-8"&amp;gt;
&amp;lt;title&amp;gt;Loading Bar Sample&amp;lt;/title&amp;gt;
&amp;lt;style&amp;gt;
.app-loading .loading-bar
{
    display: block;
    -webkit-animation: shift-rightwards 1s ease-in-out infinite;
    -moz-animation: shift-rightwards 1s ease-in-out infinite;
    -ms-animation: shift-rightwards 1s ease-in-out infinite;
    -o-animation: shift-rightwards 1s ease-in-out infinite;
    animation: shift-rightwards 1s ease-in-out infinite;
    -webkit-animation-delay: .4s;
    -moz-animation-delay: .4s;
    -o-animation-delay: .4s;
    animation-delay: .4s;
}
.loading-bar
{
    position: fixed;
    display: none;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    z-index: 800;
    background: #60d778;
    -webkit-transform: translateX(100%);
    -moz-transform: translateX(100%);
    -o-transform: translateX(100%);
    transform: translateX(100%);
}

@-webkit-keyframes shift-rightwards
{
    0%
    {
        -webkit-transform:translateX(-100%);
        -moz-transform:translateX(-100%);
        -o-transform:translateX(-100%);
        transform:translateX(-100%);
    }

    40%
    {
        -webkit-transform:translateX(0%);
        -moz-transform:translateX(0%);
        -o-transform:translateX(0%);
        transform:translateX(0%);
    }

    60%
    {
        -webkit-transform:translateX(0%);
        -moz-transform:translateX(0%);
        -o-transform:translateX(0%);
        transform:translateX(0%);
    }

    100%
    {
        -webkit-transform:translateX(100%);
        -moz-transform:translateX(100%);
        -o-transform:translateX(100%);
        transform:translateX(100%);
    }

}
@-moz-keyframes shift-rightwards
{
    0%
    {
        -webkit-transform:translateX(-100%);
        -moz-transform:translateX(-100%);
        -o-transform:translateX(-100%);
        transform:translateX(-100%);
    }

    40%
    {
        -webkit-transform:translateX(0%);
        -moz-transform:translateX(0%);
        -o-transform:translateX(0%);
        transform:translateX(0%);
    }

    60%
    {
        -webkit-transform:translateX(0%);
        -moz-transform:translateX(0%);
        -o-transform:translateX(0%);
        transform:translateX(0%);
    }

    100%
    {
        -webkit-transform:translateX(100%);
        -moz-transform:translateX(100%);
        -o-transform:translateX(100%);
        transform:translateX(100%);
    }

}
@-o-keyframes shift-rightwards
{
    0%
    {
        -webkit-transform:translateX(-100%);
        -moz-transform:translateX(-100%);
        -o-transform:translateX(-100%);
        transform:translateX(-100%);
    }

    40%
    {
        -webkit-transform:translateX(0%);
        -moz-transform:translateX(0%);
        -o-transform:translateX(0%);
        transform:translateX(0%);
    }

    60%
    {
        -webkit-transform:translateX(0%);
        -moz-transform:translateX(0%);
        -o-transform:translateX(0%);
        transform:translateX(0%);
    }

    100%
    {
        -webkit-transform:translateX(100%);
        -moz-transform:translateX(100%);
        -o-transform:translateX(100%);
        transform:translateX(100%);
    }

}
@keyframes shift-rightwards
{
    0%
    {
        -webkit-transform:translateX(-100%);
        -moz-transform:translateX(-100%);
        -o-transform:translateX(-100%);
        transform:translateX(-100%);
    }

    40%
    {
        -webkit-transform:translateX(0%);
        -moz-transform:translateX(0%);
        -o-transform:translateX(0%);
        transform:translateX(0%);
    }

    60%
    {
        -webkit-transform:translateX(0%);
        -moz-transform:translateX(0%);
        -o-transform:translateX(0%);
        transform:translateX(0%);
    }

    100%
    {
        -webkit-transform:translateX(100%);
        -moz-transform:translateX(100%);
        -o-transform:translateX(100%);
        transform:translateX(100%);
    }
}
&amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;div&amp;gt;random content here&amp;lt;/div&amp;gt;
&amp;lt;div class="loading-bar"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script&amp;gt;
$(function()
{
    $("body").addClass("app-loading");
    $.get("some-test-page.html", function(data)
    {
        $("body").removeClass("app-loading");
    });
})
&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;figure class="tmblr-full" data-orig-height="354" data-orig-width="861" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2004/devbay01.png"&gt;&lt;img alt="Picture" src="https://64.media.tumblr.com/9bd604f5ec2890b73b3b90b77f2ef35f/tumblr_inline_pjzogs5kRW1rfeip2_540.png" data-orig-height="354" data-orig-width="861" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/2004/devbay01.png"/&gt;&lt;/figure&gt;&lt;/p&gt;</description><link>https://artfulhacker.com/post/73675687210</link><guid>https://artfulhacker.com/post/73675687210</guid><pubDate>Tue, 20 Aug 2013 00:00:00 -0700</pubDate></item><item><title>Windows Azure Caching Failure (ES0006)</title><description>&lt;p&gt;So this issue has been driving us nuts for almost 2 weeks, Azure updated its NuGet package for Caching, and anyone who recently updated it but still had projects running SDK 2.0 will most likely miss this highlighted section:&lt;/p&gt;
&lt;p&gt;&lt;figure class="tmblr-full" data-orig-height="745" data-orig-width="900" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/1973/Capture.PNG"&gt;&lt;img alt="Picture" src="https://64.media.tumblr.com/74255d8f38fd4b97738057effc31cf46/tumblr_inline_pk0bbrWAaP1rfeip2_540.png" data-orig-height="745" data-orig-width="900" data-orig-src="https://coderwall-assets-0.s3.amazonaws.com/uploads/picture/file/1973/Capture.PNG"/&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;This is the error message we kept seeing repeatedly in the cloud as well as the emulator:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;ES0006&amp;gt;:There is a temporary failure. Please retry later. (One or more specified cache servers are unavailable, which could be caused by busy network or servers. For on-premises cache clusters, also verify the following conditions. Ensure that security permission has been granted for this client account, and check that the AppFabric Caching Service is allowed through the firewall on all cache hosts. Also the MaxBufferSize on the server must be greater than or equal to the serialized object size sent from the client.)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This fix? Simply update your azure &lt;a href="http://www.windowsazure.com/en-us/downloads/?sdk=net" target="_blank"&gt;SDK to &amp;gt;2.0&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I hope this helps anyone having this same issue!&lt;/p&gt;</description><link>https://artfulhacker.com/post/73675804588</link><guid>https://artfulhacker.com/post/73675804588</guid><pubDate>Mon, 12 Aug 2013 00:00:00 -0700</pubDate></item><item><title>Regex-less JSONP callback validation via LINQ magic</title><description>&lt;p&gt;For JSONP calls we should always restrict and validate the callback parameter to prevent code injections and other hacker attacks.&lt;/p&gt;
&lt;p&gt;To do this we usually set a max size and only allow alphanumeric characters and underscores.&lt;/p&gt;
&lt;p&gt;Most developers would turn to regex but I prefer to do things regex-less, in C# we can validate the string &lt;em&gt;callback&lt;/em&gt; as seen in this code snippet below using some LINQ magic:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if (!callback.ToCharArray().All(c =&amp;gt; Char.IsLetter(c) || Char.IsNumber(c) || c == '_')))

    return "illegal callback, can only contain alphanumeric characters and underscores";
&lt;/code&gt;&lt;/pre&gt;</description><link>https://artfulhacker.com/post/73675903940</link><guid>https://artfulhacker.com/post/73675903940</guid><pubDate>Wed, 07 Aug 2013 00:00:00 -0700</pubDate></item><item><title>How to get HttpContextBase from HttpContext.Current in the Global.asax?</title><description>&lt;p&gt;In order to implement server-side google analytics tracking into our API for request monitoring we decided to give this library a try:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/maartenba/GoogleAnalyticsTracker" target="_blank"&gt;https://github.com/maartenba/GoogleAnalyticsTracker&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In order to get this example below to work inside the Global.asax file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Tracker tracker = new Tracker("UA-XXXXXX-XX", "www.example.org");
tracker.TrackPageView(HttpContext, "My API - Create");
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I needed to somehow cast HttpContext.Current into the abstract class HttpContextBase.&lt;/p&gt;
&lt;p&gt;Turns out it is as simple as:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;new HttpContextWrapper(HttpContext.Current)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;so the example becomes:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Tracker tracker = new Tracker("UA-XXXXXX-XX", "www.example.org");
tracker.TrackPageView(new HttpContextWrapper(HttpContext.Current), "My API - Create");
&lt;/code&gt;&lt;/pre&gt;</description><link>https://artfulhacker.com/post/73675993882</link><guid>https://artfulhacker.com/post/73675993882</guid><pubDate>Sat, 20 Jul 2013 00:00:00 -0700</pubDate></item><item><title>Determine if a class is running in Azure and if it is actually in the cloud vs. the emulator</title><description>&lt;p&gt;We needed to determine if a class was running in Azure and if so whether it was actually in the cloud or being emulated locally.&lt;/p&gt;
&lt;p&gt;Turns out this is very simple to do, just add a reference to:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Microsoft.WindowsAzure.ServiceRuntime
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then use these two static booleans, notice the try/catch blocks, 32 bit processes throw an error here, so reporting false in the catch remedies that.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public static bool InAzureEnvironment
{
    get
    {
        try
        {
            return RoleEnvironment.IsAvailable;
        }
        catch { return false; }
    }
}

public static bool InCloud
{
    get
    {
        try
        {
            return InAzureEnvironment &amp;amp;&amp;amp; !RoleEnvironment.IsEmulated;
        }
        catch { return false; }
    }
}
&lt;/code&gt;&lt;/pre&gt;</description><link>https://artfulhacker.com/post/73676122392</link><guid>https://artfulhacker.com/post/73676122392</guid><pubDate>Tue, 09 Jul 2013 00:00:00 -0700</pubDate></item><item><title>How do I exclude a specific files from TFS 2012 source control?</title><description>&lt;p&gt;It is way easier that in previous versions of TFS, simply create a &lt;a href="http://msdn.microsoft.com/en-us/library/tfs/ms245454%28v=vs.110%29.aspx#tfignore" target="_blank"&gt;.tfignore&lt;/a&gt; file.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;######################################
# Ignore .cpp files in the ProjA sub-folder and all its subfolders
ProjA\*.cpp
# 
# Ignore .txt files in this folder 
\*.txt
#
# Ignore .xml files in this folder and all its sub-folders
*.xml
#
# Ignore all files in the Temp sub-folder
\Temp
#
# Do not ignore .dll files in this folder nor in any of its sub-folders
!*.dll
&lt;/code&gt;&lt;/pre&gt;</description><link>https://artfulhacker.com/post/73676207010</link><guid>https://artfulhacker.com/post/73676207010</guid><pubDate>Tue, 09 Jul 2013 00:00:00 -0700</pubDate></item><item><title>Google Analytics QUnit testing without needing ga.js</title><description>&lt;p&gt;I recently needed to do some QUnit testing on some code that interacted with google analytics in javascript.&lt;/p&gt;
&lt;p&gt;Specifically, firing some standard ga logic that read a custom var (slot 4) using this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;_gat._getTrackerByName()._getVisitorCustomVar(4);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In order to not load ga.js in the test I decided to mock these methods so that the code could be tested in QUnit, the following code will set the custom var to the string ‘asu’ so it can be read later in the code using the normal custom var method:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;var customvar4 = undefined;

function _tracker()
{
    this._getVisitorCustomVar=_getVisitorCustomVar;
    function _getVisitorCustomVar(i)
    {
        return customvar4;
    }
}

// test the initial mocks
test( "test initial mocks", function()
{
    // setup ga mocks
    custom_gat =
    {
        _getTrackerByName: function()
        {
            return new _tracker();
        }
    }

    customvar4 = 'asu';

    function _tracker()
    {
        this._getVisitorCustomVar=_getVisitorCustomVar;
        function _getVisitorCustomVar(i)
        {
            return customvar4;
        }
    }
    (function(_gat)
    {
        equal( _gat._getTrackerByName()._getVisitorCustomVar(4), "asu", "we expect asu to be in the ga mock" );
    })(custom_gat);
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Obviously this can be expanding on by adding more of the ga methods but this should help you get started. Also you will notice I ignore the slot number, add a switch to the method if you need specific slot data.&lt;/p&gt;</description><link>https://artfulhacker.com/post/73676317001</link><guid>https://artfulhacker.com/post/73676317001</guid><pubDate>Tue, 09 Jul 2013 00:00:00 -0700</pubDate></item><item><title>QUnit unit testing in js, window.location mocks</title><description>&lt;p&gt;So recently I need to unit test some js code but this code used the window.location.host variable, and in order to fully test the logic I had to mock the window.location global var.&lt;/p&gt;
&lt;p&gt;In case anyone ever has to do something similar here is a snippet that works with &lt;a href="http://qunitjs.com/" target="_blank"&gt;QUnit&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;test( "test initial mocks", function()
{
    custom_window =
    {
        location:
        {
            host: "test.asu.edu"
        }
    };

    (function(window)
    {
        equal( window.location.host, "test.asu.edu", "we expect test.asu.edu to be in the window.host mock" );
    })(custom_window);
});
&lt;/code&gt;&lt;/pre&gt;</description><link>https://artfulhacker.com/post/73676383337</link><guid>https://artfulhacker.com/post/73676383337</guid><pubDate>Tue, 09 Jul 2013 00:00:00 -0700</pubDate></item><item><title>.net SecureString but what about other data types?</title><description>&lt;p&gt;I have used secure string before but now I needed to protect other types of objects in memory, what is the best way to do this?&lt;/p&gt;
&lt;p&gt;Start with the following example, taken from &lt;a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.protecteddata.protect.aspx" target="_blank"&gt;here&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;using System;
using System.Security.Cryptography;

public class DataProtectionSample
{
// Create byte array for additional entropy when using Protect method. 
    static byte [] s_aditionalEntropy = { 9, 8, 7, 6, 5 };

public static void Main()
{
// Create a simple byte array containing data to be encrypted. 

byte [] secret = { 0, 1, 2, 3, 4, 1, 2, 3, 4 };

//Encrypt the data. 
    byte [] encryptedSecret = Protect( secret );
    Console.WriteLine("The encrypted byte array is:");
    PrintValues(encryptedSecret);

// Decrypt the data and store in a byte array. 
    byte [] originalData = Unprotect( encryptedSecret );
    Console.WriteLine("{0}The original data is:", Environment.NewLine);
    PrintValues(originalData);

}

public static byte [] Protect( byte [] data )
{
    try
    {
        // Encrypt the data using DataProtectionScope.CurrentUser. The result can be decrypted 
        //  only by the same current user. 
        return ProtectedData.Protect( data, s_aditionalEntropy, DataProtectionScope.CurrentUser );
    } 
    catch (CryptographicException e)
    {
        Console.WriteLine("Data was not encrypted. An error occurred.");
        Console.WriteLine(e.ToString());
        return null;
    }
}

public static byte [] Unprotect( byte [] data )
{
    try
    {
        //Decrypt the data using DataProtectionScope.CurrentUser. 
        return ProtectedData.Unprotect( data, s_aditionalEntropy, DataProtectionScope.CurrentUser );
    } 
    catch (CryptographicException e)
    {
        Console.WriteLine("Data was not decrypted. An error occurred.");
        Console.WriteLine(e.ToString());
        return null;
    }
}

public static void PrintValues( Byte[] myArr )  
{
      foreach ( Byte i in myArr )  
        {
             Console.Write( "\t{0}", i );
         }
  Console.WriteLine();
 }

}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Use these methods in this example to protect objects held in memory, all .net objects can be represented with a byte array some with native methods to serialize and deserialize them. You could then use public get and set methods to retrieve and store the data.&lt;/p&gt;
&lt;p&gt;The following shows how we can store a guid in a class using protected data:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public Guid secureGUID
{
    get
    {
        return new Guid(Unprotect(_secureGUID));
    }
    set
    {
        _secureGUID = Protect(value.ToByteArray());
    }
}

private byte[] _secureGUID;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The other thing you will want to make sure you do is run the Array.Clear on dispose of the class, to ensure the array data has been overwritten with zeros in memory.&lt;/p&gt;</description><link>https://artfulhacker.com/post/73676475065</link><guid>https://artfulhacker.com/post/73676475065</guid><pubDate>Mon, 08 Jul 2013 00:00:00 -0700</pubDate></item><item><title>The name 'ProtectedData' does not exist in the current context</title><description>&lt;p&gt;Using the .net &lt;a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.protecteddata.protect.aspx" title="ProtectedData.Protect" target="_blank"&gt;ProtectedData.Protect&lt;/a&gt; method is great way to secure in memory data.&lt;/p&gt;
&lt;p&gt;However if it isn’t obvious and you try to compile but receive this message&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The name ‘ProtectedData’ does not exist in the current context, and The name ‘DataProtectionScope’ does not exist in the current context&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The fix is you need to manually add the System.Security as a reference.&lt;/p&gt;</description><link>https://artfulhacker.com/post/73676557649</link><guid>https://artfulhacker.com/post/73676557649</guid><pubDate>Mon, 08 Jul 2013 00:00:00 -0700</pubDate></item></channel></rss>
