Give-away: Tillsammans on VHS

On my bookshelf, I noticed a VHS cassette, the Swedish comedy Tillsammans (2000) by Lukas Moodysson (director of Fucking Åmål). Great movie, but I need the shelf space. I bought it new on VHS for some reason, not owning a VHS player. Nor a TV. So, the cassette is still wrapped in plastic, never used.

If you come and pick it up, you can have it! Free, gratis, at no charge. Just comment here, and we’ll email, and set it up.

I guess I could drop by at the local thrift shop, and have them circulate the media. But you don’t frequent that shop, do you? And I’d like you to have it, should you want it.

(At the previous Ruby programming meetup in Copenhagen, I brought a book for a friend. When I took it from the shelf, I noticed another book I could give away, and brought it to the meetup. I told the congregated hackers about the book, and plopped it on a table. At the end of the meeting, the book had been swooped up by a reader.

I thought that way about some of my programming books, too. Some of them really are “one-use”, even if they try to masquerade as reference materials.)

Io gets Ruby-style string interpolation

Io

This is nice for people who come to Io from Ruby: Io, the language, now has…

a C implementation of interpolate (by trevor with help from jer)

Just to give people a heads-up on this point. There is a slight
change in behaviour. Instead of using #io{...} to interpolate your
code, you now use #{...}. As well, instead of the string being
returned being mutable, it is now immutable.

Which is in the new tarball release.

Update: Whoops! You need to send an interpolate message to get the interpolation. Not like in Ruby, where it’s automatic. Thanks Jeremy Tregunna, for correcting! And for stopping by.

CakePHP: grab only the data you need

When dealing with an abstraction that outputs dynamic SQL “behind your back”, it’s often easy to forget that some of the queries are… too greedy and grab unneeded data. Here is how to ask for less data, using CakePHP.

Today, I listed only name and id fields of a Model, and to restrict the findAll() to those things:

`$data = $this->Thing->findAll( aa("Thing.user_id", $user_id), a("id", "name"), null, null, null, -1 );`

Breaking down the call, we have:

aa() is a CakePHP convenience function to make an associative array. Odd parameters are keys, even params values. The parameters here creates a WHERE clause that matches the current user’s Things.

a() does the same for regular arrays. The params list the two fields we need returned.

A couple of null settings, and then the crucial -1, which turns off the Model associations completely.

Grab less data!

Update: here is how to use unbindModel. First take a look at the Thing model definition, courtesy of Mladen Mihajlovic:


 array(
      ‘className’ => ‘AnotherThing’
    ),
    ‘SomeOtherThing’ => array(
      ‘className’ => ‘SomeOtherThing’
    ),
    ‘YetAnotherThing’ => array(
      ‘className’ => ‘YetAnotherThing’
    )
  );
}
?>

Now, in our controller, before calling findAll, we remove two of the associated Models:


$this->Thing->unbindModel( array( "hasMany" => array( "AnotherThing", "SomeOtherThing" ) ) );

[tags]cakephp[/tags]

Copenhagen.rb meeting notes

Update: photos by Pelle.

Syndication with AtomPub, APP and GData… and Rails

Olle Jonsson “explores” some things you would want to do with Atom… and how Rails enables you to do it.

Update: My somewhat confused slides now available (PDF).

DHH on ActiveResource

…and then I got lucky, and David was able to give us “how to do all this painlessly in Rails.”

David HH presented the new ActiveResource stuff. Edge, plugins. “Undecided”, still, about if it’ll be in the standard distribution.

Suffix the URL with .xml (or any format your app responds_to!)

GET /posts/1.xml
POST /posts/1.xml {POST payload}

Clarifiction: The last line there, the POST payload, is not a Ruby block, it is what you send as the body of the HTTP request.

We saw the MIME-type format list that Rails’ ActiveResource can output. I missed the JSON format, mentioned it, and David showed how it would be simple to add JSON support to ActiveResource.

Let us cook that up! And David showed:

  • Register a new JSON mime-type
  • respond_to {} the :json, and spit that out
  • make .to_json()

There must be a plugin for this. And there is, we were informed.

Don’t Trust Yourself with Your Users’ Data

Pelle B. tells it like it is, and provides a plugin called EzCrypto. Short, simple presentation, very good. And also, notes on a couple of new developments from the productive programmer: secret URLs as a plugin.

JRuby at a glance

Teaser-like presentation (‘Part I’) by Morten Ch. from Aarhus.

