<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>The Standard Output (programming)</title><link>http://thestandardoutput.com/</link><description></description><atom:link href="http://thestandardoutput.com/tag/programming.xml" type="application/rss+xml" rel="self"></atom:link><language>en</language><lastBuildDate>Mon, 12 Oct 2015 07:59:00 GMT</lastBuildDate><generator>https://getnikola.com/</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Get a prime number sequence using Java 8 Streams</title><link>http://thestandardoutput.com/posts/get-a-prime-number-sequence-using-java-8-streams/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;With a spirit of expanding on my previous post about
&lt;a href="http://thestandardoutput.com/posts/check-number-primality-using-java-8-streams"&gt;checking numbers for primality&lt;/a&gt;,
here's a quick way to generate a sequence of prime numbers using streams:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="n"&gt;LongStream&lt;/span&gt; &lt;span class="nf"&gt;primeSequence&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;LongStream&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;iterate&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;filter&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;isPrime&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;limit&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;


&lt;p&gt;The above returns a &lt;code&gt;LongStream&lt;/code&gt; of prime numbers up to a specified &lt;code&gt;max&lt;/code&gt;
value. It uses my previous prime checker function &lt;code&gt;isPrime&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Hope it helps!&lt;/p&gt;&lt;/div&gt;</description><category>java8</category><category>programming</category><guid>http://thestandardoutput.com/posts/get-a-prime-number-sequence-using-java-8-streams/</guid><pubDate>Wed, 06 May 2015 03:42:37 GMT</pubDate></item><item><title>Check number primality using Java 8 Streams</title><link>http://thestandardoutput.com/posts/check-number-primality-using-java-8-streams/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;The canonical way to check if a number is prime in Java uses a loop. It looks
like this:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="nf"&gt;isPrime&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;Math&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;sqrt&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;++)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;


&lt;p&gt;There is a more streamlined and efficient way of doing this using Streams. It
looks like this:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="nf"&gt;isPrime&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;LongStream&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;rangeClosed&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="o"&gt;)(&lt;/span&gt;&lt;span class="n"&gt;Math&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;sqrt&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;)))&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;allMatch&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;


&lt;p&gt;Hope this helps!&lt;/p&gt;&lt;/div&gt;</description><category>java8</category><category>programming</category><guid>http://thestandardoutput.com/posts/check-number-primality-using-java-8-streams/</guid><pubDate>Mon, 04 May 2015 02:44:15 GMT</pubDate></item><item><title>A note on migrating python virtual environments</title><link>http://thestandardoutput.com/posts/note-on-migrating-python-virtual-environments/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;The engine that builds this blog is called Nikola it's written in Python. I
write the blog and run the Nikola compiler to build the site inside a Python
virtual environment.&lt;/p&gt;
&lt;p&gt;Up until recently I was doing this work on a machine running the latest Arch
Linux and Python 2.7.8, but I have recently rebuilt that machine to run Debian
8, whose default Python interpreter is currently at version 2.7.6 and I copied
my virtual environments to the new OS install.&lt;/p&gt;
&lt;p&gt;This caused me a problem with my virtual environments that manifested itself as
the following error when I tried to run any Python code from within the active
virtual environment:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;pip&lt;/span&gt; &lt;span class="n"&gt;freeze&lt;/span&gt;
&lt;span class="n"&gt;Traceback&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;most&lt;/span&gt; &lt;span class="n"&gt;recent&lt;/span&gt; &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="n"&gt;last&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
  &lt;span class="n"&gt;File&lt;/span&gt; &lt;span class="s"&gt;"/home/jonasg/.virtualenvs/tso/bin/pip"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;module&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;pip&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;
  &lt;span class="n"&gt;File&lt;/span&gt; &lt;span class="s"&gt;"/home/jonasg/.virtualenvs/tso/local/lib/python2.7/site-packages/pip/__init__.py"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;module&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;pip.vcs&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mercurial&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;subversion&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bazaar&lt;/span&gt;  &lt;span class="c"&gt;# noqa&lt;/span&gt;
  &lt;span class="n"&gt;File&lt;/span&gt; &lt;span class="s"&gt;"/home/jonasg/.virtualenvs/tso/local/lib/python2.7/site-packages/pip/vcs/mercurial.py"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;module&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;pip.download&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;path_to_url&lt;/span&gt;
  &lt;span class="n"&gt;File&lt;/span&gt; &lt;span class="s"&gt;"/home/jonasg/.virtualenvs/tso/local/lib/python2.7/site-packages/pip/download.py"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;module&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;email.utils&lt;/span&gt;
  &lt;span class="n"&gt;File&lt;/span&gt; &lt;span class="s"&gt;"/usr/lib/python2.7/email/utils.py"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;module&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;email._parseaddr&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;quote&lt;/span&gt;
  &lt;span class="n"&gt;File&lt;/span&gt; &lt;span class="s"&gt;"/usr/lib/python2.7/email/_parseaddr.py"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;module&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;time&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nn"&gt;calendar&lt;/span&gt;
  &lt;span class="n"&gt;File&lt;/span&gt; &lt;span class="s"&gt;"/usr/lib/python2.7/calendar.py"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;module&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;datetime&lt;/span&gt;
&lt;span class="ne"&gt;ImportError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;No&lt;/span&gt; &lt;span class="n"&gt;module&lt;/span&gt; &lt;span class="n"&gt;named&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;

&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;nikola&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="ne"&gt;ImportError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;No&lt;/span&gt; &lt;span class="n"&gt;module&lt;/span&gt; &lt;span class="n"&gt;named&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;
&lt;/pre&gt;


&lt;p&gt;This happens because my virtual environments had a different version of
&lt;code&gt;/usr/bin/python2.7&lt;/code&gt; (the one from Arch Linux) that — unlike the new binary —
does not include the &lt;code&gt;datetime&lt;/code&gt; built-in, and therefore generates an error when
it cannot find it on disk anywhere. The new interpreter seems to import it
without any file I/O (try running it under strace to check).&lt;/p&gt;
&lt;p&gt;The fix for this issue is to activate the virtual environment you are having
problems with and run the following:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;cp /usr/bin/python2.7 &lt;span class="k"&gt;$(&lt;/span&gt;which python2.7&lt;span class="k"&gt;)&lt;/span&gt;
&lt;/pre&gt;


&lt;p&gt;There are other ways to fix this issue, but I like the one above rather than
re-initializing the &lt;code&gt;virtualenv&lt;/code&gt; because I use &lt;code&gt;virtualenvwrapper&lt;/code&gt; which does
NOT gererate the virtual environment within the present directory.&lt;/p&gt;
&lt;p&gt;Hope this helps!&lt;/p&gt;&lt;/div&gt;</description><category>programming</category><category>python</category><guid>http://thestandardoutput.com/posts/note-on-migrating-python-virtual-environments/</guid><pubDate>Wed, 18 Feb 2015 09:13:52 GMT</pubDate></item><item><title>So, you want to write your own language?</title><link>http://thestandardoutput.com/posts/so-you-want-to-write-your-own-language/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;Below are my notes from a really interesting article about the creation of
programming languages by Walter Bright published on January 21, 2014 in the
Dr. Dobbs Journal.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.drdobbs.com/architecture-and-design/so-you-want-to-write-your-own-language/240165488"&gt;http://www.drdobbs.com/architecture-and-design/so-you-want-to-write-your-own-language/240165488&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Work&lt;/h3&gt;
&lt;p&gt;Tons of work ... years of work ... need intrinsic motivation. Not a major cash
investment&lt;/p&gt;
&lt;h3&gt;Design&lt;/h3&gt;
&lt;p&gt;Syntax matters a lot.  It needs to be something that appeals to your target
audience.  A mix of familiar syntax + aesthetic beauty.&lt;/p&gt;
&lt;p&gt;These should NOT be considerations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Minimizing keystrokes&lt;/li&gt;
&lt;li&gt;Easy parsing. not hard to write parsers with arbitrary lookahead&lt;/li&gt;
&lt;li&gt;Minimizing the number of keywords&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These things are TRULY GOOD:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Context-Free Grammar. code is parsable without having to look up in a symbol
  table&lt;/li&gt;
