m0sa.net

using System;

  • So long blogger

    It’s been almost 10 years since my first blog posts, and I’ve totally neglected blogging in the past year. I totally blame blogger for that. I really want to blog more, so I’ve decided to move to a simpler setup, that’ll allow me to blog more quickly, with better tools.

    Read more…
  • Roslyn Adventures: Metaprogramming with StackExchange.Precompilation

    In this article we’ll wrap the StringBuilderInterpolationOptimizer from my previous article into an StackExchange.Precompiltion module, and use it to optimize an existing C# project. First things first, we start off with an empty console project, to which we add some sample StringBuilder.

    Read more…
  • Roslyn Adventures: Optimizing StringBuilder string interpolation

    C# string interpolation is awesome. But we can make it even more awesome by making it less wasteful. Consider this line of code: new StringBuilder().Append($"foo {1}"); Currently Roslyn emits the following IL for this call:

    Read more…
  • Roslyn Adventures: Walk the #line

    With Roslyn, C# developers now have a powerful tool which makes modifying the source code a breeze. At Stack Exchange we’ve invented our own little set of extension to C# for localization purposes, previously described on Matt Jibson’s blog.

    Read more…
  • ZeroMQ XPUB sockets

    I was wlaying around with the new XPUB & XSUB ZeroMQ socket types that allow subscription forwarding, e.g. the producer (XPUB) can track what values he has to produce, which comes in handy when the value production is an expensive operation and the producer cannot afford to produce all values.

    Read more…
  • C# gotcha

    Consider you have the following code: SomeClass reference = null; Console.WriteLine(reference.Echo("echo")); Your first thought might be NullReferenceException. Ha, think again! What if you have an class defining an extension method like this:

    Read more…
  • Async Producer-Consumer with Linq, IEnumerable<T> and Threading.Tasks

    Lately I’ve been dealing a lot with IEnumerable classes and the yield return keyword. I found it really useful for stream like processing of otherwise really memory consuming operations. The workflow looks like this:

    Read more…
  • Unit Testing JsonResult Actions

    Today I had to write a unit test for a Asp.net MVC controller that returned a JsonResult. The Controller’s code looked somewhat like this: [HttpPost] public JsonResult JsonData(Query query) { // .

    Read more…
  • Obfuscated JS Hello World CodeGolf

    Finally the codegolf Stackexchange site is in beta. So I decided to give it a try, as I found this nice codegolf: So…. Behold my solution with JavaScript: javascript:(_=(_=[][(f=!!(_='')+_)[3]+(b=({}+_)[1])+($=(c=(d=!_+_)[1])+d[0])])())[f[1]+'l'+(a=d[3])+$]("H"+a+'ll'+b+' W'+b+c+'ld'); Feel free to try it out.

    Read more…
  • jQuery.validation breaks jQuery 1.5 ajax API

    Today I found out (the hard way) that the use of the jQuery.validation plugin breaks the jQuery.ajax API. Since the Asp.net MVC 3 uses jQuery.validation for its unobtrusive validation it is included in the default project template.

    Read more…