[tags]ruby,rubyonrails,copenhagenrb,event[/tags]

David Black on Ruby and Rails, in Malmo: a post-game

I will try to summarize my Malmo experience in the company of 20 new and old Railsers and presenter David Black. Our kind host Polar Rose had got a very central location for the event, a short hike from the train station. David did a good job of telling an understandable story about Ruby on Rails development. The theme for the session was about getting a fly-over of Rails, and to get one’s hands dirty, making a Rails application. In the later part of the day, a couple of advanced techniques, like AJAX with RJS templates were also touched on.

He began his talk by showing how Ruby works: what parts are syntactic sugar, and what really happens in the background. How methods are found in mix-ins, and how to open classes and modules.

With that out of the way, he could begin making a Rails app. I suggested that he use for his example an app that I later built, “Our House”. (List info about the neighbours you have.) David took that up, and used that example for a couple of things, but in the pair programming part of the workshop, me and the guy next to me made that app.

He was a cool guy from Oslo, Norway. A Schemer. And I promptly forgot his name.

We were given sandwich lunch, which was great. I had to be the pragmatic vegan, and eat the lacto-vegetarian sandwich, but at that point I was so hungry I could eat sawdust. Great food, and I got to hear some Norwegian war stories. Big Norwegian telco Telenor is run by a Lisp application!

Our pairing experience was made more intense (and Open Source-like) by using a Subversion repository, and working on different parts of the app in parallel.

I got stuck on an update action, and I stumbled around for a while. Got it fixed on the train home.

During the first hour, I got a back-channel set up, #davidblackmalmo at irc.freenode.net. But alas, not all participants were able to use the wifi, so I wasn’t able to tell everyone about it. The activity mainly consisted of me yakking about parallels to the Io programming language. I’ll be in that channel today, if someone would like to exchange pleasantries.

When we quit our session at 1800 hours (after 8 hours of concentration!) we were all pretty beat. So I forgot to get names and contact information of the great folks I met there. Like “Mr. blonde longhair with the deep bass voice” who was a sharp-eyed syntax man and well-versed Railser. And my Schemer friend from Oslo. And those that were from Copenhagen, who should show up at Copenhagen.rb meetings.

A great starter for the beginner. Our crowd was mixed, though, with fragments of the group being Ruby and Rails geeks, steeped in the dark arts, while others had other developments backgrounds. This meant that dwelling on an interesting detail, such as “how Ruby finds methods” was not the order of the day. (The Rails Edge, that would be the right venue. Got to get them over to Scandinavia.)

I guess we’ll have to have shorter, more focussed workshoppy stuff in Copenhagen Ruby Brigade, another day. I love the format.

Calling an XML-RPC method (PHP, Ruby)

Calling web services. Great fun when it works. Thanks to XML-RPC’s simplicity, it’s quite easy to cobble together a working client. Here is me using the Technorati “ping” service, which tells them about the Copenhagen Ruby Brigade’s weblog being updated. And then, prints the result.

My PHP take on this looks klutzy. But the request gets encoded smartly. cURL takes a lot parameters to get running. I write the appropriate headers myself, there.

Simple XML-RPC in PHP

In Ruby’s standard library, there is a library to do these things. Exciting.

Even simpler XML-RPC in Ruby

[tags]technorati,xmlrpc,ruby,php,curl[/tags]

List of local geek communities (work-in-progress)

I talked with a local PHP developer today, who’d seen my blog, and we talked some CakePHP, frameworks, servers, the general state of scripting languages, and so forth. And then we came to the subject of local communities, where developers meet up and talk shop.

And, as a Copenhagener, I don’t know very much about that. There are these two that I know of:

Is there a PHP club? A Perl club? What other communities for developers have meetings in the Copenhagen area? Are you a member? Are these communities active? Please tell about it here.

How to support the Danish National Homeless Soccer Team

These guys need a 125 000 DKK to go to South Africa and represent Denmark. This is how to support the National Homeless Soccer Team:

  • SMS the word BOLD to 1277, and you send them 50 DKK (exception: Tele2 customers)
  • Send their Danish bank an amount: 9541-101 61 908
  • Buy a sponsorship at 20 000 DKK and get an original drawing with the players’ signatures

The collection closes September 23. The team leaves for South Africa September 19.

Also: If you know how to put an interesting street paper on homeless issues on the streets of Copenhagen, there is an editorial job opening at Hus Forbi. See Hus Forbi, under the heading “Job”. (In Danish.)