&lt;li&gt;Redundancy. the grammar should be redundant to get good error messages&lt;/li&gt;
&lt;li&gt;Tried and True. Stick with tried and true grammatical forms. cuts the learning
  curve. e.g. people expect + and * to follow a certain precedence rule.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After syntax, the important thing is semantic processing... meaning is assigned
here to syntax structure.  This is where you spend most of the design and
implementation time.  There is no glory in the semantics, but it is the whole
point of the language.&lt;/p&gt;
&lt;p&gt;After the semantice phase, the compiler does optimizations and code generation
This is collectively called the back-end.  Very challenging and complicated
these 2 phases.  Try using an existing back end such as one of JVM, CLR, GCC,
LLVM.&lt;/p&gt;
&lt;h3&gt;Implementation&lt;/h3&gt;
&lt;p&gt;Regex is the wrong tool for lexing and parsing.&lt;/p&gt;
&lt;p&gt;Don't bother wasting time with lexer and parser generators or other so-called
&lt;em&gt;compiler compilers&lt;/em&gt;. They are a waste of time.  Writing the lexer and the
parser is a tiny percentage of the job of writing a compiler.&lt;/p&gt;
&lt;p&gt;Error messages are a big factor in the quality of implementation of the
language. Use the following guidelines:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;print the first error message and quit&lt;/li&gt;
&lt;li&gt;guess what a programmer intended, repair the AST and continue&lt;/li&gt;
&lt;li&gt;The poisoning approach. any operation with a NaN results in a NaN silently.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Compiler speed matters a lot... Most compilers are pigs.  The secret to making a
compiler fast is to use a &lt;em&gt;profiler&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;You must/have to be using these tools in order to be successful:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;valgrind. saved C and C++ from oblivion&lt;/li&gt;
&lt;li&gt;git / github like public repo. trasnformative tools. collaboration. track the
  origin of every line of code&lt;/li&gt;
&lt;li&gt;Automated testing framework + Coverage analyzer&lt;/li&gt;
&lt;li&gt;Automated documentation generator&lt;/li&gt;
&lt;li&gt;Bugtracker + Wiki + Blog + Google Groups + Mailing List + IRC Channel +
  Twitter + Facebook&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Lowering&lt;/h3&gt;
&lt;p&gt;A semantic technique. It consists of, internally, rewrting more complex semantic
constructs in terms of simpler ones. e.g. &lt;em&gt;while&lt;/em&gt; loops and &lt;em&gt;foreach&lt;/em&gt; loops can
be rewritten in terms of &lt;em&gt;for&lt;/em&gt; loops. Then the rest of the code only has to deal
with &lt;em&gt;for&lt;/em&gt; loops. If there are special-case rules in the language that prevent
&lt;em&gt;lowering&lt;/em&gt; rewriting, then revisit the design of the language.&lt;/p&gt;
&lt;h3&gt;Runtime Library&lt;/h3&gt;
&lt;p&gt;Critical is the need to write a runtime library.  This is a major project.  It
serves as the demostration of how the language features work.  It better be
good.&lt;/p&gt;
&lt;p&gt;Get these right:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I/O performance. Slow IO will make that language look bad. the benchmark is C
  stdio&lt;/li&gt;
&lt;li&gt;Memory allocation. Most of the time programs spend doing this&lt;/li&gt;
&lt;li&gt;Transcendental functions... What are these? Find a library that already
  implements these functions ... Floating point stuff&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;What should go in a library&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;File IO&lt;/li&gt;
&lt;li&gt;Network IO&lt;/li&gt;
&lt;li&gt;String&lt;/li&gt;
&lt;li&gt;Algorithms&lt;/li&gt;
&lt;li&gt;Data Structures&lt;/li&gt;
&lt;li&gt;OS Interaction&lt;/li&gt;
&lt;li&gt;Unicode - UTF-8&lt;/li&gt;
&lt;li&gt;Date / Time&lt;/li&gt;
&lt;li&gt;Memory Management&lt;/li&gt;
&lt;li&gt;Process Control&lt;/li&gt;
&lt;li&gt;Signals&lt;/li&gt;
&lt;li&gt;Math&lt;/li&gt;
&lt;li&gt;Data Types&lt;/li&gt;
&lt;li&gt;Crypto&lt;/li&gt;
&lt;li&gt;Reflection&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;After the Prototype&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Presentations&lt;/li&gt;
&lt;li&gt;Articles&lt;/li&gt;
&lt;li&gt;Tutorials&lt;/li&gt;
&lt;li&gt;Books&lt;/li&gt;
&lt;li&gt;Programmer Meetings&lt;/li&gt;
&lt;li&gt;Conferences&lt;/li&gt;
&lt;li&gt;Companies&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Go anywhere they will have you and show it off.  Get used to public speaking.
Get as much feedback as you can.&lt;/p&gt;&lt;/div&gt;</description><category>compilers</category><category>programming</category><guid>http://thestandardoutput.com/posts/so-you-want-to-write-your-own-language/</guid><pubDate>Tue, 02 Dec 2014 05:24:40 GMT</pubDate></item><item><title>Free GeoIp location web service</title><link>http://thestandardoutput.com/posts/free-geoip-location-web-service/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;This weekend I found a really cool web service at
&lt;a href="http://freegeoip.net/"&gt;FreeGeoIp.net&lt;/a&gt;. Their API is really simple... just send
a HTTP GET request to:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;http://freegeoip.net/{format}/{ip_or_hostname}
&lt;/pre&gt;


&lt;p&gt;Here are some of the implementation details:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;SSL is supported&lt;/li&gt;
&lt;li&gt;Formats are csv, json, and xml&lt;/li&gt;
&lt;li&gt;IP is optional. It defaults to your current IP.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I quickly implemented a comnmand line client written in Python 3. It uses the
awesome &lt;a href="http://docs.python-requests.org/en/latest/"&gt;requests&lt;/a&gt; library and
ElementTree to parse the resulting XML response. Here's the code...&lt;/p&gt;
&lt;pre class="code literal-block"&gt;def main():
    args = parse_args()

    MYIP_URL = 'http://freegeoip.net/xml/'
    MYIP_HEADERS = {'Accept': 'application/xml'}

    if args.ip is not None:
        MYIP_URL = MYIP_URL + args.ip

    rspn = requests.get(MYIP_URL, headers=MYIP_HEADERS)
    tree = etree.ElementTree(etree.fromstring(rspn.text))
    root = tree.getroot()

    ip = root.find('Ip')
    cntr = root.find('CountryName')
    reg = root.find('RegionName')
    city = root.find('City')

    print('Your Current IP: %s' % ip.text)
    print('You appear to be in %s, %s, %s' % (city.text, reg.text, cntr.text))
&lt;/pre&gt;


