tag:blogger.com,1999:blog-60776782266040506012024-03-21T16:04:57.150-07:00C# HubC# Information, code samples and ramblingsWaShierhttp://www.blogger.com/profile/07675835764991826217noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-6077678226604050601.post-23958115627239372102008-02-12T09:45:00.000-08:002008-02-13T07:06:41.838-08:00Compression and Serialization - Part I<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihYD0ESJtHVTm1Q-pHjv1nggV2U0LpmVm3EkYwiMe_AJ3OmFVcZPsgR6OHXOkoxkmbk1F8NzJFr7d3xiXEMmX4fAT3rU6VXO0o24yn-iyw4aqcFhf0oEk-I6ptHv5N7dPjnNLBpb9EZNk/s1600-h/washier_bot_enc.bmp"><img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihYD0ESJtHVTm1Q-pHjv1nggV2U0LpmVm3EkYwiMe_AJ3OmFVcZPsgR6OHXOkoxkmbk1F8NzJFr7d3xiXEMmX4fAT3rU6VXO0o24yn-iyw4aqcFhf0oEk-I6ptHv5N7dPjnNLBpb9EZNk/s200/washier_bot_enc.bmp" alt="" id="BLOGGER_PHOTO_ID_5166477606480667778" border="0" /></a><br\>If you've ever serialized an object to a <span style="font-style: italic;">Stream </span>in .NET before(and you may have done so without realising), and wondered whether there is some simple way to use compression in order to save some stream-juice, read on.<br /><br />In my case stream-juice is network bandwidth. I'm serializaing objects over a <span style="font-style: italic;">NetworkStream</span>, but, saving stream-juice should never be laughed at or overlooked, regardless of <span style="font-style: italic;">typeof(stream)</span>. If you're serializing objects to a <span style="font-style: italic;">FileStream</span>,<span style="font-style: italic;"> </span>compression can save a significant amount of disk space(stream-juice).<br /><br />The <span style="font-style: italic;">System.IO.Compression </span>namespace(framework version 2) provides classes that makes this very easy. The trick is to hook into the framework's serialization process and compress/decompress the object being serialized/deserialized.<br /><br />To be continued...<br /><br />BTW: the image is evidence of life on another planet. It's encrypted though(Rijndael).</br\>WaShierhttp://www.blogger.com/profile/07675835764991826217noreply@blogger.com0tag:blogger.com,1999:blog-6077678226604050601.post-68964479855984638912008-02-07T08:40:00.001-08:002008-02-07T08:56:05.422-08:00Plugins, suits and thread-monkeys<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxS0IMFlTbAKvMNYWOPDxT-zyjSyJc5LQuv94aYngEG6LGMKR6-4e4r2WeTBnqb1HVEiBoAsNcRaLEL6QdF8knCRbubMz5Pet_OuwLf5mo5ThugZ5snkryU_iyeGQ2px9e-SsUtkc5cJU/s1600-h/ABYSS.GIF"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxS0IMFlTbAKvMNYWOPDxT-zyjSyJc5LQuv94aYngEG6LGMKR6-4e4r2WeTBnqb1HVEiBoAsNcRaLEL6QdF8knCRbubMz5Pet_OuwLf5mo5ThugZ5snkryU_iyeGQ2px9e-SsUtkc5cJU/s400/ABYSS.GIF" alt="" id="BLOGGER_PHOTO_ID_5164282682624367378" border="0" /></a><br />Yes. I have been absent for a while - busy throwing plugins at the suits. Works well - as long as your plugin framework is razor-thin.<br /><br /><br /><br />Learned some hard lessons on threading in .NET since I last posted. Turns out my motto holds : DIY. In this case, don't rely on framework code like Delegate.BeginInvoke() or ThreadPool.QueueUserWorkItem() to solve every problem - in general I find it much safer and reliable to utilize the reilable Queue-a-job type patterns using a manually created Thread. In some cases I employ a job buffering strategy on top of this in order to manage and throttle throughput. This suits the type of software I work on perfectly.WaShierhttp://www.blogger.com/profile/07675835764991826217noreply@blogger.com0tag:blogger.com,1999:blog-6077678226604050601.post-21060095518335420332007-04-12T10:56:00.000-07:002007-04-12T11:28:28.496-07:00Multi-monitor-(aware software)-mutterings<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpJxeyyeNT6_WAMMaDTjdpGC4MHuKMurjMp_aNt4sYlHnbyrMjgDKER_gc4UdGcUbQuzSb5tCWGbc5DeftKXjSj4wDyR4ZdeiS12FnhjLdl_idznfHd5Kk_zVsOvXeNKGmXbDAfKLe10M/s1600-h/peace.jpg"><img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpJxeyyeNT6_WAMMaDTjdpGC4MHuKMurjMp_aNt4sYlHnbyrMjgDKER_gc4UdGcUbQuzSb5tCWGbc5DeftKXjSj4wDyR4ZdeiS12FnhjLdl_idznfHd5Kk_zVsOvXeNKGmXbDAfKLe10M/s320/peace.jpg" alt="" id="BLOGGER_PHOTO_ID_5052603843511025538" border="0" /></a><br />It's not uncommon to have more than one monitor on your desk lately - even at home.<br />A while back I visited a client for the first time - and wow, every software devs dream.... a user that's serious about his hardware. Four 17" LCD monitors (a good brand) were arranged to form a sublime portal into a powerful .... OK - I might be stretching it a bit, but for the first time a started thinking about efficiently utilizing 5120x1024 of real estate.WaShierhttp://www.blogger.com/profile/07675835764991826217noreply@blogger.com1tag:blogger.com,1999:blog-6077678226604050601.post-14379168605198065872007-03-05T14:04:00.000-08:002007-03-05T14:42:06.090-08:00Spiraling into an abyssLast night I made the mistake of struggling with Prolog before going to bed - sheez. It was the first time I tried my hand at this weird (only because it is so different I suppose) language.<br /><br /><a href="http://www.csupomona.edu/%7Ejrfisher/www/prolog_tutorial/2_3.html">Here is a Prolog solution to The Towers of Hanoi game, amazing...</a><br /><br />It was just after midnight, reluctantly pulling my last cigarette, I decided to have a squiz at my first AI assignment - I'm studying post-grad Computer Science, part-time. I found the first 2 chapters of the textbook relatively straightforward, so I was confident and enjoying it. After I got stuck for a couple of minutes on what seemed to be a trivial error in my code<cringe>, one of those you know is right there in front of you, I found myself utterly confused and exausted. I went to bed.<br /><br /></cringe><div style="text-align: center;"><cringe style="font-weight: bold;"></cringe><span style="font-weight: bold; color: rgb(255, 102, 0);">***<br /></span></div><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDw32t06pJv-1ppoFYvgYKxd0EQWtG7ZPgFkyhMYnZxUzokvQL_IUCL33j1T9JYJO6EcI2wJ3STlKJJRcgCGn9bT1pTwirF-MTxRCk9NjhGW-CVX6LGti-FlyzUAnZiOUoxpRWVqScMG8/s1600-h/dadanybroom3.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDw32t06pJv-1ppoFYvgYKxd0EQWtG7ZPgFkyhMYnZxUzokvQL_IUCL33j1T9JYJO6EcI2wJ3STlKJJRcgCGn9bT1pTwirF-MTxRCk9NjhGW-CVX6LGti-FlyzUAnZiOUoxpRWVqScMG8/s320/dadanybroom3.jpg" alt="" id="BLOGGER_PHOTO_ID_5038574093820094370" border="0" /></a><div style="text-align: center;"><span style="font-weight: bold; color: rgb(255, 102, 0);"><br /></span><span style="font-weight: bold; color: rgb(255, 102, 0);">***</span><br /><cringe></cringe></div><cringe><br />When you're ill you sometimes you "dream" all night about events, things or even concepts you encountered during the day - I decorated the word dream, because it's more of a constant blurred awareness of the events, things or concepts bugging you. Hope that made sense. Well, I constantly "dreamt" Prolog last night - it was terrible.</cringe>WaShierhttp://www.blogger.com/profile/07675835764991826217noreply@blogger.com0tag:blogger.com,1999:blog-6077678226604050601.post-78249044041896325962007-03-02T14:55:00.000-08:002007-03-05T14:03:09.461-08:00Throwing plugins at the suits<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtLboY8nli7hy2ilnDzvleldCMX0OU6VUG4YwxP_XWsfJNSOwR0w07fHZMplOytTpUXMSXLW0QMeyhKR8viS7PWd5uKB2pkRLrmF3J-wQYAIGNhLt-5srtD5E9yfRl-p8Nn-xjZ3zDnLA/s1600-h/138356_3.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtLboY8nli7hy2ilnDzvleldCMX0OU6VUG4YwxP_XWsfJNSOwR0w07fHZMplOytTpUXMSXLW0QMeyhKR8viS7PWd5uKB2pkRLrmF3J-wQYAIGNhLt-5srtD5E9yfRl-p8Nn-xjZ3zDnLA/s320/138356_3.jpg" alt="" id="BLOGGER_PHOTO_ID_5037465287883089794" border="0" /></a><br />My world has been turned inside down by the plugin paradigm (call it what you like). I'm a minimalistic developer, prefering DIY sollutions to common problems (like reporting) and avoiding out-of-the-box-auto-magic-quick-fix monsters I can't control. I know people who could argue with me about these things all day - but the way I(and many others) see it, it's an art - not a job or a science or anything governed by rules.<br /><br />I'm 2 months into a 6 month project - typical business desktop software(financial risk analysis, if it makes a difference). The project entails replacing an existing system(which I implemented about 3 years ago) with a new shiny one with better this and that, more of that and a few big new features. The company's software grew a web front-end (somebody else did that), and naturally a substantial amount of functionality, and more tragic, code was duplicated. The user's requirements quickly grew beyond that which two relatively seperate systems could muster and the suits agreed that it was time to let the nerds out of the cage...<br /><br />Another bug that bit me is the idea of Service Orientated Architectures. Throw in a thorough study of .NET Remoting and you end up with a Windows service hosting plugins that provide services via remote interfaces to any .NET front-end you please, over a TCP/IP network - what more could you ask for? [yeah,yeah...i know]WaShierhttp://www.blogger.com/profile/07675835764991826217noreply@blogger.com1tag:blogger.com,1999:blog-6077678226604050601.post-16794308228657547022007-03-02T02:11:00.000-08:002007-03-02T16:51:41.801-08:00public static void main()<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVimy4UzP4koopVj5aayedGVIBCweUIDu8EyQ64SDLSy8NULUr2wLtZL9l80vy4rG44mbrKkoXQeZEOZ43ijacn-mAPewFnZJ2r0qdptnB6z7z_Dr9s5ryOmJwq01RoBj6WsSFK2Hsmxk/s1600-h/Photo-0025.jpg"><img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVimy4UzP4koopVj5aayedGVIBCweUIDu8EyQ64SDLSy8NULUr2wLtZL9l80vy4rG44mbrKkoXQeZEOZ43ijacn-mAPewFnZJ2r0qdptnB6z7z_Dr9s5ryOmJwq01RoBj6WsSFK2Hsmxk/s320/Photo-0025.jpg" alt="" id="BLOGGER_PHOTO_ID_5037269342885111666" border="0" /></a><br />Hello.<br /><br />I decided to start a blog : mostly because I'd like to start an archive of useful C# code snippets and tricks, but also because I like typing. Unless you're lucky enough to find the answer to what you deem the meaning of life(2:33am, Friday morning, coffee, cigarettes,neon...."why the #$@% is this sink throwing exceptions all of a sudden!") hidden somewhere in a post, this blog provides you with nothing but random code snippets, pretty photograps(ignore this one) and such.WaShierhttp://www.blogger.com/profile/07675835764991826217noreply@blogger.com0