<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>I/Octopus</title>
  <link href="http://deckeraa.github.comindex.xml" rel="self" />
  <link href="http://deckeraa.github.com"/>
  <updated>Lisp error in nil: (wrong-type-argument integerp nil)</updated>
  <id>http://deckeraa.github.comindex.xml</id>
  <entry><title type="html">Infinite Sequences and Series Cheat Sheet</title><author><name>nil</name></author><link href="http://deckeraa.github.com/ioctopus/2013/05/11_infinite-sequences-and-series-cheat-sheet.html"/><updated>2013-05-11T17:37:00Z</updated><published>2013-05-11T17:37:00Z</published><id>ioctopus/2013/05/11_infinite-sequences-and-series-cheat-sheet.html</id><category scheme="/tags/calculus.html" term="Calculus" label="Calculus"/><category scheme="/tags/tutoring.html" term="Tutoring" label="Tutoring"/><content type="html">&lt;p&gt;
Throughout my time tutoring Calculus II, 
I have found that oftentimes people have a hard time remembering all
the series tests, so I put together this cheat sheet last year.
&lt;/p&gt;
&lt;p&gt;
It contains all of the series tests, not including power series,
that are covered in Chapter 12 of Stewart Calculus, 6th ed.
Additionally, important definitions are included.
&lt;/p&gt;
&lt;p&gt;
Most people will want the pdf:
&lt;a href="./series.pdf"&gt;series.pdf&lt;/a&gt;
but the source is also availble for modification:
&lt;a href="./series.tex"&gt;series.tex&lt;/a&gt;



&lt;/p&gt;</content></entry><entry><title type="html">Connecting to the UWPlatt network</title><author><name>nil</name></author><link href="http://deckeraa.github.com/ioctopus/2013/03/07_connecting-to-the-uwplatt-network.html"/><updated>2013-03-07T18:30:00Z</updated><published>2013-03-07T18:30:00Z</published><id>ioctopus/2013/03/07_connecting-to-the-uwplatt-network.html</id><content type="html">&lt;p&gt;
Connecting to the UWPlatt wireless network, a network on my university's campus, can be tricky.
Below is a snippet from my &lt;code&gt;/etc/wpa_supplicant/wpa_supplicant.conf&lt;/code&gt;.
Be sure to replace &lt;code&gt;your_netid_username&lt;/code&gt; and &lt;code&gt;your_password&lt;/code&gt; with your
actual username and password.
&lt;/p&gt;



&lt;pre class="src src-sh"&gt;&lt;span style="color: #dfaf8f;"&gt;network&lt;/span&gt;={
        &lt;span style="color: #dfaf8f;"&gt;ssid&lt;/span&gt;=&lt;span style="color: #cc9393;"&gt;"UWPlatt"&lt;/span&gt;
        &lt;span style="color: #dfaf8f;"&gt;priority&lt;/span&gt;=6
        &lt;span style="color: #dfaf8f;"&gt;proto&lt;/span&gt;=RSN
        &lt;span style="color: #dfaf8f;"&gt;pairwise&lt;/span&gt;=CCMP
        &lt;span style="color: #dfaf8f;"&gt;group&lt;/span&gt;=CCMP
        &lt;span style="color: #dfaf8f;"&gt;key_mgmt&lt;/span&gt;=WPA-EAP
        &lt;span style="color: #dfaf8f;"&gt;eap&lt;/span&gt;=PEAP
        &lt;span style="color: #dfaf8f;"&gt;identity&lt;/span&gt;=&lt;span style="color: #cc9393;"&gt;"your_netid_username"&lt;/span&gt;
        &lt;span style="color: #dfaf8f;"&gt;anonymous_identity&lt;/span&gt;=&lt;span style="color: #cc9393;"&gt;"anon"&lt;/span&gt;
        &lt;span style="color: #dfaf8f;"&gt;password&lt;/span&gt;=&lt;span style="color: #cc9393;"&gt;"your_password"&lt;/span&gt;
        &lt;span style="color: #dfaf8f;"&gt;phase2&lt;/span&gt;=&lt;span style="color: #cc9393;"&gt;"auth=MSCHAPv2"&lt;/span&gt;
}
&lt;/pre&gt;

</content></entry><entry><title type="html">Clojure/ClojureScript Notes</title><author><name>nil</name></author><link href="http://deckeraa.github.com/ioctopus/2013/02/11_clojureclojurescript-notes.html"/><updated>2013-02-11T23:58:00Z</updated><published>2013-02-11T23:58:00Z</published><id>ioctopus/2013/02/11_clojureclojurescript-notes.html</id><content type="html">&lt;p&gt;
These notes document an ongoing project and are not yet complete.
&lt;/p&gt;
&lt;div id="outline-container-1" class="outline-3"&gt;
&lt;h3 id="sec-1"&gt;Useful links&lt;/h3&gt;
&lt;div class="outline-text-3" id="text-1"&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://clojure.org/"&gt;http://clojure.org/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/clojure/clojurescript"&gt;ClojureScript GitHub Site&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/div&gt;

&lt;/div&gt;

&lt;div id="outline-container-2" class="outline-3"&gt;
&lt;h3 id="sec-2"&gt;Install Log&lt;/h3&gt;
&lt;div class="outline-text-3" id="text-2"&gt;

&lt;p&gt;It was recommend that I use a build system called &lt;a href="https://github.com/technomancy/leiningen#readme"&gt;Leiningen&lt;/a&gt; to manage Clojure compilation.
&lt;/p&gt;&lt;ul&gt;
&lt;li&gt;Downloaded the &lt;code&gt;lein&lt;/code&gt; script to my scripts folder (which has execute permissions).
&lt;/li&gt;
&lt;li&gt;Wow. That was easy. Now running &lt;code&gt;lein repl&lt;/code&gt; form anywhere starts a repl that appears
      to work.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;    # I dont think that the following steps were necessary.
    # - Now to install ClojureScript:
    #   - &lt;code&gt;git clone git://github.com/clojure/clojurescript.git&lt;/code&gt;
    #   - &lt;code&gt;cd ./clojurescript&lt;/code&gt;
    #   - &lt;code&gt;./scripts/bootstrap&lt;/code&gt;
    #   - Took about a minute to install. No problems so far.
    #   - &lt;code&gt;export CLOJURESCRIPT_HOME=/home/aaron/scripts/clojurescript&lt;/code&gt;
&lt;/p&gt;

&lt;/div&gt;