&lt;p&gt;Or you can get the
&lt;a href="https://github.com/gorauskas/Hacks/blob/master/python/myip"&gt;whole code&lt;/a&gt; from my
&lt;a href="https://github.com/gorauskas"&gt;github profile&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</description><category>linux</category><category>programming</category><category>python</category><guid>http://thestandardoutput.com/posts/free-geoip-location-web-service/</guid><pubDate>Thu, 04 Sep 2014 05:54:04 GMT</pubDate></item><item><title>Quick Ref: Python Virtualenv use</title><link>http://thestandardoutput.com/posts/quick-ref-python-virtualenv-use/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;Supposing you have a clean install of a Debian-based distro such as Debian 7
proper or Xubuntu 14.04, this notes will walk you through setting up a Python
development environment where you can leverage the power of Virtualenv through
Virtualenvwrapper.&lt;/p&gt;
&lt;h3&gt;Why virtualenv?&lt;/h3&gt;
&lt;p&gt;When you code in python you will quickly find out that different projects have
different requirements for the python version you need to use and also the
versions of libraries you need to use. Virtualenv will allow you to
compartmentalize the requirements on a per project basis without making you
install libraries and python versions globally or system-wide.&lt;/p&gt;
&lt;h3&gt;Ok, ok... Here are the goods...&lt;/h3&gt;
&lt;p&gt;You have your new shinny install of Debian which comes with a fairly recent
version of python pre-installed (somewhere above 2.7.3). Now you need to install
a package manager for python and the one I use is pip.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;sudo apt-get install python-pip
&lt;/pre&gt;


&lt;p&gt;Once you have pip installed, you will need to also install virtualenv, like so:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;sudo pip install virtualenvwrapper
&lt;/pre&gt;


&lt;p&gt;Virtualenvwrapper is a very nice layer on top of virtualenv that makes working
with it much more intuitive and convenient.&lt;/p&gt;
&lt;p&gt;Next, you may want to automate a couple of things like I did. First, create a
&lt;code&gt;~/.virtualenvs&lt;/code&gt; directory. This is where virtualenvwrapper will keep track of
your environments. Then open you &lt;code&gt;.bashrc&lt;/code&gt; file and add a few lines to it:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="x"&gt;export WORKON_HOME=&lt;/span&gt;&lt;span class="p"&gt;$&lt;/span&gt;&lt;span class="nv"&gt;HOME&lt;/span&gt;&lt;span class="x"&gt;/.virtualenvs&lt;/span&gt;
&lt;span class="x"&gt;if [ -f /usr/local/bin/virtualenvwrapper_lazy.sh ]; then&lt;/span&gt;
&lt;span class="x"&gt;    . /usr/local/bin/virtualenvwrapper_lazy.sh&lt;/span&gt;
&lt;span class="x"&gt;fi&lt;/span&gt;
&lt;/pre&gt;


&lt;p&gt;Now you are ready to start working, so open a new terminal, setup a virtual
environment, and start cranking out some python code. Here's a quick reference
for virtualenvwrapper:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Start new virtual environment?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;mkvirtualenv [env-name]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Leave the current virtual environment?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;deactivate&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;List all available virtual environments?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;workon&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;lsvirtualenv -b&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Enter an existing virtual environment?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;workon [env-name]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;List packages installed in current virtual environment?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;pip freeze&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Remove a virtual environment?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;rmvirtualenv [env-name]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Start a virtual environment with specific python version?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;mkvirtualenv [env-name] -p /usr/bin/python3.4&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Replace &lt;code&gt;[env-name]&lt;/code&gt; above with your actual environment name and enjoy!&lt;/p&gt;&lt;/div&gt;</description><category>debian</category><category>linux</category><category>programming</category><category>python</category><guid>http://thestandardoutput.com/posts/quick-ref-python-virtualenv-use/</guid><pubDate>Fri, 06 Jun 2014 07:55:33 GMT</pubDate></item><item><title>What are the genuinely useful ideas in programming?</title><link>http://thestandardoutput.com/posts/what-are-the-genuinely-useful-ideas-in-programming/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;There is a really interesting article here about
"&lt;a href="http://lemire.me/blog/archives/2013/10/04/genuinely-useful/" title="useful ideas in programming"&gt;What are the genuinely useful ideas in programming&lt;/a&gt;".&lt;/p&gt;
&lt;p&gt;The comments are closed for that post, so here are the two things I would add to
the list:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Index = Data(Algorithm + Data Structure): Google made this concept relevant, again.&lt;/li&gt;
&lt;li&gt;Sensors, and networks of them (not to be confused with scanners
   (e.g. barcode, QR)): The Arduino and the Raspberry Pi made these important.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;</description><category>philosophy</category><category>programming</category><category>zeitgeist</category><guid>http://thestandardoutput.com/posts/what-are-the-genuinely-useful-ideas-in-programming/</guid><pubDate>Sun, 27 Oct 2013 05:48:21 GMT</pubDate></item><item><title>Resume interrupted downloads with cURL in Linux</title><link>http://thestandardoutput.com/posts/resume-interrupted-downloads-with-curl-in-linux/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;I have recently been trying to download an ISO of a certain Linux distro, but I
find myself at the wrong end of a crappy connection. I tried downloading it with
both Firefox and Chrome but both choked very early in the process and current
speed would go down to 0 and after a while the connection would just cutoff with
no way to resume the download from where I left off.&lt;/p&gt;
&lt;p&gt;Fear not because [cURL][curl] comes to the rescue. After typing &lt;code&gt;Up-Arrow&lt;/code&gt; and
&lt;code&gt;Enter&lt;/code&gt; more time than I care to admit, I decided to let the computer do the
hard work and automate this thing. So I created a small Bash script called
&lt;code&gt;acurl.sh&lt;/code&gt; (for Automated cURL) that looks like this:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="x"&gt;export ec=1;&lt;/span&gt;

&lt;span class="x"&gt;while [ &lt;/span&gt;&lt;span class="p"&gt;$&lt;/span&gt;&lt;span class="nv"&gt;ec&lt;/span&gt;&lt;span class="x"&gt; -gt 0 ]; do&lt;/span&gt;
&lt;span class="x"&gt;    /usr/bin/curl -O -C - &lt;/span&gt;&lt;span class="p"&gt;$&lt;/span&gt;&lt;span class="x"&gt;1;&lt;/span&gt;
&lt;span class="x"&gt;    export ec=&lt;/span&gt;&lt;span class="p"&gt;$&lt;/span&gt;&lt;span class="x"&gt;?;&lt;/span&gt;
&lt;span class="x"&gt;done&lt;/span&gt;

&lt;span class="x"&gt;if [ &lt;/span&gt;&lt;span class="p"&gt;$&lt;/span&gt;&lt;span class="nv"&gt;ec&lt;/span&gt;&lt;span class="x"&gt; -eq 0 ]; then&lt;/span&gt;
&lt;span class="x"&gt;    echo "Downloaded &lt;/span&gt;&lt;span class="p"&gt;$&lt;/span&gt;&lt;span class="x"&gt;1";&lt;/span&gt;
&lt;span class="x"&gt;fi&lt;/span&gt;
&lt;/pre&gt;


&lt;p&gt;What's going on above is that I have a while loop that is checking the exit code
of &lt;code&gt;curl&lt;/code&gt;. This exit code is captured by assigning the value of &lt;code&gt;$?&lt;/code&gt; to the
variable &lt;code&gt;$ec&lt;/code&gt;. If &lt;code&gt;curl&lt;/code&gt; exit code is larger than 0 then continue trying to
download the file, which is represented by parameter &lt;code&gt;$1&lt;/code&gt;, from where we left
off, which is accomplished by passing the parameter &lt;code&gt;-C&lt;/code&gt; to &lt;code&gt;curl&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Assuming that the script above is located somewhere in the &lt;code&gt;$PATH&lt;/code&gt;, then using
it is as simple as this:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;acurl.sh http://distrodomain.org/downloads/linux-distro-version-platform.iso
&lt;/pre&gt;


