Metacello Toolbox

December 6th, 2011 2 comments

Metacello Is Cool

Metacello is a great project that manages your Smalltalk project’s dependencies on:

  1. other projects
  2. Smalltalk platforms (e.g. Squeak 4.2 vs. Pharo 1.2)

Overcoming the mess that package loading has historically been (imagine trying to guess which version to use of each package of multiple interoperating projects while the platform evolves beneath you!), it lets you say the programmatic equivalent of:

Before loading my project, you must load the current stable version of the OSProcess project. Then, for my first package: if this is Pharo1.2, load version X; if Squeak 4.2, load version Y…

But We Need Tools!

Writing configurations by hand can be a drag. But fear not! Dale and Co. have created an API to facilitate your workflow. It is described in detail in the draft chapter of Pharo By Example 2. Here’s a walkthrough of my first experience using it…

Describing Project Structure

    createBaseline: '1.0-baseline'
    for: 'SimpleApplescript' "Project name"
    repository: ''
    requiredProjects: #('OSProcess')
    packages: #('CommandShell-Piping' 'SimpleApplescript')
    repositories: #()
    dependencies: {
        ('SimpleApplescript' -> #('CommandShell-Piping')).
        ('CommandShell-Piping' -> #('OSProcess')) }
    groups: { ('default' -> #('SimpleApplescript')) }.

As good Smalltalk code, it does just what it says – describes the project and its dependencies – namely, that the SimpleApplescript package depends on CommandShell-Piping, which in turn depends on OSProcess. Usually, it would not be our responsibility to describe dependencies of an external package like CommandShell-Piping, but CommandShell currently has no Metacello configuration of its own, so we step in (although creating one would be cleaner :)). Here’s the method it generated:

baseline10: spec
    <version: '1.0-baseline'>
    spec for: #'common' do: [
        spec blessing: #'baseline'.
        spec repository: ''.
        spec project: 'OSProcess' with: [
                className: 'ConfigurationOfOSProcess';
                versionString: #'stable';
                repository: '' ].
            package: 'CommandShell-Piping' with: [
                spec requires: #('OSProcess' ). ];
            package: 'SimpleApplescript' with: [
                spec requires: #('CommandShell-Piping' ). ];
            package: 'SimpleApplescript-Specifications' with: [
                spec requires: #('SimpleApplescript' ). ].
        spec group: 'default' with: #('SimpleApplescript' 'SimpleApplescript-Specifications' ). ].

Now there was one thing I was unable to specify above. Because CommandShell-Piping is an external package, we need to tell Metacello where to find it (see how quickly things get complicated without Metacello). So I added a line to the generated baseline above:

package: 'CommandShell-Piping' with: [
        repository: ''; "added manually"
        requires: #('OSProcess' ). ];

Version Snapshot

    createDevelopment: '1.0'
    for: 'SimpleApplescript'
    importFromBaseline: '1.0-baseline'
    description: 'initial development version'.

Here, we just did something amazingly cool. Metacello walked through our project’s packages and dependencies and created a version with:

  • the current versions of each package
  • the appropriate version of each external project (e.g. stable, bleedingEdge)

Here’s the method it generated:

version10: spec
    <version: '1.0' imports: #('1.0-baseline' )>
    spec for: #'common' do: [
        spec blessing: #'release'.
        spec description: 'initial development version'.
        spec author: 'SeanDeNigris'.
        spec timestamp: '12/6/2011 10:38'.
        spec project: 'OSProcess' with: #'stable'.
            package: 'CommandShell-Piping' with: 'CommandShell-Piping-dtl.10';
            package: 'SimpleApplescript' with: 'SimpleApplescript-SeanDeNigris.1'. ].


PBE2 advises us to validate our configurations after editing. It’s easy to do, just printIt the following, which will return a collection of problems, if any:

MetacelloToolBox validateConfiguration: ConfigurationOfSimpleApplescript.

A configuration is Born

Now we have a functioning configuration. We will commit it so we can start testing it on the different platforms we support:

Gofer new
    url: '';
    package: 'ConfigurationOfSimpleApplescript';
    commit: 'Initial version of configuration'.

Release into the Wild

Once we are satisfied that our configuration is correct for all supported platforms (beyond the scope of this post, see the PBE2 draft chapter), we promote our current development version (the one we created a few steps ago) to released status:

    releaseDevelopmentVersionIn: ConfigurationOfSimpleApplescript
    description: '- release version 1.0'. "this will be the commit comment"


So the community can easily find our configuration, we copy it to (note that this location may change in the future as the community is rapidly evolving best practices for Metacello):

    copyConfiguration: ConfigurationOfSimpleApplescript
    to: ''.


Metacello solved a great need in the Squeak/Pharo ecosystem, and its tool support is making it easy and fun to use.

Here’s a github gist of the code above that you can customize to create your own configuration. Have fun!

Categories: Pharo, Smalltalk, Squeak Tags:

Run Applescript on new email

July 26th, 2011 No comments

I’m still experimenting, but so far I found two strategies:

  • Enable Folder Actions and attach a script to the folder in ~/Library/Mail/ which hold the inbox’s messages
  • Create a rule general enough to reply to all messages (e.g. account = my_email_account)

The rule approach seems to fire a bit quicker than the Folder Actions, so I’m going with that for the moment.

Categories: Applescript, Mac Tags:

Smalltalk Simple Image-based Persistence

May 30th, 2011 5 comments

In an enlightening blog post, Ramon Leon explains that most applications are designed for small businesses with small amounts of data. Therefore most applications will never have to scale (i.e. become the next Twitter), so a relational database is overkill. However, persisting by simply saving the image is slow and error-prone.

Based on these ideas, he suggests a simple (one class) framework which saves only your model. The idea is to use it as long as you can get away with, which may be forever.

I packaged the code from the post, added a few tests, and put it on SqueakSource as SimplePersistence.

It’s really easy to give your application persistence (see SPFileDatabase’s class comment). The three steps are:

  1. Subclass SPFileDatabase
  2. On the class-sode of the subclass, implement
    • #repositories – returns a collection of objects to be saved
    • #restoreRepositories: – gets passed back the collection.

That’s it! Now, whenever you want to save, call class>>saveRepository or class>>takeSnapshot (background save).

Categories: Programming, Smalltalk, Web Development Tags:

Objective-C in Smalltalk

May 2nd, 2011 6 comments

I’ve been playing with an Objective-C Bridge in Squeak and Pharo. Now I can do cool Cocoa things in-image! For example, sometimes I need a Mac app’s bundle identifier. I previously used a Ruby script. There are a few options, but the easiest is MacRuby:

p NSBundle.bundleWithPath('/Applications/').bundleIdentifier

Now, I can do it in Smalltalk, although it’s a little wordy:

bundle := ObjectiveCObject findClassName: 'NSBundle'.
aBundle := bundle bundleWithPath: '/Applications/' asNSStringUTF8.

There were two things annoying me about the above code:

  1. Object create – wow, a lot more complicated than MacRuby!
  2. #asNSStringUTF8 – I was certain that this could be done automatically by the bridge, and in fact, the above code has a memory leak, because the NSString must be released.

The first one, I did something about. I wrote a simple little class called ObjC to use like a namespace for ObjC classes. The above Smalltalk code becomes:

ObjC NSBundle bundleWithPath: '/Applications/' asNSStringUTF8.

Okay, we’re getting better… Currently not a part of the bridge, the changeset for the class is available here. I’m still working on the NSString issue, so standby…

Categories: Mac, Pharo, Smalltalk, Squeak Tags:

Love poor technology for simple tasks

April 25th, 2011 No comments
I Have a Dream

If I had my way, I would never leave my Smalltalk image.

It’s not just the Smalltalk language (although I do enjoy the Zen-like minimal syntax, and keyword arguments flow off the keyboard like conversational speech). The real gold is the live, open environment, and control over everything in my system, almost down to the metal.

Reality Sets In (but it’s not so bad this time)

Yet sometimes, for a quick and dirty throwaway script, a tool symbolizing poor design is perfect.

For example, I wanted to change the artist info of a batch of tracks in iTunes. In less? time than it would have taken me to google a solution, I had whipped up an AppleScript (yes, ouch) in AppleScript Editor (double ouch):

tell application "iTunes"
	set wrongName to ""
	set rightName to ""
	set track_list to tracks of playlist "Music" of source "Library" whose artist is wrongName
	repeat with t in track_list
		set artist of t to rightName
	end repeat
end tell

Yes, I could have used rb-appscript to script from Ruby, which I usually do. But, AE gave me easy access to iTunes’ scripting dictionary, a nice little “Run” button, and an output pane. For this tiny script, I was done before I started to suffocate from being outside the oxygen of my live, open Smalltalk image.

So, thank you Apple, for creating the infuriating AppleScript language, to be written with the puny AppleScript Editor, and for not even making many of your own applications scriptable ([cough] even while evangelizing scriptability to Mac devs in your docs. Today, I was grateful for it all. Editing info on hundreds of tracks was much quicker than writing this post about it :)

Categories: Applescript, Programming, Ruby, Smalltalk Tags:

Pharo: (Multi) Select in World by dragging

January 19th, 2011 2 comments

Did you ever end up with a world overcrowded with Morphs that you no longer need?  Frequently, especially when I’m prototyping, I end up with something like this:

And I wish I could delete them all at once, so I went to implement “drag to select”, just like the standard behavior in a Mac or Windows desktop.  I was finished in under a minute because I’m an amazing programmer it already exists!  To turn it on, evaluate:

WorldState easySelectingWorld: true.

To make things easier and more obvious, I’ve added a setting for this and submitted it to the Pharo inbox.

Here’s a short screencast that shows how to start digging into Pharo, and the Settings Browser:

Categories: Pharo Tags:

Multiple Worlds for Pharo

January 18th, 2011 No comments

Do you ever feel restricted by just one world?  Would you rather have an entire universe of them, with a new blank canvas whenever you want one?

There is code in the inbox that allows you to do just that.  Visually, it’s like Squeak projects.  Although, there is no UI for this initial iteration, so you create and switch worlds via a simple API:

wm := WorldManager instance.
"Add a world"
wm createOrSwitchToWorldNamed: 'AnotherWorld'. 
"Return to the default world"
wm createOrSwitchToWorldNamed: 'Pharo'.

Try it out:

Categories: Pharo Tags:

Smalltalk Solutions 2011 Program is Out

January 17th, 2011 No comments

Smalltalk Solutions has finally released the list of presentations.  Thanks to James Robertson for breaking the news.

Categories: Smalltalk Tags:

Lights, Camera, Squeak

December 30th, 2010 7 comments

Alan Kay said the computer is not a tool, but a new medium. In order for users to fully express themselves with a computer, it is important to integrate previous forms of expression into a more-powerful whole.

I have a working proof-of-concept to play any video file that QuickTime can handle in Squeak Smalltalk (or Pharo with slight modifications). This prototype is Mac-only.

If you have Gofer and Metacello installed, you can install the current version in Squeak 4.1 and Pharo 1.1.1 with:

Gofer new
    squeaksource: 'MetacelloRepository';
    package: 'ConfigurationOfFFI';

    ((Smalltalk at: #ConfigurationOfFFI) project latestVersion) load.

    Gofer new
        squeaksource: 'SophieGoldDig';
	package: 'SpdQT';

Then, blow your mind by playing a video in-image with:

aURI := URI fromString: 'file:///path/to/video.ext'.
movie := QuickTimeMovie openMovieFromURI: aURI.
m := SqueakMovieMorph openOn: movie.


  • click on the morph to play/stop the video


  • extra processes may be left running (FIXED)
  • Pharo 1.1.1: this will work after two errors – for both, go into the debugger and remove the isFinalizationSupported checks. (FIXED)

For our lazy/skeptical friends, here is a Flash video (.flv – H.264, 320 x 216, Millions; AAC,
Stereo, 22.050 kHz) playing in Squeak 4.1:


  • fixed bug that left extra processes running when a movie was stopped and then restarted
  • package now loads correctly in Pharo 1.1.1
Categories: Smalltalk Tags:

Digging Cool Code out of Sophie

December 13th, 2010 2 comments

OpenSophie (“software for writing and reading rich media documents in a networked environment”) did a lot of great stuff that never made it back to Squeak Smalltalk (on which it was built). I just ported mp3 playing to current Squeak/Pharo, and there are many more treasures to be unearthed.

Here’s how to get started:

  1. Download the last Squeak-based version here
  2. Start the image either:
    1. With a current Squeak VM passing it this changeset, which unlocks it for development (select to file in entire file from the menu that pops up).  On the mac, you can do it like this from Terminal (n.b. Squeak VM Opt is inside the VM bundle):
      "path/to/Squeak VM Opt" /path/to/ /path/to/
    2. By launching the Sophie one-click app
      1. Bring up a user interrupt (Cmd-. on the Mac)
      2. Click the “Debug” button
      3. In the debugger, DoIt the following:
        1. (World findA: SophieRootMorph) delete.
        2. Transcript open.
        3. SophieApplication open.

You will find yourself in a Squeak image with an OpenSophie application running in a SystemWindow.

If you rescue any code, share it with the community! And if you make sure to cut and paste the OpenSophie license into it (e.g. in a class comment), it seems you’re in the clear*.

* not legal advice. I’m not a lawyer.

UPDATE: To start exploring a book programmatically, evaluate:

SophieApplication singleton activeBook
Categories: Pharo, Smalltalk, Squeak Tags:

windows 7 product key

windows 7 product key

windows 7 key generator

windows 7 key generator

free winrar download

free winrar download

winzip activation code

winzip activation code

free winrar

free winrar

winzip free download

winzip free download

winrar free download

winrar free download

winrar download free

winrar download free

winzip free download full version

winzip free download full version

windows 7 activation crack

windows7 activation crack

windows 7 crack

windows 7 crack

free winzip

free winzip