&lt;div id="outline-container-2-1" class="outline-4"&gt;
&lt;h4 id="sec-2-1"&gt;Modern CLJS Tutorial&lt;/h4&gt;
&lt;div class="outline-text-4" id="text-2-1"&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git clone https://github.com/magomimmo/modern-cljs.git&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;cd ./modern-cljs&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;lein ring server-headless&lt;/code&gt; failed. Got issued a warning that
     Leiningen was out of date.
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;lein update&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;lein ring server-headless&lt;/code&gt; works now.
&lt;/li&gt;
&lt;li&gt;CURRENT&lt;sub&gt;END&lt;/sub&gt;&lt;sub&gt;OF&lt;/sub&gt;&lt;sub&gt;NOTES&lt;/sub&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content></entry><entry><title type="html">Installing Hardened Gentoo with Full Disk Encryption</title><author><name>nil</name></author><link href="http://deckeraa.github.com/ioctopus/2013/01/20_installing-hardened-gentoo-with-full-disk-encryption.html"/><updated>2013-01-20T20:55:00Z</updated><published>2013-01-20T20:55:00Z</published><id>ioctopus/2013/01/20_installing-hardened-gentoo-with-full-disk-encryption.html</id><content type="html">&lt;p&gt;
These notes document an ongoing project and are not yet complete.
&lt;/p&gt;
&lt;div id="outline-container-1" class="outline-3"&gt;
&lt;h3 id="sec-1"&gt;Useful Links and Documents&lt;/h3&gt;
&lt;div class="outline-text-3" id="text-1"&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://en.gentoo-wiki.com/wiki/DM-Crypt_with_LUKS"&gt;The Gentoo Wiki page on dm-crypt with LUKS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://world.std.com/~reinhold/dicewarefaq.html"&gt;Diceware Passphrase choosing system&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/div&gt;

&lt;/div&gt;

&lt;div id="outline-container-2" class="outline-3"&gt;
&lt;h3 id="sec-2"&gt;Install Log&lt;/h3&gt;
&lt;div class="outline-text-3" id="text-2"&gt;

&lt;ul&gt;
&lt;li&gt;Booted into the Gentoo minimal install live-cd.
&lt;/li&gt;
&lt;li&gt;Check hard drive (/dev/sda) for bad sectors: &lt;code&gt;/sbin/badblocks -c 10240 -n -t random -v /dev/sda&lt;/code&gt;.
      Bad sectors can contain old information that could compromise data.
      This took several hours. No bad blocks were found.
&lt;/li&gt;
&lt;li&gt;Overwrite hard drive with random data: &lt;code&gt;dd if=/dev/urandom of=/dev/sda&lt;/code&gt;.
      This operation took 74220.1 seconds, or about 20.6 hours. 
      Creating random numbers must be hard work.
&lt;/li&gt;
&lt;li&gt;While I did this I set up wpa&lt;sub&gt;supplicant&lt;/sub&gt; to connect to my wireless network.
      Don't forget to start dhcpcd.
&lt;/li&gt;
&lt;li&gt;Partitioned disk. This is the first linux install where I haven't had to work around pre-existing partitions :)

&lt;table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides"&gt;
&lt;caption&gt;&lt;/caption&gt;
&lt;colgroup&gt;&lt;col class="left" /&gt;&lt;col class="left" /&gt;&lt;col class="left" /&gt;&lt;col class="left" /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th scope="col" class="left"&gt;Partition&lt;/th&gt;&lt;th scope="col" class="left"&gt;Device&lt;/th&gt;&lt;th scope="col" class="left"&gt;Size&lt;/th&gt;&lt;th scope="col" class="left"&gt;Reason for size&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td class="left"&gt;/boot&lt;/td&gt;&lt;td class="left"&gt;/dev/sda1&lt;/td&gt;&lt;td class="left"&gt;512 MB&lt;/td&gt;&lt;td class="left"&gt;Hold several kernel images&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="left"&gt;swap&lt;/td&gt;&lt;td class="left"&gt;/dev/sda2&lt;/td&gt;&lt;td class="left"&gt;8 GB&lt;/td&gt;&lt;td class="left"&gt;2 GB Swap + (4 real + 2 swap) image&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="left"&gt;/&lt;/td&gt;&lt;td class="left"&gt;/dev/sda3&lt;/td&gt;&lt;td class="left"&gt;311.5 GB&lt;/td&gt;&lt;td class="left"&gt;Remainder of drive&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;


&lt;/li&gt;
&lt;li&gt;Load encryption modules: &lt;code&gt;for i in dm-crypt dm-mod serpent sha256 blowfish;do modprobe $i;done&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Running &lt;code&gt;cryptsetup --help&lt;/code&gt; reveals that my live CD has the cryptsetup-luks executable
&lt;/li&gt;
&lt;li&gt;Set-up swap encryption for use during installation (from wiki page):
&lt;/li&gt;
&lt;/ul&gt;




&lt;pre class="src src-sh"&gt;cryptsetup -c blowfish -h sha256 -d /dev/random create swap /dev/sda2 
mkswap /dev/mapper/swap
swapon /dev/mapper/swap
&lt;/pre&gt;


&lt;ul&gt;
&lt;li&gt;I want 64-bit AES module: &lt;code&gt;modprobe aes_x86_64&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Encrypt root partition with keyphrase generated using Diceware: 
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;    &lt;code&gt;cryptsetup -y --cipher serpent-cbc-essiv:sha256 --key-size 256 luksFormat /dev/sda3&lt;/code&gt;
&lt;/p&gt;&lt;ul&gt;
&lt;li&gt;Create root mapping: &lt;code&gt;cryptsetup luksOpen /dev/sda3 root&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Format root to ext3: &lt;code&gt;/sbin/mkfs.ext3 -j -m 1 -O dir_index,filetype,sparse_super /dev/mapper/root&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Format boot to ext2: &lt;code&gt;mkfs.ext2 /dev/sda1&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Mount root: &lt;code&gt;mount -t ext3 /dev/mapper/root /mnt/gentoo&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Go to root: &lt;code&gt;cd /mnt/gentoo&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Downloaded stage3-amd64-hardened-20130110.tar.bz2 from a mirror. &lt;code&gt;links http://www.gentoo.org/main/en/mirrors.xml&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Checked tar.bz2 integrity with sha512sum.
&lt;/li&gt;
&lt;li&gt;Extract files: &lt;code&gt;tar xvpjf stage3-amd64-hardened-20130110.tar.bz2&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Created &lt;code&gt;/mnt/gentoo/etc/portage/make.conf&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;




&lt;pre class="src src-sh"&gt;&lt;span style="color: #dfaf8f;"&gt;CFLAGS&lt;/span&gt;=&lt;span style="color: #cc9393;"&gt;"-O2 -pipe -mtune=athlon64"&lt;/span&gt;
&lt;span style="color: #dfaf8f;"&gt;CXXFLAGS&lt;/span&gt;=&lt;span style="color: #cc9393;"&gt;"${CFLAGS}"&lt;/span&gt;
&lt;span style="color: #dfaf8f;"&gt;MAKEOPTS&lt;/span&gt;=&lt;span style="color: #cc9393;"&gt;"-j3"&lt;/span&gt;
&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Set mirrors in make.conf: ~mirrorselect -i -o &amp;gt;&amp;gt; /mnt/gentoo/etc/portage/make.conf
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;    &amp;amp;&amp;amp; mirrorselect -i -r -o &amp;gt;&amp;gt; /mnt/gentoo/etc/portage/make.conf~. 
    This had no effect. I will skip this step and come back later if
    it turns out I really needed it. TODO