&lt;p&gt;This is definitely a brute force approach, but it does the work.&lt;/p&gt;
&lt;p&gt;[curl]: http://curl.haxx.se/ "cURL"&lt;/p&gt;&lt;/div&gt;</description><category>bash</category><category>debian</category><category>linux</category><category>programming</category><category>quick hacks</category><guid>http://thestandardoutput.com/posts/resume-interrupted-downloads-with-curl-in-linux/</guid><pubDate>Mon, 14 Oct 2013 04:59:23 GMT</pubDate></item><item><title>How to migrate a git repository from GitHub to Gitorious</title><link>http://thestandardoutput.com/posts/how-to-migrate-a-git-repository-from-github-to-gitorious/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;The other day I had to move a git repository from GitHub to Gitorious and after
cracking my head against the wall about this problem for a little while, I think
I came up with a pretty elegant solution.&lt;/p&gt;
&lt;p&gt;Here are some of the assumptions we are making in this turtorial:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;You already have a GitHub and a Gitorious account&lt;/li&gt;
&lt;li&gt;You have an existing GitHub repo that you want to move&lt;/li&gt;
&lt;li&gt;We will use &lt;a href="https://github.com/gorauskas/XmlTidy" title="Xml Tidy"&gt;this repo&lt;/a&gt; as the example&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Login to Gitorious and create a new Project with a Repo&lt;/li&gt;
&lt;li&gt;Find a location on your local system and create a new folder called
   XmlTidy. I usually do this at &lt;code&gt;~/Projects&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Drop into your new folder and initialize a new git repo in it&lt;/li&gt;
&lt;li&gt;Add a remote reference to your GitHub repository called &lt;code&gt;origin&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Pull all code from the &lt;code&gt;master&lt;/code&gt; branch in &lt;code&gt;origin&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Add a remote reference to your Gitorious repository called &lt;code&gt;destination&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Push your local &lt;code&gt;master&lt;/code&gt; branch to the &lt;code&gt;destination&lt;/code&gt; remote repo&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Here's the complete code listing for the above narrative:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;mkdir ~/Projects/XmlTidy
cd ~/Projects/XmlTidy
git init .
git remote add origin git@github.com:gorauskas/XmlTidy.git
git pull origin master
git remote add destination git@gitorious.org:xmltidy/xmltidy.git
git push destination master
&lt;/pre&gt;


&lt;p&gt;That's it... You're done!&lt;/p&gt;&lt;/div&gt;</description><category>git</category><category>programming</category><category>quick hacks</category><guid>http://thestandardoutput.com/posts/how-to-migrate-a-git-repository-from-github-to-gitorious/</guid><pubDate>Thu, 10 Oct 2013 09:16:11 GMT</pubDate></item><item><title>Useful Git Aliases</title><link>http://thestandardoutput.com/posts/useful-git-aliases/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;Here are some useful aliases for Git:&lt;/p&gt;
&lt;h3&gt;git ls&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;git log&lt;/code&gt; is pretty useless. It doesn't list the branch the commit was made on,
it doesn't show colors and it doesn't show branching visuals. But with this
alias you get all that. List commits in short form, with colors and branch/tag
annotations and visuals.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;git config --global alias.ls "log --color --graph --pretty=format:
  '%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)
  %Creset' --abbrev-commit --decorate"
&lt;/pre&gt;


&lt;h3&gt;git ll&lt;/h3&gt;
&lt;p&gt;List commits as above but also showing changed files.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;git config --global alias.ll "log --color --graph --pretty=format:
  '%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)
  %Creset' --abbrev-commit --decorate --numstat"
&lt;/pre&gt;


&lt;h3&gt;git lds&lt;/h3&gt;
&lt;p&gt;List one line commits that display dates.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;git config --global alias.lds "log --color --graph --pretty=format:
  '%Cred%h% %ad%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)
  %Creset' --abbrev-commit --decorate --date=short"
&lt;/pre&gt;


&lt;h3&gt;git grep&lt;/h3&gt;
&lt;p&gt;Find a file path in codebase which contains a string or pattern.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;git config --global alias.grep '!git ls-files | grep -i'
&lt;/pre&gt;


&lt;h3&gt;git ltg&lt;/h3&gt;
&lt;p&gt;Show the last tag.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;git config --global alias.ltg 'describe --tags --abbrev=0'
&lt;/pre&gt;


&lt;h3&gt;git unpushed&lt;/h3&gt;
&lt;p&gt;Sometimes I wonder what is left to push to origin. Git doesn't have an easy
way to see this, but with this alias you get the commits that haven't been
pushed to upstream. Also you get colors and branching visuals like
above.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;global&lt;/span&gt; &lt;span class="n"&gt;alias&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unpushed&lt;/span&gt; &lt;span class="s"&gt;"log --branches --not --remotes&lt;/span&gt;
  &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;graph&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;pretty&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nl"&gt;format&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;Cred&lt;/span&gt;&lt;span class="nf"&gt;%h&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;Creset&lt;/span&gt; &lt;span class="o"&gt;-%&lt;/span&gt;&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;yellow&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="nf"&gt;%d&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;Creset&lt;/span&gt;
  &lt;span class="nf"&gt;%s&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;Cgreen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;%cr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bold&lt;/span&gt; &lt;span class="n"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;Creset&lt;/span&gt;&lt;span class="err"&gt;'&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;abbrev&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;commit&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;
&lt;/pre&gt;


&lt;h3&gt;git undo&lt;/h3&gt;
&lt;p&gt;Git doesn't have an undo option to undo the last commit. But with this alias you
can easily undo the last commit.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;git config --global alias.undo 'reset --hard HEAD~1'
&lt;/pre&gt;


&lt;p&gt;However if you've added many files in the last commit (like a package or
something), git doesn't delete them. But you can do that with this alias: &lt;code&gt;git
clean -f -d&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;git visual&lt;/h3&gt;
&lt;p&gt;Run a git graphical user interface on top of your git directory.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;git config --global alias.visual '!gitk'
&lt;/pre&gt;


&lt;h3&gt;git la&lt;/h3&gt;
&lt;p&gt;Going meta! List out all your aliases.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;git config --global alias.la '!git config -l | grep alias | cut -c 7-'
&lt;/pre&gt;


&lt;h3&gt;Basic stuff&lt;/h3&gt;
&lt;p&gt;Of course I use a ton of basic shortcuts, here’s a few ingrained in my fingertips:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;cp = cherry-pick
st = status -s
cl = clone
ci = commit
co = checkout
br = branch
diff = diff --word-diff
dc = diff --cached
&lt;/pre&gt;


