<?xml version="1.0"?>
<rss version="0.91">
  <channel>
    <title>Squeak People diary for msh</title>
    <description>Squeak People diary for msh</description>
    <link>http://people.squeakfoundation.org/person/msh/</link>
    <item>
      <title>10 Jan 2006</title>
      <pubDate>Tue, 10 Jan 2006 03:03:43 -0700</pubDate>
      <link>http://people.squeakfoundation.org/person/msh/diary.html?start=12</link>
      <description>&lt;b&gt;Parsing WebStats with Squeak&lt;/b&gt;

&lt;p&gt; Over the past month I've become obsessed with usage reports for web sites: Analog, awstats, et al. I was not completely satisfied with what I was getting from the existing packages, so I decided to roll my own. You can see what I'm doing by filing in &lt;a href=&quot;http://www.revejo.org/msh/changesets/msh-webstat.1.cs&quot; &gt;http://www.revejo.org/msh/changesets/msh-webstat.1.cs&lt;/a&gt;. An example of how to use the classes defined there is included in the changeset preamble. And for good measure, it's included here as well.

&lt;p&gt; &lt;pre&gt;| a f1 f2 f3 r2 r3|
r3 _ AccessLogBaseReporter new.
r2 _ AccessLogBaseReporter new.
f3 _ AccessLogFilter new.
f2 _ AccessLogFilter new.
f1 _ AccessLogFilter new.
a _ AccessLogReport new.
r3 id: 'successful'.
r2 id: 'all'.
f2 addDestination: r2.
f2 addFilter: [ :i | true ].
f2 source: f1.
f3 addDestination: r3.
f3 addFilter: [ :e | ( e result ) = 200 ].
f3 source: f1.
f1 addDestination: f2.
f1 addDestination: f3.
f1 addFilter: [ :i | true ].
f1 source: a.
a
	stream: ( AccessLogStream with: (FileStream oldFileNamed: '/Users/mhamrick/Documents/Sites/Cryptonomicon.Net/access-log' ) );
	filter: f1.
( a report ) printOn: Transcript.
Transcript flush.&lt;/pre&gt;

&lt;p&gt; Essentially what you do is you create a chain or tree of objects. The trunk of the tree is an instance of the AccessLogReport class. You pass it a 'filter' and a 'stream'. The stream should be an instance of AccessLogStream (as demonstrated above.) The filter is an object that responds to the filtering and reporting protocol.

&lt;p&gt; In the example above, the f1 is a simple &quot;connector&quot; filter. The only thing it does is receive events from its inputs and pass them on to its outputs. In this case, the outputs are two other filters: f2 and f3. f2 is a filter that simply passes all it's results to the reporter r2. f3 is a filter that passes events whose result was 200 (as opposed to 404 or 403) to the reporter r3.

&lt;p&gt; Both r2 and r3 are &quot;base reporters&quot; meaning they track total hits, unique ips, and total bandwidth.

&lt;p&gt; It's kinda rough right now, but I hope to make it a little more interesting over the next couple of weeks.</description>
    </item>
    <item>
      <title>11 Dec 2005</title>
      <pubDate>Sun, 11 Dec 2005 21:01:13 -0700</pubDate>
      <link>http://people.squeakfoundation.org/person/msh/diary.html?start=11</link>
      <description>&lt;b&gt;Simple BASH script for creating a new Squeak instance&lt;/b&gt;

&lt;p&gt; One of the things that I find myself doing on a regular basis is filing out changes, re-installing, and then filing selected changes back in to the new installation.

&lt;p&gt; The main reason I'm doing this is that I'm playing around with some of the language's core features: Class, Behavior and various aspects of message contexts. Ocassionally I'll do something really, really bad which results in an unrunnable image. More frequently I'll modify certain core behaviors that make things run funny, or at least I fear that they're running funny, and want to start again from a fresh install.

&lt;p&gt; So I now have a &quot;stable&quot; squeak directory, along with a host of various directories that include different experiements. The stable directory is pretty stable, but experiments come and go with alarming regularity. So I finally got tired of reinstalling Squeak and implementing the standard changes I make, so I came up with the following script to do it for me.

&lt;p&gt; What I've done is I downloaded a standard Squeak install, made a common changes to the image, and then I saved it in a common source directory. The idea here is that when it's time to experiment, I simply issue a single unix command to get a new directory with a new squeak instance.

&lt;p&gt; One of the things I've done is that I make links to files and directories when I can, and only copy the image and changes file.

&lt;p&gt; I started by creating the &lt;i&gt;~/Library/Squeak&lt;/i&gt; directory. In that directory I put the &lt;i&gt;common&lt;/i&gt; and &lt;i&gt;3.8&lt;/i&gt; directories. In the common directory, I put the &lt;i&gt;SqueakV3.sources&lt;/i&gt; file. In the 3.8 directory, I put the Plugins directory and the files &lt;i&gt;ReadMe.txt&lt;/i&gt;, &lt;i&gt;Squeak3.8-6665.image&lt;/i&gt; and &lt;i&gt;Squeak3.8-6665.changes&lt;/i&gt;.

&lt;p&gt; I modified everything to be read-only (though Plugins and directories are still executable.) I then crafted the following script that creates a new directory with a name I give it, then links to and copies files into the new directory.