&lt;/p&gt;&lt;ul&gt;
&lt;li&gt;Copy DNS info: &lt;code&gt;cp -L /etc/resolv.conf /mnt/gentoo/etc/&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Mount proc, sys, and dev:
&lt;/li&gt;
&lt;/ul&gt;




&lt;pre class="src src-sh"&gt;mount -t proc none /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Chroot!
&lt;/li&gt;
&lt;/ul&gt;




&lt;pre class="src src-sh"&gt;chroot /mnt/gentoo /bin/bash
&lt;span style="color: #8cd0d3;"&gt;source&lt;/span&gt; /etc/profile
&lt;span style="color: #8cd0d3;"&gt;export&lt;/span&gt; &lt;span style="color: #dfaf8f;"&gt;PS1&lt;/span&gt;=&lt;span style="color: #cc9393;"&gt;"(chroot) $PS1"&lt;/span&gt;
&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Unpack portage snapshot:
      &lt;code&gt;mkdir /usr/portage &amp;amp;&amp;amp; emerge-webrsync&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;I set the profile to "hardened/inux/amd64/" using eselect.
&lt;/li&gt;
&lt;li&gt;Set USE flags in make.conf.
&lt;/li&gt;
&lt;li&gt;Emerge the kernel sources: &lt;code&gt;emerge -av gentoo-sources&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;Update portage for good measure &lt;code&gt;emerge -av portage&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;Create an initramfs archive for early userspace:
&lt;/li&gt;
&lt;/ul&gt;




&lt;pre class="src src-sh"&gt;&lt;span style="color: #8cd0d3;"&gt;cd&lt;/span&gt; /usr/portage/sys-apps/busybox
&lt;span style="color: #dfaf8f;"&gt;BUSYBOX_TARGET&lt;/span&gt;=&lt;span style="color: #fa8072;"&gt;`emerge -pvO busybox | grep -o "busybox-[-0-9.r]*"`&lt;/span&gt;
ebuild $&lt;span style="color: #dfaf8f;"&gt;BUSYBOX_TARGET&lt;/span&gt;.ebuild clean
ebuild $&lt;span style="color: #dfaf8f;"&gt;BUSYBOX_TARGET&lt;/span&gt;.ebuild unpack
&lt;span style="color: #8cd0d3;"&gt;cd&lt;/span&gt; /var/tmp/portage/sys-apps/$&lt;span style="color: #dfaf8f;"&gt;BUSYBOX_TARGET&lt;/span&gt;/work/busybox*
make defconfig
sed -i -e &lt;span style="color: #cc9393;"&gt;"s|# CONFIG_STATIC is not set|CONFIG_STATIC=y|"&lt;/span&gt; .config
sed -i -e &lt;span style="color: #cc9393;"&gt;"s|# CONFIG_INSTALL_NO_USR is not set|CONFIG_INSTALL_NO_USR=y|"&lt;/span&gt; .config

make &lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;this failed at first, with output of&lt;/span&gt;
&lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;&amp;gt; Failed: -Wl,--start-group -lcrypt -lm -Wl,--end-group&lt;/span&gt;
&lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;&amp;gt; As a shot in the dark, I ran&lt;/span&gt;
emerge -av app-crypt/ccrypt &lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;and&lt;/span&gt;
revdep-rebuild
&lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;then running&lt;/span&gt;
make &lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;resulted in&lt;/span&gt;
&lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;&amp;gt; Trying libraries: crypt m&lt;/span&gt;
&lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;&amp;gt;  Library crypt is not needed, excluding it&lt;/span&gt;
&lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;&amp;gt;   Library m is need, can't exclude it (yet)&lt;/span&gt;
&lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;But it built :)&lt;/span&gt;

make busybox.links
mkdir /build_initramfs
./applets/install.sh /build_initramfs --symlinks
&lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;used links to download http://waku.info/uploads/misc/crypt_guide/init to /build_initramfs&lt;/span&gt;
&lt;span style="color: #8cd0d3;"&gt;cd&lt;/span&gt; ./build_initramfs
chmod 755 init
mkdir {proc,sys,new-root,etc,dev}
mknod --mode=0660 ./dev/null c 1 3 &lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;note the dot in ./dev/null&lt;/span&gt;
mknod --mode=0600 ./dev/console c 5 1 &lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;note the dot in ./dev/console&lt;/span&gt;
&lt;span style="color: #dfaf8f;"&gt;USE&lt;/span&gt;=&lt;span style="color: #cc9393;"&gt;"static"&lt;/span&gt; emerge -av cryptsetup &lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;I need it to be statically linked for the initramfs&lt;/span&gt;
cp -p &lt;span style="color: #fa8072;"&gt;`which cryptsetup`&lt;/span&gt; /build_initramfs/sbin/
&lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;Then you need to do the equivalent of&lt;/span&gt;
&lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;&amp;gt; cp /path/to/applets /path/to/build_initramfs/etc/ &lt;/span&gt;
&lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;I did this from the original busybox directory, using screen&lt;/span&gt;
sed -i -e &lt;span style="color: #cc9393;"&gt;'s/\/bin\/sh/\/bin\/ash/g'&lt;/span&gt; init &lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;replace /bin/sh with /bin/ash in init&lt;/span&gt;
&lt;span style="color: #7f9f7f;"&gt;# &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;script due to Busybox not including a /bin/sh applet in busybox &amp;gt;= busybox-1.1.3&lt;/span&gt;
find . | cpio --quiet -o -H newc | gzip -9 &amp;gt;/boot/initramfs-gentoo-crypt  
&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Configure kernel as per &lt;a href="http://en.gentoo-wiki.com/wiki/DM-Crypt_with_LUKS#Kernel_Configuration"&gt;http://en.gentoo-wiki.com/wiki/DM-Crypt_with_LUKS#Kernel_Configuration&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;cd /usr/src/linux &amp;amp;&amp;amp; make menuconfig&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Couldn't find the "Initial RAM disk (initramfs/initrd) support" though.
&lt;/li&gt;
&lt;li&gt;Update: the option got moved to the "General Options menu".
&lt;/li&gt;
&lt;li&gt;Update: letting the kernel make initramfs. Gave it "/build&lt;sub&gt;initramfs&lt;/sub&gt;".
&lt;/li&gt;
&lt;/ul&gt;

&lt;/li&gt;
&lt;li&gt;Compiled kernal: &lt;code&gt;make &amp;amp;&amp;amp; make modules_install &amp;amp;&amp;amp; make install&lt;/code&gt; for /usr/src/linux
&lt;/li&gt;
&lt;li&gt;Created /etc/fstab as per &lt;a href="http://en.gentoo-wiki.com/wiki/DM-Crypt_with_LUKS#.2Fetc.2Ffstab"&gt;http://en.gentoo-wiki.com/wiki/DM-Crypt_with_LUKS#.2Fetc.2Ffstab&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Followed steps from 8b to 10 in Gentoo install manual.
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;emerge -av grub&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Created /boot/grub/grub.conf TODO post the file contents
&lt;/li&gt;
&lt;li&gt;Ran &lt;code&gt;grub-install /dev/sda&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Cleaned-up and rebooted &amp;hellip; and blank prompt. Thinking back on it, I'm pretty sure I didn't mount /dev/sda1 before creating /boot,
      which means grubs config file is actually on /dev/sda3, not /dev/sda1 where it needs to be. Oops.
