<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ChalamiuS&#039; Blog &#187; Coding</title>
	<atom:link href="http://blog.chalamius.se/category/coding/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.chalamius.se</link>
	<description>Yet another random blog on the internet</description>
	<lastBuildDate>Fri, 30 Sep 2011 01:46:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>A smaller status update</title>
		<link>http://blog.chalamius.se/2011/03/a-smaller-status-update</link>
		<comments>http://blog.chalamius.se/2011/03/a-smaller-status-update#comments</comments>
		<pubDate>Thu, 03 Mar 2011 19:50:32 +0000</pubDate>
		<dc:creator>ChalamiuS</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[QDB]]></category>

		<guid isPermaLink="false">http://blog.chalamius.se/?p=336</guid>
		<description><![CDATA[Except for the ordinary slavery going on at school I&#8217;m working on a bunch of projects Hecate A rewrite of Lolikins&#8217; rewrite (which I never finished), sort of. Made in Python instead of PHP which gives a couple of quite &#8230; <a href="http://blog.chalamius.se/2011/03/a-smaller-status-update">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div id="attachment_343" class="wp-caption alignright" style="width: 206px"><a href="http://danbooru.donmai.us/post/show/684832/absurdres-butterfly-camellia_-flower-flower-hagiwa"><img class="size-medium wp-image-343" title="Akyu" src="http://static.chalamius.se/wp-content/uploads/2011/03/akyu2-196x300.png" alt="Akyu" width="196" height="300" /></a><p class="wp-caption-text">Akyu~</p></div>
<p>Except for the ordinary slavery going on at school I&#8217;m working on a bunch of projects</p>
<h4><strong>Hecate</strong></h4>
<p>A rewrite of Lolikins&#8217; rewrite (which I never finished), sort of.<br />
Made in Python instead of PHP which gives a couple of quite nice advantages such as:</p>
<ul>
<li>SSL support again</li>
<li>Clean code (PHP looks dirty for some reason, probably all those $)</li>
<li>Module reloading without the use of unsupported extensions</li>
</ul>
<p>Oh and I have someone helping me out actively this time (which means it&#8217;ll probably be finished too).</p>
<h4><strong>Akyu</strong></h4>
<p>As usual there&#8217;s some changes I did to the quote database such as infi-scroll (you know, the thing that makes the page continue loading while you scroll on twitter and such) which&#8230; doesn&#8217;t work quite as I want it to just yet but oh well.</p>
<h4><strong>Lastly</strong></h4>
<p>There&#8217;s a project I&#8217;ll announce when it&#8217;s ready (some of you may already know but keep it to yourselves).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chalamius.se/2011/03/a-smaller-status-update/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some updates (and new creations)</title>
		<link>http://blog.chalamius.se/2010/09/some-updates-and-new-creations</link>
		<comments>http://blog.chalamius.se/2010/09/some-updates-and-new-creations#comments</comments>
		<pubDate>Sun, 05 Sep 2010 02:37:26 +0000</pubDate>
		<dc:creator>ChalamiuS</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[QDB]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://blog.chalamius.se/?p=277</guid>
		<description><![CDATA[The Quote Database The quote database I work on (Akyu) have been updated to 0.2 recently (24th August). This changed some things: Voting buttons now actually tells you they are, i.e voting buttons No text error messages, all error messages &#8230; <a href="http://blog.chalamius.se/2010/09/some-updates-and-new-creations">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>The Quote Database</h3>
<p>The <a title="Quote Database" href="http://www.chalamius.se/quotes/" target="_blank">quote database</a> I work on (Akyu) have been updated to 0.2 recently (24th August).<br />
This changed some things:</p>
<ul>
<li>Voting buttons now actually tells you they are, i.e voting buttons</li>
<li>No text error messages, all error messages are displayed when you hover over the button you just clicked</li>
<li>Some minor changes to the layouts of some pages (for example the search page)</li>
</ul>
<p><span id="more-277"></span></p>
<h3>pIRC</h3>
<p>A smaller bug fix a couple of days ago. The event handler couldn&#8217;t handle some constants as triggers.<br />
Away has been added to the irc wrapper as well.</p>
<p>Going to try to get some sort of Admin module into it next time I have a longer weekend than I have now.</p>
<h3>Voile</h3>
<p>My little image gallery I work on every now and then.<br />
It currently only generates cached thumbnails for what I upload and lists them on the index page; nothing fancy.</p>
<p>Feel free to take a <a title="Image Gallery" href="http://voile.chalamius.se/index2.php" target="_blank">look</a></p>
<p>One last <strong>thing</strong>&#8230;</p>
<div class="wp-caption alignnone" style="width: 314px"><a href="http://voile.chalamius.se/uploads/images/thingie.png" rel="lightbox[277]"><img class=" " title="Thingie~" src="http://voile.chalamius.se/uploads/images/thingie.png" alt="Thingie~" width="304" height="225" /></a><p class="wp-caption-text">Rawr, I&#39;m going to poke you with my antenna</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.chalamius.se/2010/09/some-updates-and-new-creations/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Random updates</title>
		<link>http://blog.chalamius.se/2010/02/random-updates</link>
		<comments>http://blog.chalamius.se/2010/02/random-updates#comments</comments>
		<pubDate>Mon, 22 Feb 2010 23:07:45 +0000</pubDate>
		<dc:creator>ChalamiuS</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[QDB]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://blog.chalamius.se/?p=202</guid>
		<description><![CDATA[So&#8230; I just thought I&#8217;d post some updates to keep this blog from being idle for way too long. As you might know (at least if you checked out the Projects tab) I&#8217;m working on an irclib, so I thought &#8230; <a href="http://blog.chalamius.se/2010/02/random-updates">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So&#8230; I just thought I&#8217;d post some updates to keep this blog from being idle for way too long.</p>
<p>As you might know (at least if you checked out the Projects tab) I&#8217;m working on an irclib, so I thought I&#8217;d give you a bit of a preview on how the actual ircbot looks from the command-line.</p>
<p>Sadly it seems like the coloring and stuff will be Linux only since it requires an extra (3rd-party, not Microsoft) executable for Windows.</p>
<div id="attachment_203" class="wp-caption alignnone" style="width: 310px"><a href="http://static.chalamius.se/wp-content/uploads/2010/02/pirc.png" rel="lightbox[202]"><img class="size-medium wp-image-203 " title="pIRC" src="http://static.chalamius.se/wp-content/uploads/2010/02/pirc-300x169.png" alt="pIRC - A screenshot" width="300" height="169" /></a><p class="wp-caption-text">So, this is how it looks</p></div>
<p><span id="more-202"></span></p>
<blockquote><p>An extensible IRC-bot made in PHP using as few PECL modules as  possible.</p>
<p>The goal of pIRC is to have a fast lightweight bot that&#8217;s  extensible.</p></blockquote>
<p>And this is the current feature set:</p>
<h3>- Event Handler</h3>
<ul>
<li>Supports both arrays and single arguments, if none are given upon registering the function will be passed the standard Message object.</li>
<li>Built-in flood protection</li>
</ul>
<h3>- Modules</h3>
<ul>
<li>All modules can be loaded, unloaded and reloaded during run-time</li>
<li>It checks the syntax before loading to prevent accidental crashing</li>
<li>Probably less leaky than the rename class method that others seems to use</li>
</ul>
<h3>Anyways,</h3>
<p>I did some updates to the QDB to make it a bit faster along with fixing up a new theme for my <a title="#bakabt @ Rizon stats by ChalamiuS" href="http://chalamius.se/stats?chan=bakabt" target="_blank">#bakabt</a> stats.</p>
<p>Sadly not much more to report, except the fact that I have math test on Wednesday so I wont get anything done on anything this week anyway :3</p>
<p>Also, if you have any suggestions to the QDB or similar, feel free, suggestions are always welcome.</p>
<h6>This post is pretty much a post to remind myself to work on this crap when I get the time to &gt;_&gt;<br />
also, todo: Add more stuff to this update post.</h6>
]]></content:encoded>
			<wfw:commentRss>http://blog.chalamius.se/2010/02/random-updates/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>C#: Lambda Expressions</title>
		<link>http://blog.chalamius.se/2010/01/c-lambda-expressions</link>
		<comments>http://blog.chalamius.se/2010/01/c-lambda-expressions#comments</comments>
		<pubDate>Fri, 08 Jan 2010 22:47:05 +0000</pubDate>
		<dc:creator>jisakujien</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://blog.chalamius.se/?p=183</guid>
		<description><![CDATA[As a belated follow up to my post on C# Anonymous Methods, let&#8217;s look at a closely related feature of the CLS: lambda expressions.  Then let&#8217;s use a lambda expression to improve the code example from that earlier article. Lambda &#8230; <a href="http://blog.chalamius.se/2010/01/c-lambda-expressions">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://static.chalamius.se/wp-content/uploads/2010/01/LambdaTransparent.png" rel="lightbox[183]"><img class="alignright size-full wp-image-189" title="Lambda" src="http://static.chalamius.se/wp-content/uploads/2010/01/LambdaTransparent.png" alt="" width="168" height="168" /></a>As a belated follow up to my post on <a title="C#: Anonymous Methods" href="http://blog.chalamius.se/jisakujien/c-anonymous-methods" target="_blank">C# Anonymous Methods</a>, let&#8217;s look at a closely related feature of the <a href="http://msdn.microsoft.com/en-us/library/12a7a7h3.aspx">CLS</a>: <a title="Lamda Expressions (C# Programming Guide) - MSDN" href="http://msdn.microsoft.com/en-us/library/bb397687.aspx" target="_blank">lambda expressions</a>.  Then let&#8217;s use a lambda expression to improve the code example from that earlier article.<span id="more-183"></span></p>
<p>Lambda Expressions were introduced in the 3.0 version of the Common Language Specification.  Lambdas are essentially a refinement of anonymous methods.  They allow you to define a block of code which operates on one or more input variables and returns a single result.  Let&#8217;s break down a simple lambda example, from <a title="Lamda Expressions (C# Programming Guide) - MSDN" href="http://msdn.microsoft.com/en-us/library/bb397687.aspx" target="_blank">the MSDN page on Lambda Expressions</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">delegate</span> <span style="color: #6666cc; font-weight: bold;">int</span> del<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Main<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    del myDelegate <span style="color: #008000;">=</span> x <span style="color: #008000;">=&gt;</span> x <span style="color: #008000;">*</span> x<span style="color: #008000;">;</span>
    <span style="color: #6666cc; font-weight: bold;">int</span> j <span style="color: #008000;">=</span> myDelegate<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">5</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">//j = 25</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>In this example, a delegate type is defined, <tt>del</tt>.   Then an instance of the delegate is created using a lambda expression.   Finally, the delegate is executed, and the return value is assigned to the integer variable <tt>j</tt>.   Let&#8217;s ignore everything but the lambda expression itself: <tt>x =&gt; x * x</tt>.</p>
<p>The first character of the expression actually defines a variable named <tt>x</tt>, which only exists inside the lambda expression.   In the MSDN example, when the lambda is actually executed, <tt>x</tt> will be assigned the input value of <tt>5</tt>.</p>
<p>The <tt>=&gt;</tt> character sequence tells C# that your lambda expression operates on the variable <tt>x</tt>.   To oversimplify, everything to the left of <tt>=&gt;</tt> is an input variable declaration, and everything on the right is an expression which determines the return value.  In our examples, there will only ever be one input variable.</p>
<p>The <tt>x * x</tt> character sequence is the actual expression, the bit of code that gets executed.   So we could rewrite down the code above to this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">int</span> x <span style="color: #008000;">=</span> <span style="color: #FF0000;">5</span><span style="color: #008000;">;</span>
<span style="color: #6666cc; font-weight: bold;">int</span> j <span style="color: #008000;">=</span> x <span style="color: #008000;">*</span> x<span style="color: #008000;">;</span></pre></div></div>

<p>&#8230;and achieve the same result.</p>
<h3>Filtering Cars with Lambda Expressions</h3>
<p>Returning to our <a title="C#: Anonymous Methods" href="http://blog.chalamius.se/jisakujien/c-anonymous-methods" target="_blank">anonymous methods example</a>, we found that the <a title="List(T).FindAll Method (System.Collections.Generic) - MSDN" href="http://msdn.microsoft.com/en-us/library/fh1w7y8z.aspx" target="_blank"><tt>FindAll</tt></a> method of the <a title="List(T) Class (System.Collections.Generic) - MSDN" href="http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx" target="_blank"><tt>List&lt;&gt;</tt></a> generic class can take a delegate.  The delegate is used to filter which items in the list are returned.</p>
<h4>With Anonymous Methods</h4>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Main<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// Create a list of cars meeting criteria by calling the FindAll()</span>
    <span style="color: #008080; font-style: italic;">// method of the List returned by CreateCars().</span>
    List cars <span style="color: #008000;">=</span> CreateCars<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">FindAll</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">delegate</span><span style="color: #008000;">&#40;</span>Car candidate<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// Return whether the car matches our criteria.  FindAll()</span>
        <span style="color: #008080; font-style: italic;">// expects our anonymous method to return a boolean, and</span>
        <span style="color: #008080; font-style: italic;">// the compiler makes sure this is the case.</span>
        <span style="color: #0600FF; font-weight: bold;">return</span>
            candidate<span style="color: #008000;">.</span><span style="color: #0000FF;">Manufacturer</span> <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;Toyota&quot;</span> <span style="color: #008000;">||</span>
            candidate<span style="color: #008000;">.</span><span style="color: #0000FF;">Manufacturer</span> <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;Nissan&quot;</span> <span style="color: #008000;">&amp;&amp;</span>
            candidate<span style="color: #008000;">.</span><span style="color: #0000FF;">Turbocharged</span> <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">foreach</span><span style="color: #008000;">&#40;</span>Car car <span style="color: #0600FF; font-weight: bold;">in</span> cars<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span>car<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Instead, let&#8217;s replace that anonymous method block with a lambda expression.</p>
<h4>With Lambda Expressions</h4>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Main<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    List cars <span style="color: #008000;">=</span> CreateCars<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">FindAll</span><span style="color: #008000;">&#40;</span>car <span style="color: #008000;">=&gt;</span>
        car<span style="color: #008000;">.</span><span style="color: #0000FF;">Manufacturer</span> <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;Toyota&quot;</span> <span style="color: #008000;">||</span>
        car<span style="color: #008000;">.</span><span style="color: #0000FF;">Manufacturer</span> <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;Nissan&quot;</span> <span style="color: #008000;">&amp;&amp;</span>
        car<span style="color: #008000;">.</span><span style="color: #0000FF;">Turbocharged</span> <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">false</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    car<span style="color: #008000;">.</span><span style="color: #0000FF;">Turbocharged</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// Invalid code, &quot;car&quot; does not exist.</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>In this case, our lambda expression creates the variable <tt>car</tt>, and then does the same set of conditional tests as the old example.  Note that the <tt>car</tt> variable only exists in the scope of the lambda expression, just like in the anonymous method.  For that reason, the second to last line of code would be a compiler error.</p>
<h3>So What&#8217;s the Difference?</h3>
<p>For the purposes of our example, not a whole lot:</p>
<ul>
<li>The input variable and return types are <a title="C# Version 3.0 Specification - Implicitly Typed Local Variables - MSDN" href="http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx" target="_blank"><i>inferred</i></a>.  C# is able to figure out what type <tt>car</tt> is by looking at where the lambda is used.   The type is actually defined in the <tt>CreateCars()</tt> method of our earlier example.  C# looks at the return type of <tt>List&lt;Car&gt;</tt> and <i>infers</i> (or deduces) that a lambda expression operating on the <tt>FindAll</tt> method of that <tt>List&lt;Car&gt;</tt> would operate on a single input variable of type <tt>Car</tt>.  Note that in the old anonymous methods example, C# was only able to infer the return type.</li>
<li>The lambda expression does not need curly braces, since it is a basic expression.</li>
<li>The lambda expression does not use the ugly <tt>delegate()</tt> syntax, thanks to the type inference.</li>
</ul>
<p>Of course lambda expressions are a bit more complicated than I let on; they can declare multiple input variables, and they can also contain normal procedural code statements (such as calling a method &#8212; and that does require using curly braces).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chalamius.se/2010/01/c-lambda-expressions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