&lt;p&gt; I'm not entirely certain that non-Macophiles be able to use it without modification, but I figured it might be handy for MacOS-X users out there. For everyone else, it might be a handy template.

&lt;p&gt; &lt;pre&gt;#!/bin/bash
if [ &quot;${SQUEAKIFY_SOURCE_REVISION}t&quot; == &quot;t&quot; ]; then 
  SQUEAKIFY_SOURCE_REVISION=&quot;3.8&quot;
fi

&lt;p&gt; if [ &quot;${SQUEAKIFY_SOURCE}t&quot; == &quot;t&quot; ]; then
  SQUEAKIFY_SOURCE=&quot;$HOME/Library/Squeak&quot;
fi

&lt;p&gt; COMMON_DIR=&quot;${SQUEAKIFY_SOURCE}/Common&quot;
REVISION_DIR=&quot;${SQUEAKIFY_SOURCE}/${SQUEAKIFY_SOURCE_REVISION}&quot;

&lt;p&gt; mkdir $1
ln -s ${REVISION_DIR}/Plugins $1/Plugins
ln -s ${REVISION_DIR}/ReadMe.txt $1/ReadMe.txt
ln -s ${COMMON_DIR}/SqueakV3.sources $1/SqueakV3.sources
cp ${REVISION_DIR}/*image $1
chmod 644 $1/*image
cp ${REVISION_DIR}/*changes $1
chmod 644 $1/*changes&lt;/pre&gt;</description>
    </item>
    <item>
      <title>9 Dec 2005</title>
      <pubDate>Fri, 09 Dec 2005 14:15:46 -0700</pubDate>
      <link>http://people.squeakfoundation.org/person/msh/diary.html?start=10</link>
      <description>&lt;b&gt;Improved Hash Function Handling in msh-crypto.2.cs&lt;/b&gt;

&lt;p&gt; &lt;p&gt;Just a note to say that I've added support for SHA224, SHA384 and SHA512 to the msh-crypto and msh-crypto-tests packages.

&lt;p&gt; &lt;p&gt;As an interesting aside... the SUnit tests for the SHA384 and SHA512 appear to fail, but when I execute the code in the tests manually (i.e.- I paste it into a Workspace window and DoIt) I get the correct results. Not sure what to think about that...

&lt;p&gt; &lt;p&gt;The SHA384 and SHA512 implementations are quite slow. This has to do mostly with the fact that these algorithms assume we have 64 bit values, so we see a lot of our friend the LargePositiveInteger. These classes could use a pretty good refactoring, but I'm more likely to work on more Symmetric Ciphers and Modes of Operation first.

&lt;p&gt; &lt;p&gt;If you're interested, you can pick up the latest changeset at &lt;a href=&quot;http://www.cryptonomicon.net/msh/changesets/msh-crypto.2.cs&quot; &gt;http://www.cryptonomicon.net/msh/changesets/msh-crypto.2.cs&lt;/a&gt; and &lt;a href=&quot;http://www.cryptonomicon.net/msh/changesets/msh-crypto-test.2.cs&quot; &gt;http://www.cryptonomicon.net/msh/changesets/msh-crypto-test.2.cs&lt;/a&gt;. Note it's being released under a BSD License, not Squeak-L. But please feel free to play around with these classes and let me know what you think. There's documentation in the MessageDigest class on how to use these classes.</description>
    </item>
    <item>
      <title>8 Nov 2005</title>
      <pubDate>Tue, 08 Nov 2005 03:58:25 -0700</pubDate>
      <link>http://people.squeakfoundation.org/person/msh/diary.html?start=9</link>
      <description>&lt;b&gt;Demo of &quot;secure&quot; Password holder&lt;/b&gt;

&lt;p&gt; &lt;p&gt; A couple days ago Andreas Raab posted to the Croquet dev list saying he had pushed out a couple images with MC passwords built into them. Sure it's a security faux pas, but you would think that by now we wouldn't have to bury passwords inside images. Some of the blame here goes to the tool; there should be a &quot;secure vault&quot; for Squeak.

&lt;p&gt; &lt;p&gt; Chris Mueller posted a quick note about KryptOn ( documented at &lt;a href=&quot;http://minnow.cc.gatech.edu/squeak/5785&quot; &gt;http://minnow.cc.gatech.edu/squeak/5785&lt;/a&gt; ). I think he's putting the finishing touches on that code, and it promises to be pretty cool.

&lt;p&gt; &lt;p&gt; I've been working on the security roadmap for Spoon over the last couple of weeks. A full-featured &quot;vault&quot; to store private things (like passwords, shared secrets, private keys) and public things (like certificates) is in the roadmap. Having been &quot;programming in PowerPoint(tm)&quot; for the last couple of days (which is my way of saying I've been drawing a bunch of boxes and not actually coding)  has left me wanting to hack a little code. So.. I put together a  brief demo of how a &quot;secure&quot; password vault might look to an client method.

&lt;p&gt; &lt;p&gt; Assuming you're running the Spoon control image and don't have the msh-crypto classes loaded, you can file in the change set at &lt;a href=&quot;http://www.cryptonomicon.net/msh/squeak/msh-passdemo.1.cs&quot; &gt;http://www.cryptonomicon.net/msh/squeak/msh-passdemo.1.cs&lt;/a&gt; . Sadly there's something funky going on with the changeset loader in Squeak 3.8 that makes it difficult to load the changeset. If you're running Squeak3.8, you can use the changeset from &lt;a href=&quot;http://www.cryptonomicon.net/msh/squeak/spoon-pass-demo-for-squeak38.1.cs&quot; &gt;http://www.cryptonomicon.net/msh/squeak/spoon-pass-demo-for-squeak38.1.cs&lt;/a&gt;. 

&lt;p&gt; &lt;p&gt; Here are a few notes from the class documentation about the &quot;SpoonPassword&quot; class (note that it's simply named Password in the spoon changeset.)

&lt;p&gt; &lt;p&gt; The SpoonPassword is one of a long line of simple password holders for Squeakish smalltalks. This one was developed for Spoon.

&lt;p&gt; &lt;p&gt; The SpoonPassword class responds to #at: and #at:put: messages so it looks like a dictionary to clients. If you want to &quot;securely&quot; hold a password, you simply add it to the SpoonPassword dictionary like so:

&lt;p&gt; &lt;p&gt; 	SpoonPassword at: 'celeste:account:msh@cryptonomicon.net' put: 'Dingos'

&lt;p&gt; &lt;p&gt; To retrieve the password for this account, use the invocation:

&lt;p&gt; &lt;p&gt; 	SpoonPassword at: 'celeste:account:msh@cryptonomicon.net'

&lt;p&gt; &lt;p&gt; The next time you save the image, you will be prompted for a master key for the &quot;secure&quot; vault these passwords live in.

&lt;p&gt; &lt;p&gt; Now... you might be one of these people that doesn't like being prompted for passwords. That's okay; I understand. I have a list of passwords as long as my arm, and the main purpose of this class is to keep passwords out of images that get sent around on development lists.

&lt;p&gt; &lt;p&gt; If you look closely, you'll see that I've added a method to Preferences called #secretVaultPassword. It currently returns nil, but if you set it to return something non-nil, you'll have an image that has the master password for the local copy of your secret vault. This is sorta playing fast and loose with the concept, but hey, I'm all about giving people enough rope to hang themselves.

&lt;p&gt; &lt;p&gt; If you're going to set the secretVaultPassword, don't distribute your svault.bin file.

&lt;p&gt; &lt;p&gt; &lt;b&gt;And what's wrong with this implementation?&lt;/b&gt;

&lt;p&gt; &lt;p&gt; So I wrote this as a quick demo in response to a question from Andreas Raab. It's similar in theory to something we're planning on adding to Spoon, so I figured I would release it into the wild and see if anyone had any &lt;i&gt;constructive&lt;/i&gt; criticism of the code. The implementation is pretty darn'd poor. But the interface I think is reasonable. Here's a quick list of things that are wrong with the implementation:

&lt;p&gt; &lt;p&gt; * Using a vernam cipher with a magic cookie in the front. ARC4 has a additive feature such that when you take one plaintext, encrypt it with two different keys and then XOR the two ciphertexts together, you get the XOR of the two keystreams. This is bad. 

&lt;p&gt; &lt;p&gt; * Using &quot;stock&quot; ARC4 is generally considered bad. ARC4 has been the target of a lot of successful cryptanalysis lately. What we SHOULD do is come up with a fast version of AES for Spoon and use that instead. Hmm... oddly enough... this is on the roadmap.

&lt;p&gt; &lt;p&gt; * The svault.bin parser is laughable. No... seriously... if you want a good laugh look at my parser.

&lt;p&gt; &lt;p&gt; * There are no tests.

&lt;p&gt; &lt;p&gt; * It keeps asking you if you're sure you want to save the file or overwrite it. I've got to look at the logic once more.

&lt;p&gt; &lt;p&gt; * It doesn't give you a clean option to cancel flushing the passwords to disk (which requires you to type in a password before shutting down.)

&lt;p&gt; &lt;p&gt; * It uses ARC4. Yeah, I mentioned this before. But this is bad enough to mention twice.

&lt;p&gt; &lt;p&gt; * It's only a password vault, not the full PKCS12ish thing we want to eventually have.

&lt;p&gt; &lt;p&gt; Anyhow... I hope this code is of interest to someone out there. Feel free to pelt me with comments or questions.

&lt;p&gt; &lt;p&gt; -Cheers,
-Matt H.</description>
    </item>
    <item>
      <title>27 Oct 2005</title>
      <pubDate>Thu, 27 Oct 2005 11:39:48 -0700</pubDate>
      <link>http://people.squeakfoundation.org/person/msh/diary.html?start=8</link>
      <description>&lt;b&gt;Ship, Captain, Crew in Smalltalk&lt;/b&gt;

&lt;p&gt; I can't tell you how many time's I've wanted to play Ship, Captain and Crew but just didn't have any dice handy. Now with this handy class, I can play as much as I want, all without ever leaving Squeak!

&lt;p&gt; The code is available as a changeset at &lt;a href=&quot;http://www.cryptonomicon.net/msh/squeak/msh-scc.1.cs&quot; &gt;http://www.cryptonomicon.net/msh/squeak/msh-scc.1.cs&lt;/a&gt;.

&lt;p&gt; So for all you pirates out there, the main class you should be interested in is ShipCaptainCrew. This class' instances model a SCC game where you have 3 throws of 5 dice to get a 6, 5 and a 4 (in that order) with the goal that you're trying to have the other two dice add up to a high score. After installing the changeset, all you need do is evaluate the following with printIt:

&lt;p&gt; &lt;blockquote&gt;( ShipCaptainCrew new ) throw; throw; throw; score&lt;/blockquote&gt;

&lt;p&gt; I'm ashamed of the fact that I didn't include a ShipCaptainCrewMorph in the distribution. Hey... everyone loves nice UIs. But if you happen to have a Transcript open, you can see the blow by blow of the three rolls. My goal was to actually write the morph, but the real world got in the way and I don't have time for that right now.

&lt;p&gt; If you want to code up a Morph to add a nice UI, it shouldn't be that difficult. I use methods to access the various instance variables used by each instance. Plus I defined a UI category. The current version doesn't do anything with the UI other than emit text to the transcript, but if you were clever, you could probably override the UI methods in a subclass, including liberal use of #changed and #update to make a pretty straight-forward model for Morphic or MVC.

&lt;p&gt; Another reason you might want to subclass this guy is to change the default behavior of the evaluator. After each throw, I call the #evaluate method to figure out which dice I should save and which I should throw next time (if you're looking at the Transcript output of this class, numbers in parentheses are rolls the evaluator thinks we should keep.) I created a subclass called SimpleStrategySCC that overrides the #evaluate method that implements the simple strategy of not rerolling dice that are 4, 5, or 6. Maybe you have a better strategy? If so, all you have to do to test it is write a subclass that overrides #evaluate. So if you want to test out SimpleStrategySCC, just evaluate the following:

&lt;p&gt; &lt;blockquote&gt;(SimpleStrategySCC new) throw; throw; throw; score&lt;/blockquote&gt;

&lt;p&gt; Finally... I pulled the same trick with the randomosity category that I used in the Star Trek plot generator. I would love to use real random numbers, but c'mon, SCC just isn't that important to warrant the extra work.

&lt;p&gt; And for the truely geeky... you can simulate a game of SCC with more than 5 dice by using the #new: method on ShipCaptainCrew.

&lt;p&gt; Okay, that's enough. There's not too much more to say other than I justified spending the time to write this by telling myself it's a good example of how to design a model for a MVC triad. I like to think that the structure of this implementation shows how you can separate behaviors between implementations and use subclassing to extend object behavior. I like to think it's well documented, and I hope it's easy to understand.</description>
    </item>
    <item>
      <title>20 Oct 2005</title>
      <pubDate>Thu, 20 Oct 2005 21:45:17 -0700</pubDate>
      <link>http://people.squeakfoundation.org/person/msh/diary.html?start=7</link>
      <description>&lt;b&gt;Star Trek Plot Generator&lt;/b&gt;

&lt;p&gt; So I've been involved in a cross country move for most of the last month, so I haven't done any &quot;real&quot; work with Squeak. I have, however, managed to scrape together enough time to build an extremely crappy Squeak implementation of Justin B. Rye's &lt;a href=&quot;http://www.xibalba.demon.co.uk/jbr/trek/gen.html&quot; &gt;DIY Star Trek Script Flowchart&lt;/a&gt;. Apart from the way I completely avoid dealing with seeding random number generators, this is definitely NOT the way one would want to do things in an OO language.

&lt;p&gt; The changeset is available at &lt;a href=&quot;http://www.cryptonomicon.net/msh/squeak/msh-trek.1.cs&quot; &gt;http://www.cryptonomicon.net/msh/squeak/msh-trek.1.cs&lt;/a&gt;. Feel free to load it up and tell me what you think. Here are a few usage hints cribbed from the class documentation:

&lt;p&gt; For example, select the following text and evaluate it with 'printIt':

&lt;p&gt; 	&lt;blockquote&gt;StarTrekPlotGenerator newAsString&lt;/blockquote&gt;

&lt;p&gt; For serious trekkies, repeatedly call the following text to see new plots emitted on the system Transcript:

&lt;p&gt; 	&lt;blockquote&gt;StarTrekPlotGenerator newOnTranscript&lt;/blockquote&gt;</description>
    </item>
    <item>
      <title>9 Sep 2005</title>
      <pubDate>Fri, 09 Sep 2005 09:24:17 -0700</pubDate>
      <link>http://people.squeakfoundation.org/person/msh/diary.html?start=6</link>
      <description>&lt;b&gt;Playing with Tweak&lt;/b&gt;

&lt;p&gt; &lt;p&gt; &lt;p&gt;Okay... so I've been hearing veiled references to Tweak for a while. I had thought it was simply another visual programming system to layer on top of Squeak like MVC and Morphic. I eventually went to read a little about it and discovered that in fact it's much more.

&lt;p&gt; &lt;p&gt; &lt;p&gt;Among other things, Tweak introduces an annotation system for Squeak that allows developers to add meta-data to methods. Right now it appears to be used mostly for telling methods what types of event messages they'll receive so the system can automagically generate code to handle them. Which is a great use for annotations. I was recently discussing annotating Smalltalk to implement AOP type features. In the distant past I remember a discussion or two about using annotation to bind instance variables to data types with the goal of being able to model an OS in Smalltalk, then with the type information in the annotation, the system could generate an executable of itself.

&lt;p&gt; &lt;p&gt; &lt;p&gt;So... I encourage anyone who might be reading to take a quick look at Tweak at: &lt;a href=&quot;http://tweak.impara.de/&quot; &gt;http://tweak.impara.de/&lt;/a&gt;. At some point in the near future I'm going to try to build a Tweak based UI for the YahooSearch class I scrubbed together last spring.

&lt;p&gt; &lt;b&gt;Squeak for the iPod&lt;/b&gt;

&lt;p&gt; &lt;p&gt;Okay... I've got an iPod, and I noticed one can run uLinux on it. I figured it might be great fun to port Squeak to an iPod. (That's actually the reason I was looking at Tweak... to see if I could build a better iPod UI in Squeak / Tweak.) Anyone heard of such a thing?</description>
    </item>
    <item>
      <title>18 Aug 2005</title>
      <pubDate>Thu, 18 Aug 2005 18:29:12 -0700</pubDate>
      <link>http://people.squeakfoundation.org/person/msh/diary.html?start=5</link>
      <description>&lt;p&gt;&lt;b&gt;Fibonacci Numbers in Squeak&lt;/b&gt;

&lt;p&gt; &lt;p&gt;I just had a pretty good discussion with one of those &quot;old as the hills&quot; engineers. He was everything you expected... gruff, filled with hubris, and a bit grumpy. However, there was no doubt he really knew his stuff. We started talking about the Fibonacci series and it's calculation ( I think the discussion was in conjunction to optimizations on code.) After a bit of thinking about this problem, I noticed that Squeak doesn't have a Fibonacci calculation facility. It's pretty simple stuff, so I added it myself.

&lt;p&gt; &lt;p&gt;So there was a little bit of confusion about the Fibonacci sequence in the discussion. I remembered that f(0) was 0, f(1) was 1, and f(n) where n &amp;gt;= 2 is f(n-1) + f(n-2). This is in accord with what you can find on the Wikipedia entry on &lt;a href=&quot;http://en.wikipedia.org/wiki/Fibonacci_number&quot; &gt;Fibonacci Number&lt;/a&gt;. This gives you a sequence of 0, 1, 1, 2, 3, 5, 8 ... starting with index 0. The gruff uber-geek I was talking with and the 2005 World Book that came with my Mac gives the definition of the sequence as being f(0) = 1, f(1) = 1, f(n) where n &amp;gt;= 2 is f(n-1) + f(n-2). This gives a sequence of 1, 1, 2, 3, 5, 8 starting with 0. Now I can't help but notice that one sequence is a subset of the other, so I'm having a hard time figuring out which is really correct (or rather... there are people out there with much more authority to say which is correct.)

&lt;p&gt; &lt;p&gt;I did a little sniffing and found the benchFib message on the Integer class. But it seemed to calculate something related but different. It seemed that the idea was to use the message as part of a benchmarking test. I'm happy to say that my new G4 iBook performs the standard benchFib test about 10 times faster than the Pentium used to initially run the test.

&lt;p&gt; &lt;p&gt;So I put together a couple of changesets with methods for Integer and IntegerTest. You can find them at &lt;a href=&quot;http://www.cryptonomicon.net/msh/squeak/Integer.msh.1.cs&quot; &gt;http://www.cryptonomicon.net/msh/squeak/Integer.msh.1.cs&lt;/a&gt; and &lt;a href=&quot;http://www.cryptonomicon.net/msh/squeak/IntegerTest.msh.1.cs&quot; &gt;http://www.cryptonomicon.net/msh/squeak/IntegerTest.msh.1.cs&lt;/a&gt;. &lt;i&gt;&lt;b&gt;Files on this server have a bad habit of disappearing, so I'm going to include the changesets in this message posting as well. Just cut and paste them into .cs files and file them in directly if the links above don't work.&lt;/b&gt;&lt;/i&gt;

&lt;p&gt; &lt;p&gt;Here's the Integer changeset. Just copy this guy into a file that ends in .cs and use the file list viewer to file them in.

&lt;p&gt; &lt;p&gt;&lt;pre&gt;
'From Squeak3.8 of ''5 May 2005'' [latest update: #6665] on 18 August 2005 at 2:05:51 am'!

&lt;p&gt; !Integer methodsFor: 'mathematical functions' stamp: 'msh 8/18/2005 01:56'!
fibonacci
        ^ ( self fibonacciEfficient ) .! !

&lt;p&gt; !Integer methodsFor: 'mathematical functions' stamp: 'msh 8/18/2005 01:39'!
fibonacciEasy
        ( self &amp;lt; 0 ) ifTrue: [
                self error: 'Not valid for negative integers'.
        ].

&lt;p&gt;         ( self &amp;lt; 2 )
                ifTrue: [ ^ 1. ]
                ifFalse: [ ^ ( self - 1 ) fibonacciEasy + ( self - 2 ) fibonacciEasy ].! !

&lt;p&gt; !Integer methodsFor: 'mathematical functions' stamp: 'msh 8/18/2005 01:52'!
fibonacciEfficient
        | a b c |

&lt;p&gt;         ( self &amp;lt; 0 ) ifTrue: [
                self error: 'Not valid for negative integers'.
        ].

&lt;p&gt;         ( self &amp;lt; 2 )
                ifTrue: [ ^ 1. ]
                ifFalse: [
                        a _ 0.
                        b _ 1.

&lt;p&gt;                         2 to: self do: [ :current |
                                c _ b.
                                b _ a + b.
                                a _ c.
                        ].

&lt;p&gt;                         ^ ( a + b ) .
                ].! !
&lt;/pre&gt;

&lt;p&gt; &lt;p&gt;And here's the changeset for IntegerTest. I probably should have put the IntegerTest changeset first to reiterate the fact that it's always good practice to write a test before writing code. And in fact, I actually did this this time.

&lt;p&gt; &lt;p&gt;&lt;pre&gt;
'From Squeak3.8 of ''5 May 2005'' [latest update: #6665] on 18 August 2005 at 2:06:57 am'!

&lt;p&gt; !IntegerTest methodsFor: 'testing - math' stamp: 'msh 8/18/2005 01:24'!
testFibonacci
        &quot;tests the default implementation of the fibonacci calculation code.&quot;

&lt;p&gt;         self should: [0 fibonacci = 1].
        self should: [1 fibonacci = 1].
        self should: [2 fibonacci = 2].
        self should: [3 fibonacci = 3].
        self should: [4 fibonacci = 5].
        self should: [5 fibonacci = 8].
        self should: [6 fibonacci = 13].
        self should: [7 fibonacci = 21].
        self should: [8 fibonacci = 34].
! !

&lt;p&gt; !IntegerTest methodsFor: 'testing - math' stamp: 'msh 8/18/2005 01:18'!
testFibonacciEasy
        &quot;tests the 'easy' implementation of the fibonacci calculation code.&quot;

&lt;p&gt;         self should: [0 fibonacciEasy = 1].
        self should: [1 fibonacciEasy = 1].
        self should: [2 fibonacciEasy = 2].
        self should: [3 fibonacciEasy = 3].
        self should: [4 fibonacciEasy = 5].
        self should: [5 fibonacciEasy = 8].
        self should: [6 fibonacciEasy = 13].
        self should: [7 fibonacciEasy = 21].
        self should: [8 fibonacciEasy = 34].
! !

&lt;p&gt; !IntegerTest methodsFor: 'testing - math' stamp: 'msh 8/18/2005 02:04'!
testFibonacciEfficient
        &quot;tests the efficient implementation of the fibonacci calculation code.&quot;

&lt;p&gt;         self should: [0 fibonacciEfficient = 1].
        self should: [1 fibonacciEfficient = 1].
        self should: [2 fibonacciEfficient = 2].
        self should: [3 fibonacciEfficient = 3].
        self should: [4 fibonacciEfficient = 5].
        self should: [5 fibonacciEfficient = 8].
        self should: [6 fibonacciEfficient = 13].
        self should: [7 fibonacciEfficient = 21].
        self should: [8 fibonacciEfficient = 34].

&lt;p&gt;         &quot;check to see that f(n) is equal to f(n-1) + f(n-2)&quot;

&lt;p&gt;         9 to: 1024 do: [ :current |
                self should: [ (current fibonacciEfficient) = ( ( ( current - 1 ) fibonacciEfficient) + ( current - 2 ) fibonacciEfficient ) ].
        ].
! !
&lt;/pre&gt;

&lt;p&gt; &lt;p&gt;&lt;b&gt;A few notes about the fibonacci implementations.&lt;/b&gt;

&lt;p&gt; &lt;p&gt;It's probably worth a few moments to say a few notes about the various fibonacci methods. First, you'll probably notice three methods: fibonacci, fibonacciEasy, and fibonacciEfficient. fibonacciEasy uses the canonical definition of the series to calculate the fibonacci number for a various index. It uses recursion, and you can get some pretty serious performance hits as n grows greater than say 20 or 30. The fibonacciEfficient method uses a simple loop to calculate the fibonacci number at a particular index. It is wildly more efficient. You can prove this to yourself by excuting the following code fragment:

&lt;p&gt; &lt;p&gt;&lt;pre&gt;
Time millisecondsToRun: [ 30 fibonacciEasy ].
&lt;/pre&gt;

&lt;p&gt; &lt;p&gt;and then execute:

&lt;p&gt; &lt;p&gt;&lt;pre&gt;
Time millisecondsToRun: [ 30 fibonacciEfficient ].
&lt;/pre&gt;

&lt;p&gt; &lt;p&gt;At some point in the future I'll write something that talks about time and space efficiency of these two algorithms. You can find a brief discussion about the complexity of the algorithm at the Wikipedia article referenced above. Basically what's going on is the fibonacciEfficient algorithm operates in a constant order with respect to space and order n with respect to time. The fibonacciEasy algorithm is exponential with an order somewhere between 2 ^ n and 2 ^ ( n / 2 ).

&lt;p&gt; &lt;p&gt;The fibonacci method simply calls the fibonacciEfficient implementation.

&lt;p&gt; &lt;p&gt;Cheers!&lt;br/&gt;-Matt H.</description>
    </item>
    <item>
      <title>15 Aug 2005</title>
      <pubDate>Mon, 15 Aug 2005 08:54:40 -0700</pubDate>
      <link>http://people.squeakfoundation.org/person/msh/diary.html?start=4</link>
      <description>&lt;b&gt;Fun with ServerDirectories&lt;/b&gt;
&lt;p&gt;One of the common critiques of image based systems in general and Smalltalk in particular is the difficulty in doing source control or configuration management when collaborating with others. In an effort to figure out how to best use Squeak in collaborative projects, I investigated the ProjectDirectory class. One of the things I figured out was how to setup a ServerDirectory on my own server. Here's some documentation...

&lt;p&gt; &lt;p&gt;The canonical location for these notes is &lt;a href=&quot;http://www.cryptonomicon.net/msh/squeak/msh-search.html&quot; &gt;http://www.cryptonomicon.net/msh/squeak/msh-search.html&lt;/a&gt;.

&lt;p&gt; &lt;p&gt;So let's just say you want to create your own ServerDirectory, the first thing I did when setting up my environment was to add the ServerDirectory with this code fragment:

&lt;p&gt; &lt;p&gt;&lt;pre&gt;
ServerDirectory addServer: ( ( ServerDirectory new )
	server: 'cryptonomicon.net';
	directory: '/squeak';
	type: #ftp;
	user: 'msh@cryptonomicon.net';
	moniker: 'msh private projects at cryptonomicon.net';
	altUrl: 'http://cryptonomicon.net/msh' ) named: 'msh private projects at cryptonomicon.net'.
&lt;/pre&gt;

&lt;p&gt; &lt;p&gt;The next thing I want to do is save the project to a server, but I have to modify the FTPClient code with the following code:

&lt;p&gt; &lt;p&gt;&lt;pre&gt;FTPClient
	compile: 'fetchNextResponse
	&quot;updated version of fetchNextResponse.&quot;

&lt;p&gt; 	| multiLine currentLine result code newCode |

&lt;p&gt; 	multiLine _ False.
	result _ '''' writeStream.
	currentLine _ ( self stream ) nextLine.
	result nextPutAll: currentLine.
	self lastResponse: currentLine.

&lt;p&gt; 	( ( currentLine size ) &amp;gt; 3 and: [ ( currentLine at: 4 ) == $- ] ) ifTrue: [
		multiLine _ True.
		code _ self determineResponseCode.
	].

&lt;p&gt; 	[
		multiLine == True.
	] whileTrue: [
		currentLine _ ( self stream ) nextLine.
		result nextPutAll: currentLine.
		( ( currentLine size ) &amp;gt; 3 and: [ ( currentLine at: 4 ) == $  ] ) ifTrue: [
			self lastResponse: currentLine.
			newCode _ self determineResponseCode.
			( newCode = code ) ifTrue: [
				multiLine _ False.
			].
		]
	].

&lt;p&gt; 	self lastResponse: ( result contents ).'
	classified: 'private protocol'
	withStamp: 'msh 3/19/2005 00:00'
	notifying: (SyntaxError new category: 'private protocol').
&lt;/pre&gt;

&lt;p&gt; &lt;p&gt;Now that the FTPClient is fixed, we can move forward with saving the project. You can do this by selecting the &quot;Projects... Save on Server...&quot; item from the desktop menu. Or, if you have a penchant for doing things programatically, you can do:

&lt;p&gt; &lt;p&gt;&lt;pre&gt;
	(Project current) storeOnServer
&lt;/pre&gt;

&lt;p&gt; &lt;p&gt;Okay... now that we've set everything up. What next?

&lt;p&gt; &lt;p&gt;I noticed that when I use the Safari browser on my Mac to view Squeak projects, I get a message saying something about not being able to resolve server 'msh-base.001.pr'. So it seems that Safari want's me to put the entire URL in the src attribute of the EMBED tag. So, I modified the htmlPagePrototype and storeHtmlPageIn: methods. Here are some fragments that will update these methods to include the changes:

&lt;p&gt; &lt;p&gt;&lt;pre&gt;Project
	compile: 'storeHtmlPageIn: aFileDirectory
	&quot;Prepare the HTML wrapper for the current project&quot;
	| file page server url |
	file _ aFileDirectory forceNewFileNamed: (self name, FileDirectory dot,''html'').
	server _ self primaryServer.
	url _ ( server altUrl ) , ( server directory ) , ''/'' , ( self versionedFileName ).
	page _ self htmlPagePrototype.
	page _ page copyReplaceAll: ''$$TITLE$$'' with: self labelString.
	page _ page copyReplaceAll: ''$$WIDTH$$'' with: world bounds width printString.
	page _ page copyReplaceAll: ''$$HEIGHT$$'' with: world bounds height printString.
	page _ page copyReplaceAll: ''$$SRC$$'' with: url.
	page _ page copyReplaceAll: String cr with: String lf. &quot;not sure if necessary...&quot;
	file nextPutAll: page.
	file close.
'
	classified: 'file in/out'
	withStamp: 'msh 3/19/2005 00:00'
	notifying: (SyntaxError new category: 'file in/out').
&lt;/pre&gt;
	
&lt;p&gt;and here's the second method

&lt;p&gt; &lt;p&gt;&lt;pre&gt;Project
	compile: 'htmlPagePrototype
	&quot;Return the HTML page prototype&quot;
^''&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Project $$TITLE$$&amp;lt;/title&amp;gt;
    &amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;/&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;EMBED 
      type=&quot;application/x-squeak-source&quot;
      align=&quot;center&quot;
      WIDTH=&quot;$$WIDTH$$&quot;
      HEIGHT=&quot;$$HEIGHT$$&quot;
      src=&quot;$$SRC$$&quot;
      pluginspage=&quot;http://www.squeakland.org/detect.html&quot;&amp;gt;
    &amp;lt;/EMBED&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
''
'
	classified: 'file in/out'
	withStamp: 'msh 3/19/2005 00:00'
	notifying: (SyntaxError new category: 'file in/out').&lt;/pre&gt;

&lt;p&gt; &lt;p&gt;Or, you could probably just fileIn the change set.</description>
    </item>
    <item>
      <title>4 May 2005</title>
      <pubDate>Wed, 04 May 2005 20:00:37 -0700</pubDate>
      <link>http://people.squeakfoundation.org/person/msh/diary.html?start=3</link>
      <description>&lt;p&gt;&lt;b&gt;More about the msh-yahoo and msh-search projects&lt;/b&gt;

&lt;p&gt; &lt;p&gt;Okay... so I modified the msh-yahoo project at &lt;a href=&quot;http://www.cryptonomicon.net/msh/squeak/msh-yahoo.001.pr&quot; &gt;http://www.cryptonomicon.net/msh/squeak/msh-yahoo.001.pr&lt;/a&gt; so that it did not directly include the VisualWorks XML stuff. The idea here was that I thinking that I didn't want to have an explicit dependency on the VWXML implementation, only the interface. This is okay if you're running plain ol' desktop squeak, because you can include the XML stuff in another project and have those classes visable in the msh-yahoo project.

&lt;p&gt; &lt;p&gt;Unfortunately, this freaks the livin' daylights out of the SqueakPlugin image. Why? because the VWXML stuff isn't there, and the project includes classes that reference them. You know you have this problem if you try to load the msh-yahoo project with the SqueakPlugin and you get an error message that says, &quot;OXSAXLocator is missing -- cannot load&quot;. So... I created a different project, msh-search, that includes a fragment that when evaluated will load the classes in question. If you're interested, you can see it at &lt;a href=&quot;http://www.cryptonomicon.net/msh/squeak/msh-search.html&quot; &gt;http://www.cryptonomicon.net/msh/squeak/msh-search.html&lt;/a&gt;.

&lt;p&gt; &lt;p&gt;&lt;b&gt;What this tells me about Smalltalk, Squeak, and SCM&lt;/b&gt;

&lt;p&gt; &lt;p&gt;This should probably tell me more about the way I view the world of software than it tells me about Squeak (or Smalltalk.) I've always appreciated the &quot;image based&quot; features of traditional smalltalks (and FORTHs and Self for that matter.) But as mi amigo Mike Perry (of L&amp;amp;P FORTH fame) is fond of saying, &quot;image based development has a lot of benefits, working easily with other people is not one of them.&quot; I've been looking for ways of disproving this conjecture, but so far we haven't reached the promised land.

&lt;p&gt; &lt;p&gt;I've been sort of shy when it comes to Monticiello, maybe I should just jump in. Another thing I've figured out is that I like to build &quot;working image sets.&quot; That is to say, I don't have just one squeak image on my hard drive, I have several. I have an &quot;experimental&quot; image, a &quot;debugging&quot; image, and a &quot;standard&quot; image. In each image, I have different types of projects. In the experimental image, I do all sorts of crazy stuff that might completely hork the VM. In the debugging image, I've instrumented various core routines to print out debugging messages ( note, this is not a debugging technique I whole-heartedly recommend. It is, however, ocassionally the fastest route to solution for simple questions. )

&lt;p&gt; &lt;p&gt; The idea behind multiple images is that I can protect my main-line development classes from inadvertant problems. The experimental image allows me to get a better idea for how the Squeak VM works. Ditto for the Debugging image. The changes I make in those images are systematic and drastic, but are not required for typical program development. 

&lt;p&gt; &lt;p&gt; So what I was thinking recently was what we need is a way to compose a running image from a collection of other images. This way I could have a &quot;desktop&quot; image composed of the kernel, desktop, and network support &quot;sub images.&quot; The Squeak Plugin image could be composed of Kernel, plugin, and network support &quot;sub images.&quot; The idea would be each image has interface and implementation of code at different levels of maturity.

&lt;p&gt; &lt;p&gt; Just a thought. I'm overdue to talk to Craig about NAIAD (Name And Identity Are Distinct) in Spoon. I'm willing to bet there's something interesting there. </description>
    </item>
  </channel>
</rss>