&lt;p&gt;Enjoy!&lt;/p&gt;&lt;/div&gt;</description><category>git</category><category>programming</category><guid>http://thestandardoutput.com/posts/useful-git-aliases/</guid><pubDate>Fri, 27 Sep 2013 07:32:30 GMT</pubDate></item><item><title>Check if a bit is set and bit-masking in CSharp</title><link>http://thestandardoutput.com/posts/check-if-a-bit-is-set-and-bit-masking-in-csharp/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;Today I was talking to a co-worker and the conversation went into the subject of
bit masking. So I wrote the quick command line tool below to explain how bit
masking works and how to find out if a bit is set or not on a value.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="nt"&gt;using&lt;/span&gt; &lt;span class="nt"&gt;System&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nt"&gt;namespace&lt;/span&gt; &lt;span class="nt"&gt;bittest&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;Program&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;void&lt;/span&gt; &lt;span class="n"&gt;Main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="cp"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;WL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;W&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Enter a number &lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="s2"&gt;: "&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                &lt;span class="n"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Int32&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;RL&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
                &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;sbin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Dec2Bin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="n"&gt;byte&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

                &lt;span class="n"&gt;WL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;WL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"{0} in binary is {1}. It has {2} bit(s)"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                              &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;object&lt;/span&gt;&lt;span class="cp"&gt;[]&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sbin&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sbin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Length&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
                &lt;span class="nt"&gt;WL&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="nt"&gt;W&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"What bit do you want to check: "&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

                &lt;span class="nt"&gt;int&lt;/span&gt; &lt;span class="nt"&gt;pos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nt"&gt;Int32&lt;/span&gt;&lt;span class="nc"&gt;.Parse&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;RL&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;

                &lt;span class="nt"&gt;WL&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="nt"&gt;WL&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;SF&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Bit {0} is {1}set!"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                              &lt;span class="nt"&gt;new&lt;/span&gt; &lt;span class="nt"&gt;object&lt;/span&gt;&lt;span class="cp"&gt;[]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pos&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;IsBitSet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pos&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"not "&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
                &lt;span class="nt"&gt;WL&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="nt"&gt;W&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Continue &lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;Y&lt;/span&gt;&lt;span class="p"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="s2"&gt;: "&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

                &lt;span class="nt"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;RL&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"n"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                    &lt;span class="nt"&gt;break&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
            &lt;span class="err"&gt;}&lt;/span&gt;
        &lt;span class="err"&gt;}&lt;/span&gt;

        &lt;span class="nt"&gt;static&lt;/span&gt; &lt;span class="nt"&gt;Func&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;lt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="nt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;gt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nt"&gt;Dec2Bin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
            &lt;span class="nt"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;gt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nt"&gt;Convert&lt;/span&gt;&lt;span class="nc"&gt;.ToString&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;value&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;2&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nt"&gt;static&lt;/span&gt; &lt;span class="nt"&gt;Func&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;lt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="nt"&gt;byte&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;bool&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;gt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nt"&gt;IsBitSet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
            &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;b&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;pos&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;gt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;b&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;amp&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;lt&lt;/span&gt;&lt;span class="o"&gt;;&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;lt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nt"&gt;pos&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="nt"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

        &lt;span class="nt"&gt;static&lt;/span&gt; &lt;span class="nt"&gt;Action&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;lt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="nt"&gt;object&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;gt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nt"&gt;W&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nt"&gt;o&lt;/span&gt; &lt;span class="o"&gt;=&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;gt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nt"&gt;Console&lt;/span&gt;&lt;span class="nc"&gt;.Write&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;o&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nt"&gt;static&lt;/span&gt; &lt;span class="nt"&gt;Action&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;lt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="nt"&gt;object&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;gt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nt"&gt;WL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nt"&gt;o&lt;/span&gt; &lt;span class="o"&gt;=&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;gt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nt"&gt;Console&lt;/span&gt;&lt;span class="nc"&gt;.WriteLine&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;o&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nt"&gt;static&lt;/span&gt; &lt;span class="nt"&gt;Func&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;lt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="nt"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;gt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nt"&gt;RL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;gt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nt"&gt;Console&lt;/span&gt;&lt;span class="nc"&gt;.ReadLine&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
        &lt;span class="nt"&gt;static&lt;/span&gt; &lt;span class="nt"&gt;Func&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;lt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="nt"&gt;string&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;object&lt;/span&gt;&lt;span class="cp"&gt;[]&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;gt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nt"&gt;SF&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
            &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;frmt&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;amp;&lt;/span&gt;&lt;span class="nt"&gt;gt&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nt"&gt;String&lt;/span&gt;&lt;span class="nc"&gt;.Format&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;frmt&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="err"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;
&lt;/pre&gt;


&lt;p&gt;Enjoy!&lt;/p&gt;&lt;/div&gt;</description><category>csharp</category><category>programming</category><category>quick hacks</category><guid>http://thestandardoutput.com/posts/check-if-a-bit-is-set-and-bit-masking-in-csharp/</guid><pubDate>Thu, 15 Aug 2013 02:37:41 GMT</pubDate></item><item><title>Some Notes on Using Git with Cygwin on Windows</title><link>http://thestandardoutput.com/posts/some-notes-on-using-git-with-cygwin-on-windows/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;Just recently I rebuilt a system that I use for work. After I installed Cygwin
on it, I started getting some weird errors when using git with ssh to do some
source control tasks.&lt;/p&gt;
&lt;p&gt;When doing a fetch, pull or push to/from origin, or really any git command that
uses ssh to communicate, the ssh client would complain with the error:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;Could not create directory '/home/jgg/.ssh'.
The authenticity of host 'github.com (204.232.175.90)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?
&lt;/pre&gt;


&lt;p&gt;Once I enter &lt;code&gt;yes&lt;/code&gt;, I get the following:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;Failed to add the host to the list of known hosts (/home/ME/.ssh/known_hosts).
&lt;/pre&gt;


&lt;p&gt;This was happening everytime I was using git under cygwin and very quickly the
situation became completely unsustainable. But after doing a little research, I
found a solution that is pretty simple:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Locate the &lt;code&gt;passwd&lt;/code&gt; file, which is usually at &lt;code&gt;C:\cygwin\etc\&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Open it with your prefered editor&lt;/li&gt;
&lt;li&gt;On the line that starts with your username, change the section that reads
    &lt;code&gt;/home/ME&lt;/code&gt; to read &lt;code&gt;/cygdrive/c/path/to/home/folder/ME&lt;/code&gt; or wherever your
    home folder is.&lt;/li&gt;
&lt;li&gt;Save the changes and restart the Cygwin Terminal&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Expect to see the authenticity check one final time and see the ssh client
actually be able to write to the &lt;code&gt;known_hosts&lt;/code&gt; file.&lt;/p&gt;&lt;/div&gt;</description><category>cygwin</category><category>git</category><category>programming</category><category>windows</category><guid>http://thestandardoutput.com/posts/some-notes-on-using-git-with-cygwin-on-windows/</guid><pubDate>Fri, 24 May 2013 04:55:30 GMT</pubDate></item><item><title>Build Emacs from Source in Ubuntu 13.04</title><link>http://thestandardoutput.com/posts/build-emacs-from-source-in-ubuntu-1304/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;Over the years I have written several of these articles and I find that every 2
to 3 years I need to re-write these notes because the installation process
diverges enough from the previous set of steps that it warrants a re-write.&lt;/p&gt;
&lt;p&gt;The main Linux distribution that I have settled on lately is Xubuntu, which is a
XFCE-based version of Ubuntu. I dabble in other distros also and I am
experimenting a lot lately with Arch and other Debian-based distros. One thing
is clear, the versions of GNU Emacs available with each distribution are
different. So, as a standard I will always try to download the latest stable GNU
Emacs sources and build it on the system I am using at the moment. This ensures
that I have a homogeneous set of features across the different machines and also
that I am pretty close to the bleeding edge.&lt;/p&gt;
&lt;p&gt;In order to get to this state with your Emacs install you can follow the below
steps. These steps are focused on a Debian-based distro using APT. I will assume
that you have a base Debian or Ubuntu system already installed with a common GUI
environment. Again, I wrote these notes for a Xubuntu system running XFCE.
Let's start by downloading and installing the tools needed to build Emacs:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;sudo apt-get install build-essential git git-core curl
&lt;span class="nv"&gt;$ &lt;/span&gt;sudo apt-get install automake autogen autoconf ssh
&lt;/pre&gt;


&lt;p&gt;Next, you need to get the sources for Emacs. There is two ways to go about doing
this: 1) Clone the sources from an Emacs repository directly or 2) Download the
latest compressed source tarball from a FSF/GNU mirror site.&lt;/p&gt;
&lt;p&gt;To clone the Emacs source from a repo, do the following:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/Downloads
&lt;span class="nv"&gt;$ &lt;/span&gt;git clone git://git.savannah.gnu.org/emacs.git
&lt;/pre&gt;


&lt;p&gt;Cloning will take several minutes, because git will get all the history and
changes and we all know that Emacs has a &lt;em&gt;long&lt;/em&gt; history. The clone method is the
way to go for those who will hack on emacs itself. The easier way to do this,
however, and the way that I prefer is to pull the source tarball from a
mirror. A list of available mirrors can be found at the &lt;a href="http://www.gnu.org/prep/ftp.html" title="GNU Emacs mirror list"&gt;FSF site&lt;/a&gt;. You can
pick any of these sites and download from it. The command to do that will differ
based on the mirror you pick, but should look something like this:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;curl -O http://mirror.sdunix.com/gnu/emacs/emacs-24.3.tar.gz
&lt;/pre&gt;


