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

<channel>
	<title>Cosine Jeremiah and his Musings</title>
	<atom:link href="http://cosine.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://cosine.org</link>
	<description>Life and Ruby and Security</description>
	<lastBuildDate>Thu, 11 Mar 2010 05:28:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Thoughts on Pair Programming</title>
		<link>http://cosine.org/2010/03/10/thoughts-pair-programming/</link>
		<comments>http://cosine.org/2010/03/10/thoughts-pair-programming/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 05:28:36 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://cosine.org/?p=85</guid>
		<description><![CDATA[I have recently been exposed to the first pair programming in my career, and I want to quickly share some thoughts on it.
Honestly, at first I found it a little frustrating.  There I was spending half my time watching someone else implement some stuff, and my brain simultaneously stuck elsewhere solving world hunger while [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently been exposed to the first pair programming in my career, and I want to quickly share some thoughts on it.</p>
<p>Honestly, at first I found it a little frustrating.  There I was spending half my time watching someone else implement some stuff, and my brain simultaneously stuck elsewhere solving world hunger while trying to be &#8220;helpful&#8221; to that other guy with me.  It took a few weeks before the benefits really started dawning on me and also to appreciate the contribution I make when not the guy with the keyboard.  I think many people have recounted much of what is great about pair programming, but the one that I have not heard that really makes me giddy is that <em>your partner prevents you from being lazy</em>.</p>
<p>In particular, I do not mean that your partner prevents you from using things like email as a distraction from getting stuff done (another benefit that others have recounted).  Instead I mean that when you are racing to complete a programming task and you encounter a decision to: (1) hack it and jam something in place quickly, or (2) Doing It Right but burn up extra time doing so.  Without a partner you typically choose #1 while lamenting that you did not choose #2.  You add to your technical debt and bad karma and you are ridden with guilt; it is a double whammy!</p>
<p>With a partner, what happens instead is that you suggest #1 to your partner, but regardless of whether your partner can discern whether #1 is Doing It Right he can see your hesitation and draws your thoughts out of you about #2.  Before you know it, he is excited to see you through to Doing It Right!  Your heart leaps in joy and later, when you go home for the day, you smile just a little more when your sweetheart asks, &#8220;how was work today, honey?&#8221; <img src='http://cosine.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2010/03/10/thoughts-pair-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rise of the Mammals</title>
		<link>http://cosine.org/2009/01/06/rise-mammals/</link>
		<comments>http://cosine.org/2009/01/06/rise-mammals/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 20:58:40 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Economy]]></category>

		<guid isPermaLink="false">http://cosine.org/?p=82</guid>
		<description><![CDATA[It is 2009, and it looks like the sky is falling.  Perhaps it is, just a little.  I think it is a good thing.  How can I say that as people are losing their jobs?  It is easy if you look at what will bring the greatest good to the greatest [...]]]></description>
			<content:encoded><![CDATA[<p>It is 2009, and it looks like the sky is falling.  Perhaps it is, just a little.  I think it is a good thing.  How can I say that as people are losing their jobs?  It is easy if you look at what will bring the greatest good to the greatest number of people.  For too long our economy has suffered at the hands of large, lumbering creatures that do not care one whiff about you or anyone else&mdash;cold blooded monsters that would stab you in the back and kick your rotting corpse to the curb the minute it thinks you missed a payment due to its own poor accounting practices.  I call these companies the dinosaurs.  Those that will suffer the most in this down economy are the dinosaurs.</p>
<p>As the dinosaurs continue to fall, the need for the goods and services they have been providing up until now will not disappear.  The people that previously fed the dinosaurs (customers and employees) will have new opportunities to feed another kind of creature that has always been around here and there but will explode in numbers to take care of the things dropped by the dinosaurs.  These creatures are the mammals.</p>
<p>Mammals are good for economies.  Most of them are small, light on their feet, and they are warm-blooded.  They do not create a &#8220;Customer Loyalty&#8221; program to pretend they care; they actually do care, and that care is felt person-to-person in the dealings of business.  Because mammals are typically smaller than dinosaurs, it is easier for them to operate closer to home.  Your money stays local instead of going to Washington or New York.  In the good times when Washington and New York are flush with cash, the dinosaurs are happy to re-invest it everywhere.  As times turn ugly, they will cling onto your cash and your locale will see nothing coming back.  This is why it is so hard to find a loan these days, even if your credit worthiness is really good.</p>
<p>I urge people to not wait for the dinosaurs they feed to collapse, but to invest today in the mammals available in your area.  Your money will be going towards making your local economy more robust and better able to provide new jobs in your area as the dinosaurs continue to release personnel.  Times will be tough for the next year or two, but in the end I want to look back at this time as the time of opportunity&mdash;our time for building a new kind of economy that will take care of us for time eternity.</p>
<p>Let me repeat one thing before I sign off:  invest in your local mammals <em>today</em>.  Feed them now so they will be strong enough to feed you back when you need them.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2009/01/06/rise-mammals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AVLTree 0.1.4 Released</title>
		<link>http://cosine.org/2008/11/16/avltree-014-released/</link>
		<comments>http://cosine.org/2008/11/16/avltree-014-released/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 09:11:35 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[avltree]]></category>

		<guid isPermaLink="false">http://www.cosine.org/?p=79</guid>
		<description><![CDATA[This morning I released AVLTree version 0.1.4.  The difference from version 0.1.3 is an idea from modifications made to the code by the Samhain folks to improve performance.
If you are not familiar with my AVLTree project, it is a C library that implements AVL trees and provides an interface for indexing and iterating over [...]]]></description>
			<content:encoded><![CDATA[<p>This morning I released <a href="http://www.cosine.org/project/AVLTree/">AVLTree</a> version <a href="http://www.cosine.org/project/AVLTree/AVLTree-0.1.4.tar.gz">0.1.4</a>.  The difference from version 0.1.3 is an idea from modifications made to the code by the <a href="http://www.la-samhna.de/">Samhain</a> folks to improve performance.</p>
<p>If you are not familiar with my AVLTree project, it is a C library that implements AVL trees and provides an interface for indexing and iterating over objects.  I like to think of it as my little C answer to the hashes and dictionary objects available in more advanced languages.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2008/11/16/avltree-014-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Templating in Excel</title>
		<link>http://cosine.org/2008/10/10/excel-template/</link>
		<comments>http://cosine.org/2008/10/10/excel-template/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 04:59:15 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Excel]]></category>

		<guid isPermaLink="false">http://www.cosine.org/?p=62</guid>
		<description><![CDATA[I wrote a little spreadsheet template language for Excel VBA (Visual Basic for Applications).  What for?  Say you have a report you create often, and you&#8217;re thinking of making a macro in Excel to help automate its generation.  You want to report on the sales of your widgets from multiple locations, and [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote a little spreadsheet template language for Excel VBA (Visual Basic for Applications).  What for?  Say you have a report you create often, and you&#8217;re thinking of making a macro in Excel to help automate its generation.  You want to report on the sales of your widgets from multiple locations, and you already have a template in mind for how the report should look:</p>
<div id="attachment_63" class="wp-caption alignnone" style="width: 323px"><a href="http://www.cosine.org/wp-content/uploads/2008/10/templatekicker-widget-template.jpg"><img src="http://www.cosine.org/wp-content/uploads/2008/10/templatekicker-widget-template.jpg" alt="Template of Widget Report in Excel" title="templatekicker-widget-template" width="313" height="191" class="size-full wp-image-63" /></a><p class="wp-caption-text">Template of Widget Report in Excel</p></div>
<p>I thought it would be so nice to be able to do this that I wrote the VBA to do it.  I call it TemplateKicker.  To use it, I copy the TemplateKicker module and the TemplateKickerVariables class module into my spreadsheet from <a href="/ex/2008/10/10/TemplateKicker.xls">TemplateKicker.xls</a> (this file also contains the example shown here).  Then I write a macro to insert the values for each location I am reporting on:</p>
<pre>
Public Sub Widget_Report()
    Dim Vars As TemplateKickerVariables
    Dim LocationIDs As Variant
    Dim WidgetSales As Variant
    Dim Index As Integer

    LocationIDs = Array("A-12345", "B-22222", "C-33333", "D-2R2", "E-5555")
    WidgetSales = Array(34, 12, 15, 6, 39)

    Set Vars = New TemplateKickerVariables
    For Index = 1 To 5
        Vars.SetVar "location:" &#038; Index &#038; ".id", LocationIDs(Index - 1)
        Vars.SetVar "location:" &#038; Index &#038; ".widgets.sold", WidgetSales(Index - 1)
    Next Index

    KickWorksheet(ActiveWorkbook, Sheets("Sheet1"), Vars).Name = "Widgets"
End Sub
</pre>
<p>One run of the macro later, and I have a new worksheet with the results:</p>
<div id="attachment_64" class="wp-caption alignnone" style="width: 323px"><a href="http://www.cosine.org/wp-content/uploads/2008/10/templatekicker-widget-report.jpg"><img src="http://www.cosine.org/wp-content/uploads/2008/10/templatekicker-widget-report.jpg" alt="Widget Report after running macro" title="templatekicker-widget-report" width="313" height="231" class="size-full wp-image-64" /></a><p class="wp-caption-text">Widget Report after running macro</p></div>
<p>TemplateKicker also has the following features that I will showcase in upcoming blog posts:</p>
<ul>
<li>Nested ForEach loops</li>
<li>Rows to insert between items being looped over</li>
<li>Generation of named ranges for use in formulas</li>
</ul>
<p>Even with all this, however, TemplateKicker does have some limitations:</p>
<ul>
<li>The template language is somewhat &#8220;fragile&#8221;&mdash;spaces must be exactly placed.</li>
<li>Errors are not reported.  Bad syntax or variable names produce undefined results.</li>
</ul>
<p>Still, I think this is a great start to doing some pretty awesome things in Excel VBA.  I do not know if I will develop it further, but if you find it interesting please let me know!</p>
<p>As a side note, <a href="http://www.cosinewave.com/">CosineWave Technologies Inc.</a> now also offers VBA solutions for business automation now. <img src='http://cosine.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   Please drop me a line if you have need for some tools to automate your workflow when using Microsoft products (or many other products for that matter)!</p>
<p><!-- adman --></p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2008/10/10/excel-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mephisto</title>
		<link>http://cosine.org/2008/08/23/mephisto/</link>
		<comments>http://cosine.org/2008/08/23/mephisto/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 08:18:03 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.cosine.org/?p=50</guid>
		<description><![CDATA[I have spent a lot of hours in the past week working with Mephisto.  Mephisto is a blogging platform with aims of eventually being a full-fledged CMS.  Overall I like it, but I am uncertain if it is a platform I ought to continue working with at this point.
Here are the highlights of [...]]]></description>
			<content:encoded><![CDATA[<p>I have spent a lot of hours in the past week working with <a href="http://www.mephistoblog.com/">Mephisto</a>.  Mephisto is a blogging platform with aims of eventually being a full-fledged CMS.  Overall I like it, but I am uncertain if it is a platform I ought to continue working with at this point.</p>
<p>Here are the highlights of the pros:</p>
<ul>
<li>It is written in <a href="http://www.rubyonrails.org/">Rails</a>, which is a platform I know well and therefore can extend rather easily.</li>
<li>The site can be split into multiple sections, each of which can be its own blog and have its own RSS feed, or which can be a single page.</li>
<li>Themes!  Mephisto can be themed, and it is easy to write new ones using one or more of several template languages.</li>
<li>It allows multiple layouts to allow for different looks for each section of the site.</li>
<li>Articles can be formatted in with Textile, Markdown, or just plain HTML.  I was able to integrate TinyMCE without much trouble as well.</li>
</ul>
<p>But there are also the cons:</p>
<ul>
<li>The current version is 0.8.  That is not quite 1.0, and I wager that the reason it is not at 1.0 is related to the various little bugs that I have found.</li>
<li>Sometimes Mephisto will select the wrong layout for a page and it is difficult to figure out why.  Fortunately, these situations are limited to &#8220;Preview this Post&#8221; and the &#8220;permanent links&#8221; to articles that represent pages that normally do not get linked to.</li>
<li>Mephisto has plugins and themes, but it is difficult to find useful plugins and more than a small number of publicly available themes.</li>
</ul>
<p><!-- adman --></p>
<p>I think Mephisto is a better platform than <a href="http://www.radiantcms.org/">Radiant</a> at this point, and in my opinion it gives Rails a reasonably usable blogging platform.  Before committing more time to it, however, I think I will take a look at the much touted <a href="http://drupal.org/">Drupal</a>.  I have been meaning to take a look at it anyway. <img src='http://cosine.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2008/08/23/mephisto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I Am an Independent Contractor Now</title>
		<link>http://cosine.org/2008/07/11/independent-contractor/</link>
		<comments>http://cosine.org/2008/07/11/independent-contractor/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 14:50:44 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[CosineWave]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2008/07/11/independent-contractor/</guid>
		<description><![CDATA[Yes, that&#8217;s right.  Today is my last day at my present employer.  Two weeks ago I formed my own company, CosineWave Technologies Incorporated, and I will be working for it as a contractor.
Here are the primary services that I offer today:

Unix Security
Security Management
Application Development
Internal Training


Please go to the CosineWave website and drop me [...]]]></description>
			<content:encoded><![CDATA[<p>Yes, that&#8217;s right.  Today is my last day at my present employer.  Two weeks ago I formed my own company, <a href="http://www.cosinewave.com/">CosineWave Technologies Incorporated</a>, and I will be working for it as a contractor.</p>
<p>Here are the primary services that I offer today:</p>
<ul>
<li>Unix Security</li>
<li>Security Management</li>
<li>Application Development</li>
<li>Internal Training</li>
</ul>
<p><!-- adman --></p>
<p>Please go to the <a href="http://www.cosinewave.com/">CosineWave website</a> and drop me a line if you are interested in hiring me!</p>
<p>And to all my friends and colleagues that have helped me get here:  thank you very much!</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2008/07/11/independent-contractor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chisec 16 and C</title>
		<link>http://cosine.org/2008/03/03/chisec-16/</link>
		<comments>http://cosine.org/2008/03/03/chisec-16/#comments</comments>
		<pubDate>Mon, 03 Mar 2008 12:00:44 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[chisec]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2008/03/03/chisec-16/</guid>
		<description><![CDATA[Thursday, February 28 was a long day for me, but in a good way.  It started almost like any normal morning, except I had to wake up 20 minutes early to handle the morning care and feeding of my animals.  That task is one my wife usually performs, but she had to run [...]]]></description>
			<content:encoded><![CDATA[<p>Thursday, February 28 was a long day for me, but in a good way.  It started almost like any normal morning, except I had to wake up 20 minutes early to handle the morning care and feeding of my animals.  That task is one my wife usually performs, but she had to run out extra early for her own work.</p>
<p>My morning at work went relatively fast.  I had very few scheduled tasks because of meetings dotting my schedule and my vice president&#8217;s group was all going out to play <a href="http://www.whirlyball.com/">Whirlyball</a> for the afternoon.  Additionally, due to my company&#8217;s sales team scoring a big contract, the company was serving free Lou Malnati&#8217;s pizza for lunch.</p>
<p>Whirlyball was probably the most fun of the day, but it is what happened afterward that is the most interesting.  I arrived at Houlihan&#8217;s at 6:30, preparing to socialize with other security professionals at Chisec 16 starting at 7:00.  I did not wait long.  I had hardly sat down when Maniac showed up, always full of interesting conversation and even an <a href="http://en.wikipedia.org/wiki/ASUS_Eee_PC">Asus Eee PC</a>, something I had never seen before.  It was not long before the room was full of other security professionals from all over the Chicago area.</p>
<p>With 20&ndash;30 people in a room, you do not get to talk to everyone.  I primarily spoke with a couple guys from the University of Chicago and some consultants from no less than three different firms.  It was <a href="http://www.matasano.com/log/thomas-ptacek/">Thomas Ptacek</a> that gave me the biggest surprise of the evening.</p>
<p>Tom told me that it is getting increasingly rare to find computer people that know C.  I had never thought about it, but I could see why this would be a problem.  I have been using C since 1994, and I simply consider it a staple of my computer abilities.  It is like part of the foundation.  It is through C that I know how a shell interacts with an operating system, or how any program interacts with other components of the system.  My knowledge of C is how I learned about the general structure of a running process in memory, and from that I understand how things like buffer overflow attacks actually work.  It is through C that I even know how Ruby handles its garbage collection, at a low level.  In regard to modern computer architecture, if you do not know C, then I would be incredulous if you told me that you <em>really</em> understand computer architecture.  I am not sure that knowledge of C++ can really convey the same understanding, except that someone could do so by paying close attention to the subset of C++ that is C.</p>
<p>I wonder&#8230; do you know C?  If I were to compile a list of important languages that all computer programmers should learn, C would be high on the list, if not the top language.  Certainly there are other important languages out there that expand ones mind around advanced programming topics, such as Ruby, Lisp, and ML, but down at the linker level C is the language that all other languages communicate with the operating system or the hardware&mdash;application binary interfaces (ABIs) are designed around how C compilers generate object files.  <em>It is </em>that<em> important.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2008/03/03/chisec-16/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenID and Testing</title>
		<link>http://cosine.org/2008/03/01/openid-testing/</link>
		<comments>http://cosine.org/2008/03/01/openid-testing/#comments</comments>
		<pubDate>Sat, 01 Mar 2008 07:20:44 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Website]]></category>
		<category><![CDATA[OpenID]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2008/03/01/openid-testing/</guid>
		<description><![CDATA[Earlier this month I was playing with a WordPress plugin that would add OpenID support for the blog here.  My intention is to make it easier to signup for commenting, while still not opening the flood gates of anonymous posting to avoid spam (I am not a big fan of CAPTCHAs).  Unfortunately, the [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier this month I was playing with a WordPress plugin that would add OpenID support for the blog here.  My intention is to make it easier to signup for commenting, while still not opening the flood gates of anonymous posting to avoid spam (I am not a big fan of CAPTCHAs).  Unfortunately, the hosting environment is still on PHP4 and the plugin requires PHP5.  I could probably fix the code to work with PHP4, but I have better things to do for now so the OpenID support will wait a bit.</p>
<p>Also, I want to share <a href="http://www.onestepback.org/index.cgi/Tech/Programming/DarthTest.red">this bit</a> posted on <a href="http://www.onestepback.org/">Jim Weirich&#8217;s blog</a>.  He said it is on his wall, and I liked it so much that it is also on mine now, too.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2008/03/01/openid-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Security Missing in Oracle Best Practices</title>
		<link>http://cosine.org/2008/02/12/security-missing-oracle-practices/</link>
		<comments>http://cosine.org/2008/02/12/security-missing-oracle-practices/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 16:12:44 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[soa]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2008/02/12/security-missing-oracle-practices/</guid>
		<description><![CDATA[Recently Oracle released a 272 page document outlining some recommended best practices when implementing SOA with its suite:
http://download.oracle.com/technology/tech/soa/soa_best_practices_1013x_drop3.pdf
I was going to review it for its security best practices and WS-Security recommendations&#8230; but there are not any.  Take that to mean what you will.
]]></description>
			<content:encoded><![CDATA[<p>Recently Oracle released a 272 page document outlining some recommended best practices when implementing SOA with its suite:</p>
<p><a href="http://download.oracle.com/technology/tech/soa/soa_best_practices_1013x_drop3.pdf">http://download.oracle.com/technology/tech/soa/soa_best_practices_1013x_drop3.pdf</a></p>
<p>I was going to review it for its security best practices and WS-Security recommendations&#8230; but there are not any.  Take that to mean what you will.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2008/02/12/security-missing-oracle-practices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unleash the Arc!</title>
		<link>http://cosine.org/2008/02/06/unleash-arc/</link>
		<comments>http://cosine.org/2008/02/06/unleash-arc/#comments</comments>
		<pubDate>Wed, 06 Feb 2008 07:08:53 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[arc]]></category>
		<category><![CDATA[paul graham]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2008/02/06/unleash-arc/</guid>
		<description><![CDATA[I just found out that Paul Graham has unleashed Arc upon the world after years and years of teasing us.  This is exciting, particularly for what will happen to Ruby.  All of the nifty features that make Arc awesome will be extracted into a few Ruby gems in the next 2&#8211;4 weeks, and [...]]]></description>
			<content:encoded><![CDATA[<p>I just found out that <a href="http://www.paulgraham.com/">Paul Graham</a> <a href="http://www.paulgraham.com/arc0.html">has unleashed</a> <a href="http://arclanguage.org/">Arc</a> upon the world after <a href="http://www.paulgraham.com/arcll1.html">years</a> and <a href="http://www.paulgraham.com/ilc03.html">years</a> of teasing us.  This is exciting, particularly for what will happen to Ruby.  All of the nifty features that make Arc awesome will be extracted into a few Ruby gems in the next 2&ndash;4 weeks, and everything that Paul put into Arc will be available for Ruby.</p>
<p>But Cosine, you might say, Paul developed Arc so that the <em>language</em> would have nifty breakthrough features unlike any ever seen before to make code more concise!  Without the base language support for these features, Ruby will not beat Arc at its own game!</p>
<p>Well, someone has already <a href="http://arc-challenge.heroku.com/">written a library</a> (it should be reformatted properly into one, anyway) in response to the <a href="http://www.paulgraham.com/arcchallenge.html">Arc Challenge</a> that implements part of the Arc standard library, exposing for Ruby any language features in Arc that Paul was trying to showcase in the Arc Challenge.</p>
<p>Paul, please give us a challenge that shows a fundamental language design difference rather than displaying a gap in the presently available libraries.  I know you are a smart cookie, so you must be hiding something up that sleeve.</p>
<p>Actually, I can think of one advantage Arc has over Ruby.  Arc is Lisp whereas Ruby is not, and following from that Arc has macros while Ruby has ugly workarounds to fake macro writing.  But everyone already knows that.  Hmmm, maybe what we really want to do is have all our Ruby gems and Rails made available for Arc?  Arc on Rails, anyone?  I think that would be pleasant.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2008/02/06/unleash-arc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Looking at Ruby on Rails</title>
		<link>http://cosine.org/2008/02/05/ruby-rails/</link>
		<comments>http://cosine.org/2008/02/05/ruby-rails/#comments</comments>
		<pubDate>Tue, 05 Feb 2008 20:42:20 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2008/02/05/ruby-rails/</guid>
		<description><![CDATA[Are you stuck in a J2EE framework that leaves you feeling like this?
&#60;statement&#62;&#60;personal&#62;&#60;timeframe&#62;&#60;someday&#62;&#60;subject&#62;I&#60;/subject&#62;&#60;action how="at"&#62;look&#60;/action&#62;&#60;object&#62;&#60;name&#62;ruby&#60;/name&#62;&#60;modifier type="on"&#62;rails&#60;/modifier&#62;&#60;/object&#62;&#60;/someday&#62;&#60;/timeframe&#62;&#60;/personal&#62;&#60;/statement&#62;
Why wait?  Get out there and get started with Rails today!  
]]></description>
			<content:encoded><![CDATA[<p>Are you stuck in a J2EE framework that leaves you feeling like this?</p>
<p><code>&lt;statement&gt;&lt;personal&gt;&lt;timeframe&gt;&lt;someday&gt;&lt;subject&gt;I&lt;/subject&gt;&lt;action how="at"&gt;look&lt;/action&gt;&lt;object&gt;&lt;name&gt;ruby&lt;/name&gt;&lt;modifier type="on"&gt;rails&lt;/modifier&gt;&lt;/object&gt;&lt;/someday&gt;&lt;/timeframe&gt;&lt;/personal&gt;&lt;/statement&gt;</code></p>
<p>Why wait?  Get out there and <a href="http://www.rubyonrails.org/">get started with Rails</a> today! <img src='http://cosine.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2008/02/05/ruby-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Where Have I Been?</title>
		<link>http://cosine.org/2007/11/14/where/</link>
		<comments>http://cosine.org/2007/11/14/where/#comments</comments>
		<pubDate>Wed, 14 Nov 2007 20:06:42 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Website]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/11/14/where/</guid>
		<description><![CDATA[If you started reading this blog recently, you might wonder where I have been for the last two weeks.  I apologize for my absence.  I have been extremely busy working with a wonderful team on a new project.  I have dedicated all of my spare time to that, so I have not [...]]]></description>
			<content:encoded><![CDATA[<p>If you started reading this blog recently, you might wonder where I have been for the last two weeks.  I apologize for my absence.  I have been extremely busy working with a <a href="http://www.whygosolo.com/aboutus.html">wonderful team</a> on a new project.  I have dedicated all of my spare time to that, so I have not had time to write articles here.  However, I promise I will be back in business with new posts in another week or two!  Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/11/14/where/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WS-Security versus SOA over SSL</title>
		<link>http://cosine.org/2007/10/25/wss-vs-ssl/</link>
		<comments>http://cosine.org/2007/10/25/wss-vs-ssl/#comments</comments>
		<pubDate>Thu, 25 Oct 2007 12:00:22 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/10/25/wss-vs-ssl/</guid>
		<description><![CDATA[I have had some thoughts recently about the security of SOA (Service Oriented Architecture).  When using SOA, the services are often made available using SOAP (Simple Object Access Protocol) messages communicated using HTTP.  Naturally, it is important to keep data secure as it is transmitted from requester to servicer and vice versa.  [...]]]></description>
			<content:encoded><![CDATA[<p>I have had some thoughts recently about the security of <a href="http://en.wikipedia.org/wiki/Service-oriented_architecture">SOA</a> (Service Oriented Architecture).  When using SOA, the services are often made available using <a href="http://en.wikipedia.org/wiki/SOAP">SOAP</a> (Simple Object Access Protocol) messages communicated using HTTP.  Naturally, it is important to keep data secure as it is transmitted from requester to servicer and vice versa.  Should one use SSL to secure SOAP?  Or should we recommend WS-Security, a standard means of transforming a SOAP message to add confidentiality and integrity to the message, instead&mdash;if we limit it to one or the other, that is.  Let us do a quick comparison of each solution:</p>
<p><b>1. SSL is ubiquitous and most everyone knows how to use it, whereas WS-Security is largely an &#8220;unknown&#8221; to most organizations.</b></p>
<p><b>2. Both SSL and WS-Security are easy to &#8220;drop in&#8221; to a typical web service architecture, though SSL is somewhat easier due to the previous observation.</b></p>
<p><!-- adman --></p>
<p>Both SSL and WS-Security have programs or libraries that make adding them to an existing web service a reasonable task.  </p>
<p>Adding SSL to a web service can be as easy as putting <a href="http://stunnel.mirt.net/">Stunnel</a> or other SSL termination software in front of the service.  However, to integrate SSL&#8217;s authentication features one would need to have the results of the SSL handshake passed into the application somehow.  More often a server ends up using weaker credentials, such as username and password, inside the SSL connection to establish the identity of its users.</p>
<p>With WS-Security, implementation can be done by adding a few calls to an appropriate WS-Security library, such as <a href="http://ws.apache.org/wss4j/">WSS4J</a> (Java) or <a href="http://rubyforge.org/projects/wss4r">WSS4R</a> (Ruby).</p>
<p><b>3. SSL provides security for an entire connection; WS-Security secures each message one by one.</b></p>
<p>If an application keeps a connection open to make multiple requests of a web service, then SSL would provide better performance than WS-Security.  Exactly how much better may depend on your servers&#8217; average load.  The difference in computation is due to SSL using mostly symmetric key encryption after the initial handshake at the start of the connection, whereas WS-Security needs to perform asymmetric key encryption on each message (one computation for handling encryption and one computation for handling the signature).  Symmetric key encryption is a lot faster than asymmetric key encryption, and while both technologies switch to using symmetric key encryption as fast as possible to provide the best performance, WS-Security is unable to avoid those asymmetric key computations on every message.</p>
<p>On the other hand, since security is applied on a message-by-message basis with WS-Security, an application is not susceptible to possible channel hijacking or HTTP splitting attacks that could occur with SSL.  If either of these things were to happen when WS-Security was in use then its security features would still protect the message and the data.</p>
<p><b>4. SSL requires an immediate communication with the endpoint to securely transmit data; WS-Security can protect a message that is queued up or stored on intermediate servers without additional concerns.</b></p>
<p>With SSL, the SOAP messages themselves remain unencrypted but are transmitted through a secure tunnel (the SSL link).  If that message ends up being stored on a disk (queued) prior to use, then it is unprotected from being read or tampered with by anyone who can obtain access to that disk.  If you think this is unlikely then you should know that attackers are often able to leverage poorly configured web, FTP, Citrix, remote desktop, and Windows file sharing servers to access disk.  This is one of several reasons that encryption of data at rest has become more important recently, and &#8220;at rest&#8221; refers to any time data hits a disk or a tape, not just when it resides within a database.</p>
<p>On the other hand, WS-Security imposes its protections upon the message itself, so if the message were to be copied by an adversary he could not read it.  If the attacker could find a way to get write access to the disk containing the WS-Security protected message waiting in queue, any attempt to tamper with the message is detected by WS-Security&#8217;s integrity protection features.</p>
<p><b>Comparison Summary</b></p>
<p>SSL (pros):</p>
<ol>
<li>SSL is ubiquitous&mdash;it is easy to find people with experience using it.</li>
<li>Easy to &#8220;drop in&#8221; to a typical web service architecture.</li>
<li>Provides encryption for an entire connection.</li>
<li>Client may authenticate the server during SSL handshake.</li>
<li>Server may authenticate the client during SSL handshake.</li>
</ol>
<p>SSL (cons):</p>
<ol>
<li>Connections must be active to transport data and responses.  In other words, the endpoints must have a direct channel to each other.</li>
<li>Once authenticated with the SSL handshake, any data transported on the connection is trusted.  This might leave a channel open that can be hijacked and used in similar fashion to a cross-site request forgery attack.</li>
<li>Data is vulnerable to capture and tampering if left unencrypted on a disk by queuing software; extra precautions may be necessary to protect it.</li>
</ol>
<p>WS-Security (pros):</p>
<ol>
<li>Easy to &#8220;drop in&#8221; to a typical web service architecture.</li>
<li>Provides encryption for a single message.</li>
<li>Client may be assured the server is the message recipient by virtue of the public key used to encrypt the message.  Likewise, the server is assured that the client is the recipient of the reply by virtue of the public key used to encrypt the reply.</li>
<li>Server may be assured the client is the message sender by virtue of the public key used to decrypt the message signature.  Likewise, the client is assured that the server is the sender of the reply by virtue of the public key used to decrypt the reply signature.</li>
<li>Messages may be time limited to prevent expired messages from being processed.</li>
<li>Messages are innately protected if left on disk and queued during transmission to the consumer.</li>
</ol>
<p>WS-Security (cons):</p>
<ol>
<li>WS-Security is not ubiquitous.  You will likely need to train your development staff how to use it.</li>
<li>Each individual message and its response requires processor expensive asymmetric key encryption to occur even if a communications channel is maintained.  This is negligible on small loads, but systems with hundreds, thousands, or yet more messages per second may become loaded.</li>
</ol>
<p>After reviewing the differences I suggest that WS-Security should be the preferred choice of most enterprises.  Do note that I suggest you do both SSL and WS-Security (for defense in depth and to provide some security by obscurity against those that would sniff your packets), but if you were to limit it to one or the other then I would prefer WS-Security.  The issue that convinced me was the security of messages left in queue on disks.  This situation happens rather frequently (swap files, anyone?) and is often done unbeknown to the original application architect as the system grows and the message delivery mechanism is changed.  WS-Security simply provides security from end to end without worrying that every step of the way is secured appropriately as well; SSL only promises security between the endpoints of the SSL tunnel.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/10/25/wss-vs-ssl/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Multi-User Screen</title>
		<link>http://cosine.org/2007/10/23/multiuser-screen/</link>
		<comments>http://cosine.org/2007/10/23/multiuser-screen/#comments</comments>
		<pubDate>Tue, 23 Oct 2007 13:27:10 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/10/23/multiuser-screen/</guid>
		<description><![CDATA[Have you ever been jamming away on a Unix host&#8217;s command line and wish you could share your session with others?  Perhaps you could do so to show someone else something you found on the system?  Maybe you want that someone to type a password for you?  Or perhaps you need to [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever been jamming away on a Unix host&#8217;s command line and wish you could share your session with others?  Perhaps you could do so to show someone else something you found on the system?  Maybe you want that someone to type a password for you?  Or perhaps you need to share the experience of going through some prompts and how to answer them?  Recently there have been a myriad of technologies that can share windows and even whole desktops, but those programs are not always handy or appropriate.</p>
<p>Fortunately, the <a href="http://www.gnu.org/software/screen/">GNU Screen</a> program can share that command line session of yours with other users with accounts on the same Unix host.  Screen comes with a multi-user mode that allows them to connect to it.  Each user can be granted permissions to each window to view, interact, or issue other commands to Screen.  Here is a .screenrc file I have used to implement three groups of users: read-only users that can view all windows, read-write users that can also type in all windows, and an administrative user (the account that runs screen in my case) that retains all permissions within Screen.</p>
<pre>
multiuser on

aclchg READERS +r-wx &#34;#&#34;
aclchg READERS -rwx &#34;?&#34;
aclchg READERS +x colon,license,windows,next,prev,select,other,detach,suspend,redisplay,lastmsg,windowlist,help,stuff

aclchg WRITERS +rw-x &#34;#&#34;
aclchg WRITERS -rwx &#34;?&#34;
aclchg WRITERS +x colon,license,windows,next,prev,select,other,detach,suspend,redisplay,lastmsg,windowlist,help,stuff

aclgrp watcher1 READERS
aclgrp watcher2 READERS
aclgrp trusted1 WRITERS
aclgrp trusted2 WRITERS

aclumask &#34;*&#34;-rwx cosine+rwx READERS+r-wx WRITERS+rw-x &#34;?&#34;-rwx &#34;??&#34;-rwx
</pre>
<p><!-- adman --></p>
<p>In this example, the administrative user is <code>cosine</code>.  The read-only users <code>watcher1</code> and <code>watcher2</code> are in the <code>READERS</code> group.  Likewise, the read-write users <code>trusted1</code> and <code>trusted2</code> are in the <code>WRITERS</code> group.  Users are placed in groups with the <code>aclgrp</code> command.</p>
<p>The other commands to set this up can be understood with a careful read of Screen&#8217;s man page.  The short of it is that for <code>READERS</code> we give read access but no write or execute (<code>+r-wx</code>) for all windows (<code>#</code>), then we do not allow any access (<code>-rwx</code>) to any Screen commands.  Next we do enable access (<code>+x</code>) to a reasonable set of Screen commands necessary for navigation and comfortable viewing&mdash;otherwise Screen would not allow the user to change windows, exit his session, or a few other commands Screen users take for granted.  The <code>aclumask</code> command provides a similar level of coverage to windows that are yet to be created.  The <code>WRITERS</code> group is given similar permissions, except users in that group are also allowed to write (i.e. type things) into all windows.</p>
<p>If we wanted to create an <code>ADMINS</code> group that had full control of screen (able to create new windows and execute arbitrary screen commands), we could do so by replacing the <code>aclumask</code> command with another that replaces the mention of the <code>cosine</code> user with an <code>ADMINS</code> group, adding a pair of <code>aclchg</code> commands to grant this group access to everything, and then adding some users to the group:</p>
<pre>
aclchg ADMINS +rwx &#34;#&#34;
aclchg ADMINS +rwx &#34;?&#34;

aclgrp cosine ADMINS
aclgrp admin1 ADMINS
aclgrp admin2 ADMINS

aclumask &#34;*&#34;-rwx ADMINS+rwx READERS+r-wx WRITERS+rw-x &#34;?&#34;-rwx &#34;??&#34;-rwx
</pre>
<p>If you begin experimenting with these &#8220;acl&#8221; commands in Screen, do make sure you test your configurations before using them.  Screen did not make these commands particularly user-friendly, and they do not always behave how you might think they do.  They feel like they were bolted onto the program as an afterthought, and if you have been reading my blog for very long <a href="http://www.cosine.org/2007/09/14/bolting-security/">you know how I feel about <em>that</em></a>.  I would not use Screen&#8217;s multi-user mode for any high-security application.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/10/23/multiuser-screen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>irb: Learning Ruby Quick</title>
		<link>http://cosine.org/2007/10/17/irb-learning-ruby-quick/</link>
		<comments>http://cosine.org/2007/10/17/irb-learning-ruby-quick/#comments</comments>
		<pubDate>Wed, 17 Oct 2007 12:00:44 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/10/17/irb-learning-ruby-quick/</guid>
		<description><![CDATA[In my previous post I introduced the idea of using irb as a desktop calculator.  If you are new to Ruby, however, using irb can have the side effect of teaching you Ruby.  Everything you type in irb is a Ruby statement.  The response you get from irb is the value Ruby [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous post I introduced the idea of using irb as a desktop calculator.  If you are new to Ruby, however, using irb can have the side effect of teaching you Ruby.  Everything you type in irb is a Ruby statement.  The response you get from irb is the value Ruby returns from the evaluation of the statement you type.  You can use this to try things out in Ruby to see how it behaves.  Here is an example exploring how a Ruby Array handles some given Range objects as arguments to the &#8220;indexing&#8221; method <code>[]</code>:</p>
<pre>
irb(main):001:0&gt; <b>a = [1, 2, 3, 4, 5]</b>
=&gt; [1, 2, 3, 4, 5]
irb(main):002:0&gt; <b>a[1..-1]</b>
=&gt; [2, 3, 4, 5]
irb(main):003:0&gt; <b>a[1..a.size]</b>
=&gt; [2, 3, 4, 5]
irb(main):004:0&gt; <b>a[1..&#46;-1]</b>
=&gt; [2, 3, 4]
</pre>
<p>Now we just saw first hand some of how we manipulate Arrays in Ruby.  But what if we are curious about what else we can do with an Array?  It would be really nice if we could quickly get a list of methods available for my Array.  Oh, but we can!  Every Ruby object has a <code>methods</code> method that returns an Array populated with the names all the messages it responds to.</p>
<pre>
irb(main):005:0&gt; <b>a.methods</b>
=&gt; [&#34;select&#34;, &#34;[]=&#34;, &#34;inspect&#34;, &#34;compact&#34;, &#34;&lt;&lt;&#34;, &#34;&amp;&#34;, &#34;clone&#34;,
&#34;method&#34;, <em>..&#46; (over 100 other methods) ..&#46;</em>, &#34;unshift&#34;,
&#34;sort_by&#34;, &#34;to_yaml_properties&#34;, &#34;fill&#34;, &#34;max&#34;, &#34;is_a?&#34;,
&#34;uniq!&#34;, &#34;[]&#34;]
</pre>
<p>Oh, that is a lot of methods!  My version of Ruby/irb returned 128 methods for the object, and they are hard to read all mixed up like that.  Good thing we can sort them, too:</p>
<pre>
irb(main):006:0&gt; <b>a.methods.sort</b>
=&gt; [&#34;&amp;&#34;, &#34;*&#34;, &#34;+&#34;, &#34;-&#34;, &#34;&lt;&lt;&#34;, &#34;&lt;=&gt;&#34;, &#34;==&#34;, &#34;===&#34;, <em>..&#46; (over 100
other methods) ..&#46;</em>, &#34;uniq&#34;, &#34;uniq!&#34;, &#34;unshift&#34;, &#34;untaint&#34;,
&#34;values_at&#34;, &#34;yaml_initialize&#34;, &#34;zip&#34;, &#34;|&#34;]
</pre>
<p><!-- adman --></p>
<p>By scanning the methods available to an object you can get an idea of what you can do with it before you even look at proper documentation (which you want to have handy, too).  Using the <code>methods</code> method from irb is also a fast way to recall the name of a method if you forget it and your text editor or IDE does not help you figure it out.  I sometimes just try out methods unknown to me just to see what happens, and then I check the documentation shortly thereafter to ensure I understand it.</p>
<p>The most important aspect of irb that enabled me to learn Ruby and keep up with changes in the language was the ability to vet out short bits of code before putting them into a program.  For example, if I need to ensure a complicated regular expression will match what I want it to, I can do the initial testing in irb.  Then those tests done in irb that supply confidence that the regular expression is correct are copied into the unit tests.  Here is a simple example to illustrate the idea:</p>
<pre>
irb(main):007:0&gt; <b>&#39;foo bar baz&#39; =~ /&#92;&lt;bar&#92;&gt;/</b>
=&gt; nil
</pre>
<p>Oops!  I expected an Integer result, which would denote there was a match.  However, I forgot I was working in Ruby instead of an old version of grep, and the notations denoting a word boundary in regular expressions are different between the two.  It is easily fixed:</p>
<pre>
irb(main):008:0&gt; <b>&#39;foo bar baz&#39; =~ /&#92;bbar&#92;b/</b>
=&gt; 4
</pre>
<p>One other trick I employ in irb is to get a list of currently loaded classes, at least as defined at the top level (i.e. a class within a class or module, like <code>Net::HTTP</code>, will not show up, but <code>Net</code> will and then one could drill down from there).  This can be done because every class can be identified by a constant value, and a list of these constants can be obtained from the <code>Object</code> class using the <code>constants</code> class method:</p>
<pre>
irb(main):009:0&gt; <b>Object.constants.sort</b>
=&gt; [&#34;ARGF&#34;, &#34;ARGV&#34;, &#34;ArgumentError&#34;, &#34;Array&#34;, &#34;BasicSocket&#34;,
&#34;Bignum&#34;, &#34;Binding&#34;, &#34;Buffering&#34;, <em>..&#46; (over 100 other entries)
..&#46;</em>, &#34;UNIXserver&#34;, &#34;UNIXsocket&#34;, &#34;URI&#34;, &#34;UnboundMethod&#34;,
&#34;VERSION&#34;, &#34;YAML&#34;, &#34;ZeroDivisionError&#34;, &#34;Zlib&#34;]
</pre>
<p>Not all of the entries returned are classes (e.g. <code>ARGF</code> and <code>ARGV</code>), but it does not hurt to know about the other defined constants, too.</p>
<p>With irb at my disposal learning Ruby was a snap, and it was very fun.  If you have not yet had the pleasure of learning Ruby then perhaps irb can make your journey more fun, too.  Let me know if you try it out!</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/10/17/irb-learning-ruby-quick/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>irb: The New Desktop Calculator</title>
		<link>http://cosine.org/2007/10/11/irb-desktop-calculator/</link>
		<comments>http://cosine.org/2007/10/11/irb-desktop-calculator/#comments</comments>
		<pubDate>Thu, 11 Oct 2007 12:00:17 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/10/11/irb-desktop-calculator/</guid>
		<description><![CDATA[One of the things I love about Ruby is that it comes with irb.  It is short for Interactive Ruby, and it is a command line tool to interact with an instance of the Ruby interpreter.  To start it up just run irb from the command line (Interactive Ruby is a menu option [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things I love about Ruby is that it comes with irb.  It is short for <strong>I</strong>nteractive <strong>R</strong>u<strong>b</strong>y, and it is a command line tool to interact with an instance of the Ruby interpreter.  To start it up just run <code>irb</code> from the command line (Interactive Ruby is a menu option in the most common Windows Ruby package).  One of my most frequent uses of irb is as a calculator:</p>
<pre>
irb(main):001:0&gt; <b>1465 + 1723</b>
=&gt; 3188
</pre>
<p>Simple addition is not too exciting, but that&#8217;s just the beginning.  When Ruby is at your fingertips, the sky is the limit (limited by your imagination, of course).  You can sum up a whole list of numbers quickly:</p>
<pre>
irb(main):002:0&gt; <b>[1, 2, 3, 4, 5, 6].inject(0) { |x, y| x + y }</b>
=&gt; 21
</pre>
<p>Use variables to store values or add to them:</p>
<pre>
irb(main):003:0&gt; <b>a = 515</b>
=&gt; 515
irb(main):004:0&gt; <b>a += 23</b>
=&gt; 538
</pre>
<p>Or perhaps you need a special function to crunch your numbers today?  Just define it, possibly as an instance method for the Array or Integer classes, and then have a blast with it:</p>
<pre>
irb(main):005:0&gt; <b>class Array</b>
irb(main):006:1&gt;   <b>def sum_of_squares</b>
irb(main):007:2&gt;     <b>inject(0) { |s, x| s + x * x }</b>
irb(main):008:2&gt;   <b>end</b>
irb(main):009:1&gt; <b>end</b>
=&gt; nil
irb(main):010:0&gt; <b>[1, 2, 3, 4, 5, 6].sum_of_squares</b>
=&gt; 91
</pre>
<p>Take advantage of some mathematical constants!  They are available, too, using the Ruby constants shown below.</p>
<pre>
irb(main):011:0&gt; <b>Math::PI</b>
=&gt; 3.14159265358979
irb(main):012:0&gt; <b>Math::E</b>
=&gt; 2.71828182845905
</pre>
<p>Finally, there is just one thing to note.  If you are doing division and want a decimal point in your results then you need to make sure you are using at least one floating point precision number in your statement (otherwise the result is an integer dividend):</p>
<pre>
irb(main):013:0&gt; <b>2352.0 / 17</b>
=&gt; 138.352941176471
irb(main):014:0&gt; <b>2352 / 17</b>
=&gt; 138
</pre>
<p><!-- adman --></p>
<p>Using irb as a desktop calculator is really just scratching the surface of what one can do, but I think it is a rather cool application of it.  If you have never used irb, or even Ruby, go ahead and give it a try!  I hope you find it just as useful as I do.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/10/11/irb-desktop-calculator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internal Machine Security</title>
		<link>http://cosine.org/2007/10/06/internal-machine-security/</link>
		<comments>http://cosine.org/2007/10/06/internal-machine-security/#comments</comments>
		<pubDate>Sun, 07 Oct 2007 00:09:18 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/10/06/internal-machine-security/</guid>
		<description><![CDATA[Sorry for the delay in posts here, but I have been sick the past week, and getting back into my regular routine has been challenging since.  Also, rather that just post random musings of the day like many other blogs, I try to provide useful original content based on my experience.
However, today I will [...]]]></description>
			<content:encoded><![CDATA[<p>Sorry for the delay in posts here, but I have been sick the past week, and getting back into my regular routine has been challenging since.  Also, rather that just post random musings of the day like many other blogs, I try to provide useful original content based on my experience.</p>
<p>However, today I will do as many other blogs do and point to some interesting content from elsewhere that I recently came across.  There are two recent articles by <a href="http://www.root.org/~nate/">Nate Lawson</a> that are very interesting; you may find them <a href="http://rdist.root.org/2007/09/27/pc-memory-architecture-overview/">here</a> and <a href="http://rdist.root.org/2007/09/28/protecting-memory-from-dma/">here</a>, and I suggest you read them.  They discuss the security of internal system components&mdash;hardware security.</p>
<p>As security practitioners continue to struggle with networks and applications, we still have the same issues affecting components of our hardware.  The exact same issues, in fact:  authorization, authentication, and security versus performance to name a few.  I smile at the thought of a conference room somewhere in the bowels of Intel or AMD where engineers and managers discuss threat models and risk equations and make decisions on what to implement and how to implement PC hardware features based on costs and risks in a manner no different than how a web application&#8217;s security is discussed at a software company.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/10/06/internal-machine-security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Answers to the Redirection Puzzle</title>
		<link>http://cosine.org/2007/09/27/answers-redirection-puzzle/</link>
		<comments>http://cosine.org/2007/09/27/answers-redirection-puzzle/#comments</comments>
		<pubDate>Thu, 27 Sep 2007 12:00:14 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/09/27/answers-redirection-puzzle/</guid>
		<description><![CDATA[This post discusses answers to the Redirection Puzzle.  Do not read on if you do not want to see or discuss answers (yet).  

My solution is not very complicated or long at 57 characters (9 of them spaces, 6 of them optional), but it is less than the ideal of the shell providing [...]]]></description>
			<content:encoded><![CDATA[<p>This post discusses answers to the <a href="/2007/09/27/redirection-puzzle">Redirection Puzzle</a>.  Do not read on if you do not want to see or discuss answers (yet). <img src='http://cosine.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-37"></span><!-- adman --></p>
<p>My solution is not very complicated or long at 57 characters (9 of them spaces, 6 of them optional), but it is less than the ideal of the shell providing better support for pipe redirection.  I would like to see <a href="http://zsh.sourceforge.net/">zsh</a> incorporate the Plan 9 redirection syntax to make this easier.  I would have suggested it to them, but I feel like such a suggestion should have a patch attached. <img src='http://cosine.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Anyway, go ahead and post answers or potential solutions to the puzzle below in the comments.  If you do not want to register for an account you can email your answers or questions to <b>cosine</b>&nbsp;at&nbsp;<b>cosine</b>&nbsp;dot&nbsp;<b>org</b>.  I will post noteworthy comments sent to my email below.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/09/27/answers-redirection-puzzle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redirection Puzzle</title>
		<link>http://cosine.org/2007/09/27/redirection-puzzle/</link>
		<comments>http://cosine.org/2007/09/27/redirection-puzzle/#comments</comments>
		<pubDate>Thu, 27 Sep 2007 11:59:37 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/09/27/redirection-puzzle/</guid>
		<description><![CDATA[Today&#8217;s entry here at cosine.org is a little Unix puzzle for everyone to work.  I came up with this seven years ago when I was first reading about the Plan 9 shell, rc.  Plan 9&#8217;s shell has a nifty little syntax for connecting a pipe from an arbitrary file descriptor of one process [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s entry here at <a href="/">cosine.org</a> is a little Unix puzzle for everyone to work.  I came up with this seven years ago when I was first reading about the Plan 9 shell, rc.  Plan 9&#8217;s shell has a nifty little syntax for connecting a pipe from an arbitrary file descriptor of one process to any file descriptor of another process when they are invoked at the command line together.  Using this syntax we can pipe standard error to a different process than we pipe standard output to:</p>
<pre>
; <b>{puzzle2000 | tee out.log} |[2] tee err.log</b>
This is standard output
This is standard error
; <b>cat out.log</b>
This is standard output
; <b>cat err.log</b>
This is standard error
</pre>
<p><!-- adman --></p>
<p>As seen above, the <a href="/ex/2007/09/27/redirection-test/puzzle2000">puzzle2000</a> script outputs two lines.  It outputs &#8220;<code>This is standard output</code>&#8221; to standard output and &#8220;<code>This is standard error</code>&#8221; to standard error.  The challenge is repeating the above Plan 9 shell functionality using the Bourne shell instead.  Back in 2000 it took me about two weeks of throwing ideas around to work out a solution.  This is non-trivial because the Bourne shell&#8217;s pipe syntax can only connect the pipe from standard output of the first process to standard input of the second.  So can you figure out how to extend this functionality?  Give it a try!</p>
<p><strong>Please do not post answers or spoilers in the comments of this post.</strong>  I have set up an <a href="/2007/09/27/answers-redirection-puzzle">additional post</a> to discuss possible answers and to avoid spoiling it for those that want to work out the challenge.  I have also provided a little bit of information about my own solution there, and will eventually update that post with the solution itself.  Feel free to post your answers in the comments there (do not read them if you do not want to be spoiled!).  Also, if you do not want to register for an account you can email your answers or questions to <b>cosine</b>&nbsp;at&nbsp;<b>cosine</b>&nbsp;dot&nbsp;<b>org</b>, and I will post them if they are good (that is, if they would contribute to a positive discussion) even if they are not correct.</p>
<p>Note that I will delete comments below if they are a spoiler or if they discuss possible answers, so please limit the discussion here to clarification about what the challenge is or other general comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/09/27/redirection-puzzle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mind the Arguments</title>
		<link>http://cosine.org/2007/09/22/mind-arguments/</link>
		<comments>http://cosine.org/2007/09/22/mind-arguments/#comments</comments>
		<pubDate>Sat, 22 Sep 2007 12:00:27 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/09/22/mind-arguments/</guid>
		<description><![CDATA[How command line arguments are processed in Unix is important to know when scripting.  That which should be a simple script is often troublesome to debug if the arguments to some of the commands get mangled unexpectedly.
To help understand what ends up being sent as command line arguments to a command, we can use [...]]]></description>
			<content:encoded><![CDATA[<p>How command line arguments are processed in Unix is important to know when scripting.  That which should be a simple script is often troublesome to debug if the arguments to some of the commands get mangled unexpectedly.</p>
<p>To help understand what ends up being sent as command line arguments to a command, we can use a little Perl script I wrote to see exactly what the arguments are and how they were broken up by the shell.  It does nothing more that print each argument out on a line of its own, but just that little service is enough to learn the finer points of command line argument processing.  I called this script <strong>sargs</strong>, and here is the code:</p>
<pre>
#!/usr/bin/env perl
foreach $arg (@ARGV) {
  print(&#34;$arg&#92;n&#34;);
}
</pre>
<p>Let us take a look at it in action in a few different circumstances.  First with three arguments:</p>
<pre>
% <b>sargs 1 2 3</b>
1
2
3
</pre>
<p>Now with the same three arguments combined as one:</p>
<pre>
% <b>sargs &#39;1 2 3&#39;</b>
1 2 3
</pre>
<p>We all know that quoting an argument allows us to put spaces and other special characters within them, and with sargs we can see it first hand.  With one more simple example, let us see shell wildcards in action:</p>
<pre>
% <b>sargs /*</b>
/bin
/boot
/cdrom
/dev
/etc
/home
/lib
/lost+found
/mnt
/opt
/proc
/root
/sbin
/service
/sys
/tmp
/usr
/var
</pre>
<p>This is the evidence that it is the shell, not the command, that interprets the wildcard asterisk (*) and expands it into many arguments, one for each file with a matching name.</p>
<p>Now let us use sargs for something more useful.  What happens to command line arguments in a command issued with SSH?  SSH mangles the command line when used to issue shell commands.  How?  We can see exactly how.  Three arguments apart are seen as normal:</p>
<pre>
% <b>ssh localhost sargs 1 2 3</b>
1
2
3
</pre>
<p>But if I group them inside quotes, something does not work right:</p>
<pre>
% <b>ssh localhost sargs &#39;1 2 3&#39;</b>
1
2
3
</pre>
<p>Those were supposed to be one argument!  What SSH does is it joins all the command line arguments it receives and passes the string to a shell for interpretation, which in this case includes parsing the one argument as separate arguments.  Thus, to keep those arguments together we need to make sure that the quotes are seen by SSH by escaping them:</p>
<pre>
% <b>ssh localhost sargs &#34;&#39;1 2 3&#39;&#34;</b>
1 2 3
</pre>
<p>That is what we wanted.  Since SSH joins all the arguments together, we can even send them to SSH as separate arguments as long as the quotes are escaped:</p>
<pre>
% <b>ssh localhost sargs &#92;&#39;1 2 3&#92;&#39;</b>
1 2 3
</pre>
<p>So next time you have trouble with running commands over SSH remember that the shell gets to see the SSH command and run it and that it is not run directly by the sshd process.  Let us take a quick look at sudo to see if it behaves similarly:</p>
<pre>
% <b>sudo sargs &#39;1 2 3&#39;</b>
1 2 3
</pre>
<p>There is no reprocessing by the shell here.  This is good most of the time when you want to run sudo for a single command because there are no shell double-interpreting surprises.  This is bad if you want to run two commands with one invocation of sudo, like this:</p>
<pre>
% <b>sudo sargs 1 2 &#39;&amp;&amp;&#39; sargs 3 4</b>
1
2
&amp;&amp;
sargs
3
4
</pre>
<p>Oops!  That second command got processed as arguments of the first!  Normally it is recommended that you invoke sudo twice and not quote the double-ampersand like so:</p>
<pre>
% <b>sudo sargs 1 2 &amp;&amp; sudo sargs 3 4</b>
1
2
3
4
</pre>
<p><!-- adman --></p>
<p>But sometimes you cannot do that, such as if the first command is <code>sleep</code> and you cannot allow the second sudo command to request your password again because you will be at lunch (<code>sleep 900; shutdown -r now</code>).  Sure, you could use <code>at</code>, but that can be messy in its own way for some tasks.  So how can we invoke sudo so that it can run two commands?</p>
<p>The answer is you cannot, but you can invoke sudo to run a command that runs two commands.  What command might that be?  A shell invoked as a command, of course!  All of the shells that I know of use the -c flag for this.  If you provide a -c flag, the next argument is expanded as a shell command and you can use the special shell characters to break the command up into multiple commands:</p>
<pre>
% <b>sudo zsh -c &#39;sargs 1 2 &amp;&amp; sargs 3 4&#39;</b>
1
2
3
4
</pre>
<p>It is not as pretty as one might hope, but it is reasonably easy to do.</p>
<p>I hope that if you had trouble in the past with figuring out how arguments are handled by different programs that you take this chance to learn using sargs.  It can really come in handy some day when you are programming that script that you need &#8220;an hour ago&#8221; but cannot quite figure out why it does not work right.  If that happens to you, just whip out sargs and verify that your commands are seeing their arguments exactly as they are supposed to see them, and if not then escape or unescape the offending special characters appropriately!</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/09/22/mind-arguments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