&lt;/li&gt;
&lt;li&gt;Fixed that. Now I get a grub boot menu.
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Kernel panic - not syncing: No init found. Try passing init= option to kernel.&lt;/code&gt; Great.
&lt;/li&gt;
&lt;li&gt;Did some troubleshooting and found that the init script link on the wiki page was broken.
      Copied the script in its entirety to &lt;a href="#deckeraa.github.com-init"&gt;deckeraa.github.com/init&lt;/a&gt;.
&lt;/li&gt;
&lt;/ul&gt;




&lt;/div&gt;

&lt;/div&gt;

&lt;div id="outline-container-3" class="outline-3"&gt;
&lt;h3 id="sec-3"&gt;Target System&lt;/h3&gt;
&lt;div class="outline-text-3" id="text-3"&gt;

&lt;ul&gt;
&lt;li&gt;Gateway NV5211u
&lt;/li&gt;
&lt;li&gt;AMD Athlon 64 X2 QL-65
&lt;/li&gt;
&lt;/ul&gt;


&lt;/div&gt;

&lt;/div&gt;

&lt;div id="outline-container-4" class="outline-3"&gt;
&lt;h3 id="sec-4"&gt;&lt;/h3&gt;
&lt;div class="outline-text-3" id="text-4"&gt;


&lt;/div&gt;
&lt;/div&gt;
</content></entry><entry><title type="html">Test-First Programming</title><author><name>nil</name></author><link href="http://deckeraa.github.com/ioctopus/2012/12/30_test-first-programming.html"/><updated>2012-12-30T04:33:00Z</updated><published>2012-12-30T04:33:00Z</published><id>ioctopus/2012/12/30_test-first-programming.html</id><category scheme="/tags/lisp.html" term="Lisp" label="Lisp"/><category scheme="/tags/xp.html" term="XP" label="XP"/><category scheme="/tags/unit-tests.html" term="Unit Tests" label="Unit Tests"/><content type="html">&lt;p&gt;
My most recent coding, an arkanoid clone written in Common Lisp, with a sprite library that I'm creating
with an eye towards reusability, called for unit testing.
I know, one should always unit test, but at school I am often forced to use tools e.g. Visual Studio,
that obfuscate the build process and make it time-consuming to set-up unit tests.
&lt;/p&gt;
&lt;p&gt;
Judging from &lt;a href="https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.lisp/5ieAOvLWSTA"&gt;this comp.lang.lisp thread&lt;/a&gt;,
many lispers roll their own unit test frameworks.
In lisp it is fairly trivial (following code taken from the referenced &lt;code&gt;comp.lang.lisp&lt;/code&gt; thread):
&lt;/p&gt;


&lt;pre class="src src-lisp"&gt;(&lt;span style="color: #f0dfaf; font-weight: bold;"&gt;defun&lt;/span&gt; &lt;span style="color: #8cd0d3;"&gt;pick-greater&lt;/span&gt; (x y) y)
(&lt;span style="color: #f0dfaf; font-weight: bold;"&gt;defparameter&lt;/span&gt; &lt;span style="color: #dfaf8f;"&gt;*test-cases*&lt;/span&gt;
  '((+    (3 5)     8)
    (car  ((3 5))   3)
    (cdr  ((3 5))   5)
    (cons (3 5)     (3 . 5))
    (/    (6 4)     3/2)
    (cadr ((3 5 7)) 7)
    ))
(remove-if #'(&lt;span style="color: #f0dfaf; font-weight: bold;"&gt;lambda&lt;/span&gt; (fn+args+res)
               (equal (caddr fn+args+res)
                      (apply (car fn+args+res) (cadr fn+args+res))))
 *test-cases*)
&lt;/pre&gt;

&lt;p&gt;
The last s-expression returns &lt;code&gt;((CDR ((3 5)) 5) (CADR ((3 5 7)) 7))&lt;/code&gt; when evaluated,
showing which tests failed.
Honestly, when I saw this, I was pretty impressed.
A rudimentary, yet functional, testing framework in &lt;b&gt;4 lines&lt;/b&gt; of code.
Lisp continues to impress me.
&lt;/p&gt;
&lt;p&gt;
Peter Seibel has a &lt;a href="http://www.gigamonkeys.com/book/practical-building-a-unit-test-framework.html"&gt;chapter&lt;/a&gt; in Practical Common Lisp devoted to creating a unit-testing library.
He demonstrates proper use of macros (the lisp kind, unrelated to the C kind).
&lt;/p&gt;
&lt;p&gt;
I wanted something a bit more feature-full, yet still simple, so I took a look around
at the available libraries. &lt;a href="https://github.com/OdonataResearchLLC/lisp-unit/wiki"&gt;lisp-unit&lt;/a&gt; fits the bill.
There is another page I referenced &lt;a href="http://www.cs.northwestern.edu/academics/courses/325/readings/lisp-unit.html#overview"&gt;here&lt;/a&gt;. 
The big takeaway from that page was the use of &lt;code&gt;(use-package :lisp-unit)&lt;/code&gt;
at the start.
I loaded the package using quicklisp: &lt;code&gt;(ql:quickload :lisp-unit)&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
The main point of this post has surprisingly, against the best advice from writers of prose, not been introduced yet.
The &lt;a href="http://www.cs.northwestern.edu/academics/courses/325/readings/lisp-unit.html#overview"&gt;second page&lt;/a&gt; had a link to &lt;a href="http://www.extremeprogramming.org/rules/testfirst.html"&gt;this&lt;/a&gt; "Xtreme" Programming article.
While I agreed with most of the first portion, especially how writing unit test &lt;i&gt;before&lt;/i&gt; code forces the requirements to be fully specified,
I disagreed later on, mostly with the last paragraph:
&lt;/p&gt;



&lt;pre class="src src-sh"&gt;There is a rhythm to developing software unit test first. 
You create one test to define some small aspect of the problem at hand. 
Then you create the simplest code that will make that test pass. 
Then you create a second test. 
Now you add to the code you just created to make this new test pass, but no more! 
Not until you have yet a third test. 
You continue until there is nothing left to test. 
The coffee maker problem shows an example written&lt;span style="color: #f0dfaf; font-weight: bold;"&gt; in&lt;/span&gt; Java.

The code you will create is simple and concise, implementing only the features you wanted. 
Other developers can see how to use this new code by browsing the tests. 
Input whose results are undefined will be conspicuously absent from the test suite. 
&lt;/pre&gt;