&lt;p&gt;While you are downloading the tarball or cloning the repo you should open
another terminal window and start installing some needed Emacs dependencies in
parallel:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;sudo apt-get install texinfo libncurses5-dev libgtk2.0-dev libgif-dev
&lt;span class="nv"&gt;$ &lt;/span&gt;sudo apt-get install libjpeg-dev libpng-dev libxpm-dev libtiff4-dev
&lt;span class="nv"&gt;$ &lt;/span&gt;sudo apt-get install libxml2-dev librsvg2-dev libotf-dev libm17n-dev
&lt;span class="nv"&gt;$ &lt;/span&gt;sudo apt-get install libgpm-dev libgnutls-dev libgconf2-dev libdbus-1-dev
&lt;/pre&gt;


&lt;p&gt;Once the above deps are installed and you finished retrieving the sources for
Emacs, it's time to do the actual build. Decompress the source if you downloaded
it and change directory into the Emacs source:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;tar -zxvf emacs-24.3.tar.gz
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/Downloads/emacs-24.3/
&lt;/pre&gt;


&lt;p&gt;Configure the build according to what you want your installation to look like:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;sudo ./autogen.sh
&lt;span class="nv"&gt;$ &lt;/span&gt;./configure
&lt;/pre&gt;


&lt;p&gt;I use the vanilla configuration, but you can change it to what suits you best
and you can view all alternatives by using &lt;code&gt;./configure --help&lt;/code&gt; ... If you don't
like what &lt;code&gt;configure&lt;/code&gt; has done for you (read the &lt;code&gt;configure&lt;/code&gt; output) you can
also clean things up and start over with &lt;code&gt;make distclean&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The key thing that I am trying to achieve is a message from &lt;code&gt;configure&lt;/code&gt; that
looks very similar to the below output. Note all the &lt;code&gt;yes&lt;/code&gt; values next to all
the stuff that &lt;code&gt;configure&lt;/code&gt; checks for; this is a direct outcome of installing
all the dependency packages above. Emacs absolutely needs &lt;code&gt;texinfo&lt;/code&gt;, &lt;code&gt;ncurses&lt;/code&gt;,
an X toolkit and the image libraries to even build. The rest of the stuff is
nice to have, but if you don't install it you will get a &lt;code&gt;no&lt;/code&gt; from &lt;code&gt;configure&lt;/code&gt;
for that feature check.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;... a ton of output

