tag:blogger.com,1999:blog-3012417362420078942024-03-14T09:30:40.313+01:00blog.m0sa.netusing System;Unknownnoreply@blogger.comBlogger22125tag:blogger.com,1999:blog-301241736242007894.post-72369890420937121252016-01-24T20:22:00.000+01:002016-01-25T16:33:53.866+01:00Roslyn Adventures: Metaprogramming with StackExchange.PrecompilationIn 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.Append calls, passing interpolated strings as parameters:
Now, let's add the Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-301241736242007894.post-28838874620123391232015-10-19T10:20:00.002+02:002015-10-19T10:49:17.015+02:00Roslyn Adventures: Optimizing StringBuilder string interpolationC# string interpolation is awesome. But we can make it even more awesome by making it less wasteful. Consider this line of code:
Currently Roslyn emits the following IL for this call:
You see what it does there? Let's translate that back to C#, to make it more obvious:
It allocates another string and possibly even another StringBuilder. The thing is, you wouldn't be using a StringBuilder ifUnknownnoreply@blogger.com1tag:blogger.com,1999:blog-301241736242007894.post-37655191130029009302014-11-14T12:09:00.001+01:002015-10-19T10:21:56.765+02:00Localization Adventures: Walk the #line
Intro
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. The project originally supported ASP.NET MVC views only, but we’ve expanded it to C# source files (.cs) because our projects have strings that simply Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-301241736242007894.post-27809682845842111512012-09-27T20:54:00.001+02:002012-09-27T20:59:36.046+02:00Aggregating Shared Google Reader Posts in the Google+ EraEver since Google overhauled the reader and removed the original share button I was searching for a way to get to my shared items in the RSS form. None of the online suggested solutions was acceptable for me so I figured, since I already have ASP.NET hosting, that creating a new site, that would tap into the Google+ API and parse the shared posts as RSS would be the way to go. Fortunately that Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-301241736242007894.post-16667571750241456512012-04-04T00:41:00.000+02:002012-04-04T00:41:16.522+02:00ZeroMQ XPUB socketsPlaying 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.
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-301241736242007894.post-36925106229502676412011-04-14T23:20:00.001+02:002011-04-14T23:20:51.832+02:00C# gotchaConsider 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:public static class SomeClassExt { public static string Echo(this SomeClass x, string str) { return str; }}You have been warned :) Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-301241736242007894.post-28396396259946248382011-03-09T23:58:00.001+01:002011-03-10T00:14:09.641+01:00Async Producer-Consumer with Linq, IEnumerable<T> and Threading.TasksLately I’ve been dealing a lot with IEnumerable<T> 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:- Retrieve Item 1 (yield return)- Process Item 1 (GetNext())- ….- Retrieve Item N- Process Item N The total time it takes to process the whole operation is: N x AvgTime(Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-301241736242007894.post-77864156528982854502011-02-10T16:22:00.001+01:002011-02-10T16:29:42.911+01:00MVC – Unit Testing JsonResult ActionsToday 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){ // ... process query, get total_row_cnt and rows return Json(new { total_row_cnt = rowCount, rows }); }I often return anonymous types as JsonResult, just because I don’t want to have additional return model Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-301241736242007894.post-90251226725978380252011-02-04T01:55:00.001+01:002011-02-04T01:58:13.120+01:00Obfuscated 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. Just paste it in your browser's address bar and let it do the magic.Well if you Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-301241736242007894.post-46861139032708708002011-02-03T00:44:00.001+01:002011-02-03T01:55:34.844+01:00jQuery.validation breaks jQuery 1.5 ajax APIToday 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. You can imagine my surprise when I updated jQuery to v1.5, and my heavy ajaxified MVC page stopped working correctly. Every ajax request contained an parseerror with Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-301241736242007894.post-2857450442841696522010-12-14T21:54:00.002+01:002010-12-14T23:24:26.286+01:00inJsect – a JavaScript injection utilityToday I was fooling around on how to launch external JavaScript files in web pages. As a result a small utility called inJsect was created. Feel free to fork the code on jsfiddle (BTW great platform). The final peace of the puzzle is a link that you can bookmark so you can run the tool from the toolbar of your browser (bookmarklet). inJsect (drag&drop to your toolbar) I host the code on Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-301241736242007894.post-11050749047421095792010-11-24T23:19:00.012+01:002010-11-25T00:04:52.412+01:00KOTO - KO Tournament OrganiserI recently released my KnockOut Tournament Organiser (short. KOTO) application to the public. The application can be used to help you organise any kind of knockout elimination tournament events (karate, tennis, ...)FeaturesIntuitive entry form, requiring minimal effortAutomatic draw (random, custom)Simple billing system (global entry fee, customizable per category)Draw printing and export to XSLXUnknownnoreply@blogger.com1tag:blogger.com,1999:blog-301241736242007894.post-82019588147420446322010-04-15T10:20:00.002+02:002010-04-15T10:34:46.300+02:00Čakanje na AppFabric RTMKot že veste je 12.4.2010 bil dan-d, dolgo pričakovani datum, na katerega sta izšla .net ogrodje verzije 4 in Visual Studio 2010. Seveda smo pred tem vsi z velikim zagonom uporabljali beta in RC verzije, posebaj po ogledu videjev iz PDC. Tam sem tudi naletel na novo tehnologiji "velocity" in "dublin" združeni v novo platform za okenske strežnike imenovano Windows Server AppFabric.Seveda sem v Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-301241736242007894.post-85523357054196937002009-06-02T21:08:00.002+02:002009-06-02T21:13:56.541+02:00Semantic movie searchPri predmetu ekspertni sistemi smo s kolegi naredili zanimiv projekt za sikanje filmov, ki se trenutno predvajajo v slovenskihi kinematografih. S pomočjo xml sporedov Koloseja in Planeta Tuš ter imdb.com smo zgradili sistem, ki enkrat dnevno zgradi semantično mrežo vseh filmov, ki so trenutno na sporedu. Po teh podatkih je potem mogoče povpraševati z lastnimi SPARQL povpraševanji ali pa z že Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-301241736242007894.post-67885730870413668292009-05-23T10:05:00.002+02:002009-05-23T10:09:01.213+02:00Kako WolframAlpha vidi SlovenijoŽalosno, kajne?Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-301241736242007894.post-32249223902716194372009-02-12T15:59:00.004+01:002009-02-12T16:07:32.299+01:00Bedarije - prvičUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-301241736242007894.post-74733497462060279762008-12-19T11:26:00.003+01:002008-12-20T10:57:14.398+01:00m0sa - mormon?Ta izredno zabaven članek me je opredelil kot mormona. Koliko je resnice v tem odločite sami. Naj pa povem, da ne mislim prestopiti v nobeno drugo "religijo".Med tem pa si še vedno prepevam odo snihu, katerega pa v Mariboru letos žal ne bom dočakal. Na srečo se nam je uspelo na faksu dogovoriti, da vse obveznosti naslednjega tedna "prestavimo", tako da se sedaj odpravljam domov.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-301241736242007894.post-12572121566986839722008-12-06T00:34:00.003+01:002008-12-06T00:36:33.654+01:00Moje share-ane rss novice iz google readerjaZa vse, ki vas zanima katere RSS novice so mi še posebaj zanimive, a vas nimam dodanih kot prijatelje na googlovem računu :) http://www.google.com/reader/shared/02236268932350252017Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-301241736242007894.post-54494457837372043342008-11-28T12:30:00.003+01:002008-11-28T12:34:30.470+01:00BBCode parser kontrola za WPF/SilverlightNa strani codeproject.com sem objavil majhno kontrolo, ki vam omogoči definiranj lastnih BBKod (ki jih vsi poznate iz phpBB forumov) in njihov prikaz v Silverlight WPF aplikacijah.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-301241736242007894.post-15271855930158003372008-11-20T23:57:00.009+01:002008-11-24T23:01:31.757+01:00Asp.net Reverse Ajax Chat1. MotivacijaKer je bil danes tak turoben dan, sem se odločil napisati demonstracijsko aplikacijo, ki uporablja t.i. reverse ajax, s pomočjo tehnologije Asp.net in WCF. Pred kakim letom sem se udeležil poletne šole, kjer smo podoben primerček spisali v Javi. Danes sem se hotel prepričati ali je kaj podobnega mogoče tudi z asp.net. Gre pa zgolj za predstavitev koncepta, programska koda je zgolj Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-301241736242007894.post-53534901626647196452008-11-17T09:24:00.002+01:002008-11-17T09:26:52.189+01:00Oda snihuDej dej snih zej!Jebeš pumlad, dej zej snih!Kipn ga en metr zej,snih, snih, snih, snih! Moje sneške, toje sneške,super sanke, tralala.Če ha manka, nam se sanka,kuhan uinu nam ga da. Zakua ni snih ciu lit (ciu lit)?Kua je hlup ta svit (ta svit)!Jest čem bit eskim (eskim),snih na smi bit sam pazim! Moje sneške, toje sneške,super sanke, tralala.Če ha manka, nam se sanka,kuhan uinu nam ga da. Ris ni Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-301241736242007894.post-9393221355843113672008-11-11T19:54:00.002+01:002008-11-11T19:55:58.582+01:00Prva objavaPo dolgem razmišljanju sem se tudi sam odločil, da začnem pisati blog.Unknownnoreply@blogger.com0