&lt;p&gt;
So they are basically saying that all my funtions should be discrete, the domain of which consists entirely of points for
which there are test cases.
No! This is &lt;b&gt;not&lt;/b&gt; the understanding that other people using your code will have.
They will assume that your functions will work for all values of the input types specified.
For example, I would expect, say, a function that determined if a point in a rectangle, to work given any point and any rectangle.
Or at the very least, any point and any rectangle with a positive (non-zero) area.
This is orthogonally opposed to the test-spec driven function being promoted in the article.
&lt;/p&gt;
&lt;p&gt;
Oh, but we can go further.
I can trivially follow the above advice by hard-wiring in output to match the test spec.
Think of it like a function defined by a set of ordered pairs, (&lt;i&gt;input&lt;/i&gt; &lt;i&gt;output&lt;/i&gt;).
Hopefully everyone can easily concieve of the folly of this sort of philosophy.
&lt;/p&gt;
&lt;p&gt;
This concludes Rant #269.4, entitled "Test Specs do not constitute a function definition."
&lt;/p&gt;
</content></entry><entry><title type="html">Lisp with SDL Notes</title><author><name>nil</name></author><link href="http://deckeraa.github.com/ioctopus/2012/12/22_lisp-with-sdl-notes.html"/><updated>2012-12-22T17:14:00Z</updated><published>2012-12-22T17:14:00Z</published><id>ioctopus/2012/12/22_lisp-with-sdl-notes.html</id><category scheme="/tags/lisp.html" term="Lisp" label="Lisp"/><category scheme="/tags/sdl.html" term="SDL" label="SDL"/><category scheme="/tags/repl.html" term="REPL" label="REPL"/><content type="html">&lt;div id="outline-container-1" class="outline-3"&gt;
&lt;h3 id="sec-1"&gt;Installing LispBuilder&lt;/h3&gt;
&lt;div class="outline-text-3" id="text-1"&gt;