Configured for `x86_64-unknown-linux-gnu'.

  Where should the build process find the source code?    ~/Downloads/emacs-24.3
  What compiler should emacs be built with?               gcc -std=gnu99 -g3 -O2
  Should Emacs use the GNU version of malloc?             yes
      (Using Doug Lea's new malloc from the GNU C Library.)
  Should Emacs use a relocating allocator for buffers?    no
  Should Emacs use mmap(2) for buffer allocation?         no
  What window system should Emacs use?                    x11
  What toolkit should Emacs use?                          GTK2
  Where do we find X Windows header files?                Standard dirs
  Where do we find X Windows libraries?                   Standard dirs
  Does Emacs use -lXaw3d?                                 no
  Does Emacs use -lXpm?                                   yes
  Does Emacs use -ljpeg?                                  yes
  Does Emacs use -ltiff?                                  yes
  Does Emacs use a gif library?                           yes -lgif
  Does Emacs use -lpng?                                   yes
  Does Emacs use -lrsvg-2?                                yes
  Does Emacs use imagemagick?                             no
  Does Emacs use -lgpm?                                   yes
  Does Emacs use -ldbus?                                  yes
  Does Emacs use -lgconf?                                 yes
  Does Emacs use GSettings?                               yes
  Does Emacs use -lselinux?                               no
  Does Emacs use -lgnutls?                                yes
  Does Emacs use -lxml2?                                  yes
  Does Emacs use -lfreetype?                              yes
  Does Emacs use -lm17n-flt?                              yes
  Does Emacs use -lotf?                                   yes
  Does Emacs use -lxft?                                   yes
  Does Emacs use toolkit scroll bars?                     yes

... more output
&lt;/pre&gt;


&lt;p&gt;Now you can go into the actual build of Emacs by issuing the following command:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;make
&lt;/pre&gt;


&lt;p&gt;And then last step is to install the Emacs you just finished building:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;sudo make install
&lt;/pre&gt;


&lt;p&gt;... and run it:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;emacs &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;


&lt;p&gt;Enjoy hacking with Emacs!&lt;/p&gt;
&lt;p&gt;&lt;em&gt;P. S.&lt;/em&gt; One last step that is personal and relevant to me only is to install my
Emacs configuration. Execute the following to accomplish that:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;rm -r .emacs.d
&lt;span class="nv"&gt;$ &lt;/span&gt;git clone git@github.com:gorauskas/.emacs.d.git
&lt;/pre&gt;


&lt;p&gt;You will of course need to have the correct encryption key in order to clone the
repo like the line above.&lt;/p&gt;&lt;/div&gt;</description><category>emacs</category><category>linux</category><category>programming</category><guid>http://thestandardoutput.com/posts/build-emacs-from-source-in-ubuntu-1304/</guid><pubDate>Mon, 06 May 2013 22:28:28 GMT</pubDate></item><item><title>Convert an Integer to a Binary Representation</title><link>http://thestandardoutput.com/posts/convert-an-integer-to-a-binary-representation/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;Here is a quick way to convert any integer &lt;code&gt;n&lt;/code&gt; into a string that represents the
&lt;code&gt;n&lt;/code&gt; integer in binary notation:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;def dec_to_bin(n, bits=32):
    return ''.join([str((n &amp;amp;gt;&amp;amp;gt; y) &amp;amp;amp; 1) for y in range(bits - 1, -1, -1)])
&lt;/pre&gt;


&lt;p&gt;What's going on in the above code? This can be better explained if we read the
&lt;code&gt;return&lt;/code&gt; line in the &lt;code&gt;dec_to_bin&lt;/code&gt; function backwards. First we create a list of
integers from 31 to 0 in order to iterate through it. This list is created with
the built-in &lt;code&gt;range&lt;/code&gt; function and it uses the number of bits that we passed into
the function, with a default being 32. Next, we iterate through the list with
each number being represented by &lt;code&gt;y&lt;/code&gt;. Then we take the number parameter &lt;code&gt;n&lt;/code&gt;,
which is the number we want to transform to binary, and we shift its bits to the
right by &lt;code&gt;y&lt;/code&gt; places. Then we apply a bitwise &lt;code&gt;and&lt;/code&gt; operation on the result of
that right shift and the literal value of 1. This &lt;code&gt;and&lt;/code&gt; operation tells us if
the bit at location &lt;code&gt;y&lt;/code&gt; is turned on or off. We then make a string out of the
value and append it to the string that we are building to return to the
user. This is a perfect example of Python's conciseness and the power of list
comprehensions.&lt;/p&gt;
&lt;p&gt;You can use the code above like so:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt;&amp;gt;&amp;gt; print dec_to_bin(255)
00000000000000000000000011111111
&lt;/pre&gt;


&lt;p&gt;Enjoy!&lt;/p&gt;&lt;/div&gt;</description><category>programming</category><category>python</category><guid>http://thestandardoutput.com/posts/convert-an-integer-to-a-binary-representation/</guid><pubDate>Mon, 15 Apr 2013 21:17:49 GMT</pubDate></item><item><title>Get the latest version from a Git repository</title><link>http://thestandardoutput.com/posts/get-the-latest-version-from-a-git-repository/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;If you want to get the latest version from a Git repository and you don't care
about any local changes, do the following:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;git reset --hard HEAD
git clean -f
git pull
&lt;/pre&gt;


&lt;p&gt;The above will copy the latest code from the repo and overwrite the local
copy.&lt;/p&gt;&lt;/div&gt;</description><category>git</category><category>programming</category><guid>http://thestandardoutput.com/posts/get-the-latest-version-from-a-git-repository/</guid><pubDate>Sun, 02 Sep 2012 05:29:46 GMT</pubDate></item><item><title>How to use Emacs key bindings in Visual Studio 2010</title><link>http://thestandardoutput.com/posts/how-to-use-emacs-key-bindings-in-visual-studio-2010/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;Visual Studio 2008 used to have a Emacs key mapping scheme that you could pick
from the Options dialog under the Keyboard options. Visual Studio 2010 did away
with that key mapping scheme.&lt;/p&gt;
&lt;p&gt;&lt;img alt="VS2010 Keyboard Mapping Schemes" src="http://farm9.staticflickr.com/8167/7524332504_88780c5245.jpg"&gt;&lt;/p&gt;
&lt;p&gt;But those emacs enthusiasts among us who use Visual Studio should not
fear... There is now an Emacs Emulation extension available for VS2010 that you
can install via the Extensions Manager under the Tools menu.&lt;/p&gt;
&lt;h3&gt;Installation&lt;/h3&gt;
&lt;p&gt;To install the Emacs Emulation extension, follow these steps:&lt;/p&gt;
&lt;p&gt;&lt;img alt="VS2010 Extensions Manager" src="http://farm9.staticflickr.com/8023/7524332642_147e3ebc33.jpg"&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open Visual Studio 2010&lt;/li&gt;
&lt;li&gt;Go to the Tools menu&lt;/li&gt;
&lt;li&gt;Select the Extension Manager&lt;/li&gt;
&lt;li&gt;On the Extension Manager dialog, select Online Gallery&lt;/li&gt;
&lt;li&gt;Search the Online Gallery for Emacs (top right)&lt;/li&gt;
&lt;li&gt;Select and install the Emacs Emulation package&lt;/li&gt;
&lt;li&gt;Restart Visual Studio 2010&lt;/li&gt;
&lt;li&gt;From the Options dialog, the Emacs key mapping scheme is now available&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img alt="VS2010 Emacs Keyboard Mapping Scheme" src="http://farm8.staticflickr.com/7130/7524332716_e2e039ab36.jpg"&gt;&lt;/p&gt;
&lt;p&gt;Beyond the default Emacs key bindings, the ones that I find most useful are the
following:&lt;/p&gt;
&lt;dl&gt;
&lt;dt&gt;Edit.EmacsExtendedCommand&lt;/dt&gt;
&lt;dd&gt;&lt;em&gt;ALT + X&lt;/em&gt; - Places the cursor in the Find/Command box on the Standard toolbar.&lt;/dd&gt;
&lt;dt&gt;Edit.EmacsFindReplace&lt;/dt&gt;
&lt;dd&gt;&lt;em&gt;SHIFT + ALT + 5&lt;/em&gt; - Displays the replace options in the Quick tab of the Find and Replace dialog box.&lt;/dd&gt;
&lt;dt&gt;Edit.EmacsSwapPointAndMark&lt;/dt&gt;
&lt;dd&gt;&lt;em&gt;CTRL + X, CTRL + X&lt;/em&gt; - Moves the cursor to the current mark in the location stack and moves the current mark to the location where the cursor mark was when the command was invoked.&lt;/dd&gt;
&lt;dt&gt;Edit.EmacsCloseOtherWindow&lt;/dt&gt;
&lt;dd&gt;&lt;em&gt;CTRL + X, 1&lt;/em&gt; - When a window is split, this shortcut closes the pane that does not have focus.&lt;/dd&gt;
&lt;dt&gt;Edit.EmacsSplitVertical&lt;/dt&gt;
&lt;dd&gt;&lt;em&gt;CTRL + X, 2&lt;/em&gt; - Splits the current document in half vertically. The current line of code is centered in each window.&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;... and that's all, folks!&lt;/p&gt;&lt;/div&gt;</description><category>csharp</category><category>emacs</category><category>programming</category><category>visual studio</category><guid>http://thestandardoutput.com/posts/how-to-use-emacs-key-bindings-in-visual-studio-2010/</guid><pubDate>Sun, 08 Jul 2012 04:33:04 GMT</pubDate></item><item><title>Extracting a .NET Assembly from SQL Server 2005</title><link>http://thestandardoutput.com/posts/extracting-a-net-assembly-from-sql-server-2005/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;I just answered a great question on Stackoverflow:
&lt;a href="http://stackoverflow.com/questions/4103406/extracting-a-net-assembly-from-sql-server-2005"&gt;Extracting a .NET Assembly from SQL Server 2005&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Yes, this is possible. The actual binary representation of the assemblies live
in the SQL catalog for your server. Namely, if you run a join between
&lt;code&gt;sys.assembly_files&lt;/code&gt; and &lt;code&gt;sys.assemblies&lt;/code&gt; you can get to all the information you
need. The assemblies binary is in the content column of the &lt;code&gt;sys.assembly_files&lt;/code&gt;
view.&lt;/p&gt;
&lt;p&gt;But in order to extract the binary representation from SQL Server and into a
file on disk you will have to write some .NET code that needs to run on the same
database where the assemblies you refer to are located now. In Visual Studio
start a SQL CLR project and add a class to it with the following code:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IO&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SqlClient&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SqlTypes&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;Microsoft&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SqlServer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Server&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Security&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Permissions&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;namespace&lt;/span&gt; &lt;span class="n"&gt;ExtractSqlAssembly&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;PermissionSet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SecurityAction&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Demand&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Unrestricted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"FullTrust"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
    &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;partial&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="n"&gt;SaveSqlAssembly&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;SqlProcedure&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;SaveAssembly&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;assemblyName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;sql&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;@"SELECT AF.content FROM sys.assembly_files AF JOIN sys.assemblies A ON AF.assembly_id = A.assembly_id where AF.file_id = 1 AND A.name = @assemblyname"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SqlConnection&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;SqlConnection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"context connection=true"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SqlCommand&lt;/span&gt; &lt;span class="n"&gt;cmd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;SqlCommand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sql&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="n"&gt;SqlParameter&lt;/span&gt; &lt;span class="n"&gt;param&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;SqlParameter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"@assemblyname"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;SqlDbType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;VarChar&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                    &lt;span class="n"&gt;param&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;assemblyName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                    &lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Parameters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;param&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                    &lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Open&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  &lt;span class="c1"&gt;// Read in the assembly byte stream&lt;/span&gt;
                    &lt;span class="n"&gt;SqlDataReader&lt;/span&gt; &lt;span class="n"&gt;reader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ExecuteReader&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
                    &lt;span class="n"&gt;reader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Read&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
                    &lt;span class="n"&gt;SqlBytes&lt;/span&gt; &lt;span class="n"&gt;bytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;reader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GetSqlBytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                    &lt;span class="c1"&gt;// write the byte stream out to disk&lt;/span&gt;
                    &lt;span class="n"&gt;FileStream&lt;/span&gt; &lt;span class="n"&gt;bytestream&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;FileStream&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;FileMode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CreateNew&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                    &lt;span class="n"&gt;bytestream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Length&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                    &lt;span class="n"&gt;bytestream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;


&lt;p&gt;Then build the project and deploy it to your database. Make sure that the CLR
Enabled configuration option is enabled on the SQL Server. This is probably
already enabled, since you have assemblies on it. In case clr execution is not
enabled you can run the following code on SSMS to enable it:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;sp_configure 'clr enabled', 1
go

reconfigure
go
&lt;/pre&gt;


&lt;p&gt;One more thing that you need to be aware of is the by default SQL server may not
allow you to write to the disk from the .NET code. If you get a FileIO security
error when you run the code above by calling the stored procedure in SSMS, you
will need to configure the proper permission set for the assembly. You can do
this via SSMS: right-click the new assembly and look at the Permission Set in
the Properties dialog. Set it to External Access. Now you should be able to
export your assemblies by running the following code in SSMS:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;exec SaveAssembly 'AssemblyName', 'f:\path\to\assemblyname.dll'
&lt;/pre&gt;&lt;/div&gt;</description><category>csharp</category><category>database</category><category>programming</category><category>sql server</category><category>t-sql</category><guid>http://thestandardoutput.com/posts/extracting-a-net-assembly-from-sql-server-2005/</guid><pubDate>Fri, 05 Nov 2010 04:16:26 GMT</pubDate></item><item><title>Testing Regular Expressions with Regex Builder</title><link>http://thestandardoutput.com/posts/testing-regular-expressions-with-regex-builder/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;I have been working on a recent project where I need to make heavy use ofregular
expressions and I have been spending a lot of time tweaking
theseexpressions. Well, the tweaking is a lot easier if you can use a visual
tool totest the expressions. There are lots of such tools out there, and I
provide ashort list below, but I decided to hack together my own tool just to
learn howthese things work under the hood.&lt;/p&gt;
&lt;p&gt;This is a very simple tool written in CSharp to visually highlight
regularexpression matches. The source is available on github and it's called
&lt;a href="https://www.gitorious.org/regex-builder"&gt;RegexBuilder&lt;/a&gt; (I know... very original
name).&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.flickr.com/photos/gorauskas/5106157334/"&gt;&lt;img alt="Regex Builder" src="http://farm2.static.flickr.com/1070/5106157334_7b8a01ae07.jpg"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here's how it works... There are 2 text boxes, one for the regular
expressionitself and another for the test string and a couple of check boxes for
theoptions. I run the regular expression provided with options against the
teststring and I receive back a collection of matches. I also have a Style
classthat encapsulates two Colors for background and foreground. I then
loopthrought the match collection and I apply the alternating Style to each
Matchin the collection. The highlighting is made possible by the properties of
the rich text box. This is the core of the code:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;string regexPattern = textRegex.Text;
string inputText = rtbTest.Text;
int i = 0;
RegexOptions ro = new RegexOptions();

if (!checkCase.Checked)
    ro = ro | RegexOptions.IgnoreCase;

if (checkMultiLine.Checked)
    ro = ro | RegexOptions.Multiline;

regex = new Regex(regexPattern, ro);
matches = regex.Matches(inputText);

foreach (Match m in matches) {
    Style s = getStyle(i);
    rtbTest.SelectionStart = m.Index;
    rtbTest.SelectionLength = m.Length;
    rtbTest.SelectionColor = s.ForegroundColor;
    rtbTest.SelectionBackColor = s.BackgroundColor;
    rtbTest.Select(m.Index + m.Length, 0);

    i++;
}
&lt;/pre&gt;


&lt;p&gt;Regex Builder was a simple mental exercise around regular expressions for meand
it's the minimum thing that actually works. I have no plans to develop
itfurther. There are other tools that fall in this &lt;em&gt;Regex Tester/Debugger&lt;/em&gt;
category and are able to accomplish much more than my humble Regex Builder:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://weblogs.asp.net/rosherove/archive/2006/07/09/IntroducingRegulazy10.aspx"&gt;Regulazy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.webresourcesdepot.com/learn-test-regular-expressions-with-the-regulator/"&gt;Regulator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.weitz.de/regex-coach/index.html"&gt;The Regex Coach&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.sellsbrothers.com/Posts/Details/12425"&gt;RegexDesigner.NET&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://regexpal.com/"&gt;RegexPal&lt;/a&gt; - this is an online tool that does basically the same as my Regex Builder&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description><category>csharp</category><category>programming</category><guid>http://thestandardoutput.com/posts/testing-regular-expressions-with-regex-builder/</guid><pubDate>Sat, 23 Oct 2010 02:48:00 GMT</pubDate></item><item><title>Delicious to Blogger Python Script</title><link>http://thestandardoutput.com/posts/delicious-to-blogger-python-script/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;Readers of this blog (that means my wife and my mom) will notice that there is a
&lt;a href="http://www.thestandardoutput.com/2010/10/delicious-grep-links-blogger-for-2010-10-09/"&gt;new post&lt;/a&gt;
with a weird title right before this one (in chronological order). What's going
on with that?&lt;/p&gt;
&lt;p&gt;On a weekly basis I save several links to
&lt;a href="http://www.delicious.com/gorauskas"&gt;my Delicious account&lt;/a&gt; and I consider that
to be a pretty good representation of what is going on in mind at the time. The
only problem is that sometimes I link to something and then it gets lost in the
black hole that Delicious can sometimes be. There are situations when I saved a
link and didn't go back to look for it until a year later.&lt;/p&gt;
&lt;p&gt;So I thought that I wanted to group these links together and bring them up front
and center in my radar. I just want to have a little better visibility into what
I am thinking at the time. This is a task that can be easily automated and I
wrote a script in Python to do that for
me. &lt;a href="http://github.com/gorauskas/delicious-greplinks-blogger"&gt;You can look at the code here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Basically, the script looks at the links posted to Delicious since a certain
date, downloads the information about those links and creates a blog post for my
&lt;a href="https://www.blogger.com/start"&gt;Blogger&lt;/a&gt; account based on the
&lt;a href="http://www.delicious.com/"&gt;Delicious&lt;/a&gt; links.&lt;/p&gt;&lt;/div&gt;</description><category>programming</category><category>python</category><category>quick hacks</category><guid>http://thestandardoutput.com/posts/delicious-to-blogger-python-script/</guid><pubDate>Sat, 09 Oct 2010 21:19:00 GMT</pubDate></item><item><title>Tidy up your XML files</title><link>http://thestandardoutput.com/posts/tidy-up-your-xml-files/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;I have been working with some really large XML files (20 MB) that I have to
parse and save the data to a database. The XML data is available to me as a
single line of XML (probably to save up space) which is quite unreadable by a
human. There are many tools out there that will help you tidy up and reformat
your XML to a human-readable format. But writing my own tool using C# and LINQ
to XML is so trivial that I decided to do my own. Here's the code:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;using System;
using System.IO;
using System.Xml;
using System.Linq;
using System.Xml.Linq;

namespace XmlTidy {
    class Program {
        static void Main(string[] args) {
            try {
                XmlTidy(args[0]);
            } catch (FileNotFoundException ex) {
                Console.WriteLine("{0}: {1}", ex.Message, ex.FileName);
            }
        }

        static void XmlTidy(string filename) {
            if (File.Exists(filename)) {
                var doc = XDocument.Load(filename);
                doc.Save(filename, SaveOptions.None);
            } else {
                throw new FileNotFoundException("File not found", filename);
            }
        }
    }
}
&lt;/pre&gt;


&lt;p&gt;What's going on in the code above? When you call the program from the command
line, it expects a file name as a parameter, like so: &lt;code&gt;xmltidy
samplefile.xml&lt;/code&gt;. Next is the call to the &lt;code&gt;XmlTidy&lt;/code&gt; function, which checks if the
file exists and then loads the file contents into a LINQ to XML document, and
then we just save the file again to the same location. That's it!  The XDocument
class takes care of formating the XML data for you.&lt;/p&gt;
&lt;p&gt;You can download the full source, which has some enhancements, from my
&lt;a href="https://www.gitorious.org/xmltidy"&gt;Github project&lt;/a&gt;. This code works on
Windows 7 with .NET 4.0 and also on Ubuntu 10.04 with Mono 2.6.7 .&lt;/p&gt;&lt;/div&gt;</description><category>csharp</category><category>programming</category><guid>http://thestandardoutput.com/posts/tidy-up-your-xml-files/</guid><pubDate>Sat, 18 Sep 2010 21:30:00 GMT</pubDate></item></channel></rss>