&lt;p&gt;Run the following in your lisp interpreter (for me it's SBCL)
&lt;/p&gt;


&lt;pre class="src src-lisp"&gt;(asdf-install:install &lt;span style="color: #8cd0d3;"&gt;:cffi&lt;/span&gt;)
&lt;/pre&gt;


&lt;p&gt;
That command stops and asks a lot about not reading the GPG key and also needs to re-initialize the central registry for
every new package. No big deal though, both are offered as restarts.
&lt;/p&gt;
&lt;p&gt;
Next, check-out lispbuilder.
&lt;/p&gt;


&lt;pre class="src src-sh"&gt;svn checkout http://lispbuilder.googlecode.com/svn/trunk/ lispbuilder-read-only
&lt;/pre&gt;


&lt;p&gt;
Put the following in ~/.sbclrc. You will have to change the paths to match where you checked out lispbuilder to.
&lt;/p&gt;


&lt;pre class="src src-lisp"&gt;(pushnew &lt;span style="color: #cc9393;"&gt;"~/src/lispbuilder-read-only/lispbuilder-sdl/"&lt;/span&gt; asdf:*central-registry* &lt;span style="color: #8cd0d3;"&gt;:test&lt;/span&gt; #'equal)
(pushnew &lt;span style="color: #cc9393;"&gt;"~/src/lispbuilder-read-only/lispbuilder-sdl-mixer/"&lt;/span&gt; asdf:*central-registry* &lt;span style="color: #8cd0d3;"&gt;:test&lt;/span&gt; #'equal)

(asdf:oos 'asdf:load-op 'lispbuilder-sdl)
(asdf:oos 'asdf:load-op 'lispbuilder-sdl-examples)
&lt;/pre&gt;


&lt;p&gt;
Running &lt;code&gt;(lispbuilder-sdl-examples:mandelbrot)&lt;/code&gt; yields a window drawing a mandelbrot, so it must have
installed.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="https://code.google.com/p/lispbuilder/wiki/UsingLispbuilderSDL"&gt;There is a really good user manual&lt;/a&gt; with examples and line-by-line explanations.
&lt;/p&gt;
&lt;/div&gt;

&lt;/div&gt;

&lt;div id="outline-container-2" class="outline-3"&gt;
&lt;h3 id="sec-2"&gt;Using the REPL&lt;/h3&gt;
&lt;div class="outline-text-3" id="text-2"&gt;

&lt;p&gt;A primary inspiration trying out lisp with emacs/slime is &lt;a href="http://youtu.be/PUv66718DII"&gt;Bret Victor's talk&lt;/a&gt; on interactive programming.
My distaste for the compile-test-modify cycle grew last semester when I had to compile C++ using Visual Studio &amp;hellip; over a network.
12-second compile times were the norm. That and a bug in VS 2010 kept auto-complete from working in the Windows forms mode, 
combined with a stunning lack of quality documentation for the C++ Forms libraries turned the projects into an agonizingly slow
guess-and-check "development" process.
Anyhow, back to lisp.
&lt;/p&gt;
&lt;p&gt;
I loaded the following code from the wiki and stated executing it:
&lt;/p&gt;


&lt;pre class="src src-lisp"&gt;(&lt;span style="color: #f0dfaf; font-weight: bold;"&gt;defparameter&lt;/span&gt; &lt;span style="color: #dfaf8f;"&gt;*random-color*&lt;/span&gt; sdl:*blue*)
(&lt;span style="color: #f0dfaf; font-weight: bold;"&gt;defun&lt;/span&gt; &lt;span style="color: #8cd0d3;"&gt;mouse-rect-2d&lt;/span&gt; ()
  (&lt;span style="color: #f0dfaf; font-weight: bold;"&gt;sdl:with-init&lt;/span&gt; ()
    (sdl:window 200 200 &lt;span style="color: #8cd0d3;"&gt;:title-caption&lt;/span&gt; &lt;span style="color: #cc9393;"&gt;"REPL without a cause"&lt;/span&gt;)
    (setf (sdl:frame-rate) 60)

    (&lt;span style="color: #f0dfaf; font-weight: bold;"&gt;sdl:with-events&lt;/span&gt; ()
      (&lt;span style="color: #8cd0d3;"&gt;:quit-event&lt;/span&gt; () t)
      (&lt;span style="color: #8cd0d3;"&gt;:key-down-event&lt;/span&gt; ()
       (sdl:push-quit-event))
      (&lt;span style="color: #8cd0d3;"&gt;:idle&lt;/span&gt; ()
       &lt;span style="color: #7f9f7f;"&gt;;; &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;Change the color of the box if the left mouse button is depressed&lt;/span&gt;
       (&lt;span style="color: #f0dfaf; font-weight: bold;"&gt;when&lt;/span&gt; (sdl:mouse-left-p))
&lt;span style="color: #7f9f7f;"&gt;;;         &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;(setf *random-color* (sdl:color :r (random 255) :g (random 255) :b (random 255))))&lt;/span&gt;

       &lt;span style="color: #7f9f7f;"&gt;;; &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;Clear the display each game loop&lt;/span&gt;
       (sdl:clear-display sdl:*black*)

       &lt;span style="color: #7f9f7f;"&gt;;; &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;Draw the box having a center at the mouse x/y coordinates.&lt;/span&gt;
       (sdl:draw-box (sdl:rectangle-from-midpoint-* (sdl:mouse-x) (sdl:mouse-y) 20 20)
                     &lt;span style="color: #8cd0d3;"&gt;:color&lt;/span&gt; *random-color*)

       &lt;span style="color: #7f9f7f;"&gt;;; &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;Redraw the display&lt;/span&gt;
       (sdl:update-display)))))
&lt;/pre&gt;


&lt;p&gt;
There is a screenshot here &lt;a href="./images/basic_sdl_with_repl.jpg"&gt;&lt;img src="./images/basic\_sdl\_with\_repl.jpg" alt="basic\_sdl\_with\_repl.jpg"/&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Then I changed &lt;code&gt;sdl:*blue*&lt;/code&gt; to &lt;code&gt;sdl:*red*&lt;/code&gt;, pressed C-c C-c, and boom! the color changed. Nice.
&lt;/p&gt;
&lt;p&gt;
Okay, so a global variable can be changed on the fly. Big deal. Any debugger can do that.
What about redefining a function, recompiling, and executing on the fly?
To test this out, I wrote the function &lt;code&gt;(defun my_clear () (sdl:clear-display sdl:*red*))&lt;/code&gt;.
I then replaced &lt;code&gt;(sdl:clear-display sdl:*black*)&lt;/code&gt; with &lt;code&gt;(my_clear)&lt;/code&gt; in the main event loop.
Then, once I ran it, I could change the color inside of &lt;code&gt;my_clear&lt;/code&gt;, redefine the function with C-c C-c,
and have the already-running process change accordingly. This is powerful.
&lt;/p&gt;
&lt;p&gt;
There is a tip &lt;a href="https://code.google.com/p/lispbuilder/wiki/PortableInteractiveDevelopment"&gt;here&lt;/a&gt; on the lispbuilder wiki with a tip about keeping the repl available when 
running a single-threaded lisp/sdl program. 
I haven't needed this yet.
&lt;/p&gt;&lt;/div&gt;
&lt;/div&gt;
</content></entry><entry><title type="html">Getting SLIME working on Gentoo</title><author><name>nil</name></author><link href="http://deckeraa.github.com/ioctopus/2012/12/21_getting-slime-working-on-gentoo.html"/><updated>2012-12-21T20:54:00Z</updated><published>2012-12-21T20:54:00Z</published><id>ioctopus/2012/12/21_getting-slime-working-on-gentoo.html</id><category scheme="/tags/slime.html" term="SLIME" label="SLIME"/><category scheme="/tags/lisp.html" term="Lisp" label="Lisp"/><category scheme="/tags/emacs.html" term="Emacs" label="Emacs"/><category scheme="/tags/repl.html" term="REPL" label="REPL"/><category scheme="/tags/gentoo.html" term="Gentoo" label="Gentoo"/><content type="html">&lt;p&gt;
  I wanted to get &lt;a href="http://common-lisp.net/project/slime/"&gt;SLIME&lt;/a&gt; working so that I could efficiently code lisp, which is my next learning endeavour.
  This turned out to be much more difficult than I imagined.
  I've decided to document the steps I took to connect SLIME to a running SBCL (my lisp implementation) on Gentoo.
  Although outdated, the video on &lt;a href="http://www.common-lisp.net/project/slime/"&gt;this&lt;/a&gt; page (&lt;a href="http://common-lisp.net/project/movies/movies/slime.mov"&gt;direct link&lt;/a&gt;) is a good overview of SLIME.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Emerge &lt;a href="http://www.cliki.net/sbcl"&gt;SBCL&lt;/a&gt;



&lt;pre class="src src-sh"&gt;sudo emerge -av sbcl
&lt;/pre&gt;


&lt;/li&gt;
&lt;li&gt;Check out the fairly-stable version of SLIME
    I put all the software I build from source by myself in ~/src, but you could put it anywhere.



&lt;pre class="src src-sh"&gt;&lt;span style="color: #8cd0d3;"&gt;cd&lt;/span&gt; ./src
cvs -d :pserver:anonymous@common-lisp.net:/project/slime/cvsroot checkout -r FAIRLY-STABLE slime
&lt;/pre&gt;


&lt;/li&gt;
&lt;li&gt;Create a "systems" folder for SBCL to find SLIME's &lt;code&gt;swank.asd&lt;/code&gt; file in.



&lt;pre class="src src-sh"&gt;&lt;span style="color: #8cd0d3;"&gt;cd&lt;/span&gt; ./lisp
mkdir systems
&lt;span style="color: #8cd0d3;"&gt;cd&lt;/span&gt; ./systems
ln -s ~/src/slime/swank.asd
&lt;/pre&gt;


&lt;/li&gt;
&lt;li&gt;Add the following to ~/.sbclrc (create the file if it doesn't exist).



&lt;pre class="src src-sh"&gt;(require :asdf)
(push &lt;span style="color: #cc9393;"&gt;"/home/[user]/lisp/systems/"&lt;/span&gt; asdf:*central-registry*)
&lt;/pre&gt;


&lt;/li&gt;
&lt;li&gt;Add the following to ~/.emacs



&lt;pre class="src src-lisp"&gt;(setq inferior-lisp-program &lt;span style="color: #cc9393;"&gt;"/usr/bin/sbcl"&lt;/span&gt; &lt;span style="color: #7f9f7f;"&gt;; &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;your Lisp system&lt;/span&gt;
    slime-startup-animation t) 
(add-to-list 'load-path &lt;span style="color: #cc9393;"&gt;"~/src/slime"&lt;/span&gt;) &lt;span style="color: #7f9f7f;"&gt;; &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;your SLIME directory&lt;/span&gt;
(&lt;span style="color: #f0dfaf; font-weight: bold;"&gt;require&lt;/span&gt; '&lt;span style="color: #bfebbf;"&gt;slime&lt;/span&gt;)
(slime-setup '(slime-fancy slime-asdf))
&lt;/pre&gt;


&lt;/li&gt;
&lt;li&gt;Start up SBCL, and run the following:



&lt;pre class="src src-lisp"&gt;(asdf:oos 'asdf:load-op &lt;span style="color: #8cd0d3;"&gt;:swank&lt;/span&gt;)
(swank:create-server)
&lt;/pre&gt;


&lt;/li&gt;
&lt;li&gt;Now running 'M-x slime-connect' in Emacs should start a REPL that looks something like



&lt;pre class="src src-lisp"&gt;&lt;span style="color: #7f9f7f;"&gt;; &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;SLIME 2011-11-03&lt;/span&gt;
CL-USER&amp;gt; 
&lt;/pre&gt;

&lt;p&gt;
    Expect to be prompted for host name and port; accept the defaults.
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


</content></entry><entry><title type="html">Math Homework Template using Org-mode/LaTeX</title><author><name>nil</name></author><link href="http://deckeraa.github.com/ioctopus/2012/12/19_math-homework-template-using-org-modelatex.html"/><updated>2012-12-19T16:46:00Z</updated><published>2012-12-19T16:46:00Z</published><id>ioctopus/2012/12/19_math-homework-template-using-org-modelatex.html</id><category scheme="/tags/org-mode.html" term="Org Mode" label="Org Mode"/><category scheme="/tags/homework.html" term="Homework" label="Homework"/><category scheme="/tags/math.html" term="Math" label="Math"/><content type="html">&lt;p&gt;
This past semester for my Discrete Math class I decided to type up most of my assignments.
I needed an easy way to format the page and organize problems, so I used &lt;a href="http://orgmode.org/"&gt;Org-mode&lt;/a&gt;, which comes built-in with Emacs.
Then I also added a few lines to each file to get the page layout to work well with what I was trying to do.
I've decided to post an org file with some representative problems so that others can employ the same sort of set-up.
&lt;/p&gt;
&lt;p&gt;
To use this template, simply open the org file in Emacs. It should then start org-mode automatically.
To export to a pdf, type C-c C-e to open the export buffer. Then type 'd' to export to pdf via LaTeX.
Emacs will probably then ask if you want to allow BIND values; type 'yes' once and it won't ask again.
&lt;/p&gt;


&lt;a href="./hw_sample_template.org"&gt;org file&lt;/a&gt;

&lt;p&gt;
&lt;a href="./hw_sample_template.pdf"&gt;pdf output&lt;/a&gt;
&lt;/p&gt;</content></entry><entry><title type="html">State Squid and I/Octopus</title><author><name>nil</name></author><link href="http://deckeraa.github.com/ioctopus/2012/09/13_state-squid-and-ioctopus.html"/><updated>2012-09-13T15:23:00Z</updated><published>2012-09-13T15:23:00Z</published><id>ioctopus/2012/09/13_state-squid-and-ioctopus.html</id><category scheme="/tags/functional-programming.html" term="Functional Programming" label="Functional Programming"/><category scheme="/tags/uml.html" term="UML" label="UML"/><category scheme="/tags/state.html" term="State" label="State"/><content type="html">&lt;p&gt;
   &lt;img src="./images/state-squid-uml.png"  alt="./images/state-squid-uml.png" /&gt;
&lt;/p&gt;

&lt;p class="verse"&gt;
Once upon a time, in a land so fine,&lt;br/&gt;
where analysis happened all the time,&lt;br/&gt;
lived a happy little class family.&lt;br/&gt;
Yes, it was in the land of OO, where lines&lt;br/&gt;
and boxes and use case scenarios&lt;br/&gt;
frolic playfully in the street and all&lt;br/&gt;
the happy classes live together with&lt;br/&gt;
minimal coupling and high cohesion.&lt;br/&gt;
&lt;br/&gt;
Twas dusk one night at the coding class house,&lt;br/&gt;
where lived a family whose existence was due&lt;br/&gt;
to an assignment from a programming class.&lt;br/&gt;
Twas the RPN family of who&lt;br/&gt;
members were Susie Stack, sibling Quentin Queue,&lt;br/&gt;
RPNEval and Driver Class too.&lt;br/&gt;
Daddy Driver Class tucked them into bed&lt;br/&gt;
along with the state from their objects, he said.&lt;br/&gt;
Scary stories of high coupling he read,&lt;br/&gt;
but he assured them that all those bugs were long dead.&lt;br/&gt;
&lt;br/&gt;
Those bugs were before we had UML,&lt;br/&gt;
now we have OO and life is just swell.&lt;br/&gt;
With those words he bid them all a good night,&lt;br/&gt;
he bid them sweet dreams and turned off the light.&lt;br/&gt;
He thought to himself, as he went to his room,&lt;br/&gt;
Their state is encapsulated, all that&lt;br/&gt;
talk from functional programmers, of doom&lt;br/&gt;
and despair from state was lame and old hat.&lt;br/&gt;
He had it all taken care of, put in each class,&lt;br/&gt;
the lambda and OO schools had reached an impasse.&lt;br/&gt;
&lt;br/&gt;
But all through the night he had quite a fright,&lt;br/&gt;
unspeakable horrors passing through his mind's sight.&lt;br/&gt;
He dreamt of a kraken, no, just a huge squid,&lt;br/&gt;
that just stood and stared as he wondered what it did.&lt;br/&gt;
It's cavernous eyes peered deep into his soul,&lt;br/&gt;
this must be a prank, just a functional troll.&lt;br/&gt;
But there its singular figure remained,&lt;br/&gt;
on the UML of his soul it was firmly engrained.&lt;br/&gt;
Its tentacles were just lines, his face a mere shape,&lt;br/&gt;
But the diagram of his family it threatened to reshape.&lt;br/&gt;
&lt;br/&gt;
Rebellion against father, but just in his dream,&lt;br/&gt;
for RPNEval was drinking from the forbidden stream.&lt;br/&gt;
That ethereal stream that is called I/O,&lt;br/&gt;
whose state at runtime, nobody knows.&lt;br/&gt;
The paternal class cursed in frustration, no fear he could quell,&lt;br/&gt;
he thought he had had it all planned out so well.&lt;br/&gt;
But his model was naive, much too simple to be good,&lt;br/&gt;
he hadn't modeled the state of the &lt;i&gt;whole&lt;/i&gt; program like he should.&lt;br/&gt;
But now complexity, and inter-dependency too,&lt;br/&gt;
clamored around his program, like the monkeys at a zoo.&lt;br/&gt;
&lt;br/&gt;
Now there is a moral to this story, something just for you,&lt;br/&gt;
model &lt;i&gt;all&lt;/i&gt; the state in your program, or this too you will rue.&lt;br/&gt;
&lt;/p&gt;




</content></entry><entry><title type="html">Style Guidelines Revisited</title><author><name>nil</name></author><link href="http://deckeraa.github.com/ioctopus/2012/09/10_style-guidelines-revisited.html"/><updated>2012-09-10T03:25:00Z</updated><published>2012-09-10T03:25:00Z</published><id>ioctopus/2012/09/10_style-guidelines-revisited.html</id><category scheme="/tags/style.html" term="Style" label="Style"/><content type="html">&lt;p&gt;
  Coding style guidelines are great.
  They keep code looking consistent and can improve readability.
  As a result, many quality, widely-accepted coding styles exist
  &amp;ndash; K&amp;amp;R, GNU, Whitesmith are a few examples &amp;ndash; and are already
  loaded into IDE's such as Emacs or NetBeans. 
  This makes me wonder: Why do certain universities insist
  on creating their own style guidelines?
&lt;/p&gt;
&lt;p&gt;
  I was recently reading through the "programming ground rules" of a course
  at a certain university, which will remain unnamed.
  For context, this course uses C++ as the main language for the course.
  While many of the guidelines are good ideas and common sense,
  I came across some interesting rules.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;"Use the // comment style."
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;  "Only use the &lt;code&gt;/* */&lt;/code&gt; comment style to
  temporarily comment out chunks of your program for testing and debugging." 
    I must admit I was a little confused by this one.
    Comments compile out.
    Additionally, all the editors I know of 
    are able to deal with both commenting styles.
    I just can't see how this affects readability.
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;i&gt;Every&lt;/i&gt; function needs a doc banner.
    Even getters, setters, and the following function.



&lt;pre class="src src-cpp"&gt;&lt;span style="color: #f0dfaf; font-weight: bold;"&gt;class&lt;/span&gt; &lt;span style="color: #8cd0d3;"&gt;Stack&lt;/span&gt;
{
&lt;span style="color: #f0dfaf; font-weight: bold;"&gt;public&lt;/span&gt;:
   &lt;span style="color: #7f9f7f;"&gt;// &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;-----------------------------------&lt;/span&gt;
   &lt;span style="color: #7f9f7f;"&gt;// &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;Returns true if the stack is empty.&lt;/span&gt;
   &lt;span style="color: #7f9f7f;"&gt;// &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;-----------------------------------&lt;/span&gt;
   &lt;span style="color: #8cd0d3;"&gt;bool&lt;/span&gt; &lt;span style="color: #8cd0d3;"&gt;isEmpty&lt;/span&gt;() { &lt;span style="color: #7f9f7f;"&gt;/* &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;. . . */&lt;/span&gt; }
   &lt;span style="color: #7f9f7f;"&gt;// &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;...&lt;/span&gt;
};
&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;
  Thankfully, a few rules from previous courses were noticeably absent.
  Arguments no longer must be labeled in a 
  comment block as "in, out, or in/out".
  Do I have a problem with such labels?
  No, but when they are unnecessary they tend to &lt;i&gt;reduce&lt;/i&gt; the readability
  of the comments. 
  Take the following two functions for example.
  Yes, the function is deliberately simplified, but how much of your C++ code consists
  of such functions?
&lt;/p&gt;



&lt;pre class="src src-cpp"&gt;&lt;span style="color: #7f9f7f;"&gt;// &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;isOutOfBounds( int x, int y)&lt;/span&gt;
&lt;span style="color: #7f9f7f;"&gt;// &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;Returns true if the coordinates are in bounds.&lt;/span&gt;
&lt;span style="color: #7f9f7f;"&gt;// &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;Returns false otherwise.&lt;/span&gt;
&lt;span style="color: #7f9f7f;"&gt;// &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;ARGS: IN, IN&lt;/span&gt;
&lt;span style="color: #8cd0d3;"&gt;bool&lt;/span&gt; &lt;span style="color: #8cd0d3;"&gt;isOutOfBounds&lt;/span&gt;( &lt;span style="color: #8cd0d3;"&gt;int&lt;/span&gt; &lt;span style="color: #dfaf8f;"&gt;x&lt;/span&gt;, &lt;span style="color: #8cd0d3;"&gt;int&lt;/span&gt; &lt;span style="color: #dfaf8f;"&gt;y&lt;/span&gt; );
&lt;/pre&gt;


&lt;p&gt;
  or
&lt;/p&gt;



&lt;pre class="src src-cpp"&gt;&lt;span style="color: #7f9f7f;"&gt;// &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;Checks to see if the given coordinates are in bounds of the window.&lt;/span&gt;
&lt;span style="color: #7f9f7f;"&gt;// &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;Note that x and y are expressed in screen coordinates.&lt;/span&gt;
&lt;span style="color: #8cd0d3;"&gt;bool&lt;/span&gt; &lt;span style="color: #8cd0d3;"&gt;isOutOfBounds&lt;/span&gt;( &lt;span style="color: #8cd0d3;"&gt;int&lt;/span&gt; &lt;span style="color: #dfaf8f;"&gt;x&lt;/span&gt;, &lt;span style="color: #8cd0d3;"&gt;int&lt;/span&gt; &lt;span style="color: #dfaf8f;"&gt;y&lt;/span&gt; );
&lt;/pre&gt;


&lt;p&gt;
  The second declaration, though not rigidly formatted, provides far more
  information than the first.
  Also note the use of upper-case to convey that 1960's COBOL kind of feeling.
&lt;/p&gt;
&lt;p&gt;
  Also gone from the rules is the "30-line function limit", where points
  would be taken off for any function longer than 30 lines.
  While written to encourage modular design, the rule also encourages
  "code golf", where esoteric programming constructs and obscure evaluation
  rules help to fit the function inside of the line limit.
&lt;/p&gt;
&lt;p&gt;
  Take the following code snippets. Do they do the same thing?
&lt;/p&gt;



&lt;pre class="src src-cpp"&gt;&lt;span style="color: #8cd0d3;"&gt;void&lt;/span&gt; &lt;span style="color: #8cd0d3;"&gt;push&lt;/span&gt;( &lt;span style="color: #8cd0d3;"&gt;float&lt;/span&gt; &lt;span style="color: #dfaf8f;"&gt;obj_to_push&lt;/span&gt; )
{
   stack_data[current_index++] = obj_to_push;
}

&lt;span style="color: #7f9f7f;"&gt;// &lt;/span&gt;&lt;span style="color: #7f9f7f;"&gt;or&lt;/span&gt;

&lt;span style="color: #8cd0d3;"&gt;void&lt;/span&gt; &lt;span style="color: #8cd0d3;"&gt;push&lt;/span&gt;( &lt;span style="color: #8cd0d3;"&gt;float&lt;/span&gt; &lt;span style="color: #dfaf8f;"&gt;obj_to_push&lt;/span&gt; )
{
   current_index++;
   stack_data[current_index] = obj_to_push;
}

&lt;/pre&gt;


&lt;p&gt;  
  They do not do the same thing.
  The post-fix increment operator is evaluated &lt;i&gt;after&lt;/i&gt; the assignment operator.
  Encouraging code golf with line limits encourages language constructs that,
  while clever and loved by language lawyers, 
  are a pitfall for the creation of bugs.
&lt;/p&gt;
&lt;p&gt;
  Why then are programs graded according to criteria that at times are
  only tangentially related to good programming and at other times are
  actually opposed to proper coding?
  It would seem that the university system feels a need to conform
  programming into the standardized testing/grading paradigm currently
  embraced by many educational institutions, but has failed to quantify
  good programming practices.
&lt;/p&gt;
&lt;p&gt;
  How then, do we teach proper coding to students still struggling
  to master even the simplest aspects of programming such as language syntax?
  To be honest, I do not have an answer, and it would be preposterous if I
  purported to be qualified to propose proper pedagogical procedures.
  One thing I have noticed, however, is the inordinate amount of time spent
  learning language-specific constructs ( where the semi-colon goes )
  in courses that advertise themselves
  as being about things such as "data structures".
&lt;/p&gt;
&lt;p&gt;
  Perhaps the way to go is to use a language with little syntax such as
  Scheme.
  Hal Abelson and Gerald Jay Sussman employed such a method in their
  book &lt;a href="http://mitpress.mit.edu/sicp/"&gt;Structure and Interpretation of Computer Programs&lt;/a&gt; and their MIT course
  by the same name ( video lectures can be found &lt;a href="http://archive.org/details/mit_ocw_sicp"&gt;here&lt;/a&gt;).
  Roughly one lecture covered the syntax of Scheme, rather than half of 
  a semester using, say, Java ( as an aside, I would have to posit that
  Java's object reference system cannot be properly understood without
  first understanding the idea of pointers in a language such as C).
&lt;/p&gt;
</content></entry>
</feed>
