Nested Marionette Behaviors

Today I was having trouble with Nested Behaviors in Marionette 2.4.2.

The trouble was, how do I get options into my behaviors in behaviors?

Here is my situation:

view.js:

  View.Main = Marionette.ItemView.extend({
  ...
  behaviors: {
    // named so the sub behavior can access this!
    behaviorName: {
      data: 'someData',
      behaviorClass: BehaviorName,
    }
  }
  ...
});

Then inside of that Behavior:

BehaviorName.js:


...
// Note: using the unnamed array method to describe behaviors here, which came in as of 2.4.1
behaviors: [{
behaviorClass: NestedBehaviorName,
}],
...

So the problem then, is how do I get these the options from the parent into this sub behavior?

Here is what I ended up with:

NestedBehaviorName.js

  ... 
  initialize: function() {
    if (this.view.behaviors.BehaviorName) {
      _.extend(this.options, _.pick(this.view.behaviors.BehaviorName, ['data']));
    }
  },
  ...

Some recent spam

I got some spam recently, but they must have failed to parse their email correctly, so it came out raw, it is a little bit interesting. Though it was very long, here is a small snippet:

{
{I have|I’ve} been {surfing|browsing} online
more than {three|3|2|4} hours today, yet
I never found any interesting article like yours.

{It’s|It is} pretty worth enough for me. {In my opinion|Personally|In my view}, if
all {webmasters|site owners|website owners|web owners} and
bloggers made good content as you did, the {internet|net|web} will be {much more|a lot more} useful than ever before.|
I {couldn’t|could not} {resist|refrain from} commenting.
{Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I’ll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch} your {rss|rss feed} as I {can not|can’t} {in finding|find|to find} your {email|e-mail} subscription {link|hyperlink}
or {newsletter|e-newsletter} service. Do {you have|you’ve} any?
{Please|Kindly} {allow|permit|let} me {realize|recognize|understand|recognise|know} {so
that|in order that} I {may just|may|could} subscribe.
Thanks.|
{It is|It’s} {appropriate|perfect|the best} time to make some plans for
the future and {it is|it’s} time to be happy. {I have|I’ve} read this post and if I could I {want
to|wish to|desire to} suggest you {few|some} interesting things or {advice|suggestions|tips}.
{Perhaps|Maybe} you {could|can} write next articles referring
to this article. I {want to|wish to|desire to} read {more|even more} things about it!|
{It is|It’s} {appropriate|perfect|the best} time to make {a few|some} plans for
{the future|the longer term|the long run} and {it is|it’s} time to be happy.
{I have|I’ve} {read|learn} this {post|submit|publish|put up} and if I {may just|may|could}
I {want to|wish to|desire to} {suggest|recommend|counsel} you {few|some} {interesting|fascinating|attention-grabbing} {things|issues} or {advice|suggestions|tips}.
{Perhaps|Maybe} you {could|can} write {next|subsequent} articles {relating to|referring to|regarding} this article.

Hope you get the {problem|issue} {solved|resolved|fixed} soon. {Kudos|Cheers|Many thanks|Thanks}|
This is a topic {that is|that’s|which is} {close to|near to} my heart…

Caps lock

Was ranting to grg today about how capslock is the worst key ever invented on a keyboard and how no one has ever used it ever.

Then I googled it, and found some other people agree: http://capsoff.org/history

Nice to know.

… the Caps Lock key has been little used, with some people claiming they use it deliberately only once or twice per year.

Publishing a Yeoman generator and its sub generators.

So I have a Yeoman generator that helps scaffold a Backbone.Marionette application using the module paradigm, which is all good.

Though I did get a little caught out when publishing the sub-generator component of it.

That is so you can do things like yo marionette-modules:module aSubModule, to get a module generated.

The :module part was not being registered in the Yeoman package when running yo --help.

The solution in the end is to add all folders you want to deploy into package.json before you publish eg:

“files”: [
“app”,
“module”
],

Changing to access Github via SSH instead of HTTPS

Recently I finally got around to adding my public key into my Github account, as described here

But then there is one more step you have to do to your already existing checked out projects to get them to use this. That is update the origin to use SSH and not HTTPS.

So cd to your project and run something like:

git remote set-url origin git@github.com:USER/PROJECTNAME.git

In Nelson

Arrived in NZ last week. Spent a few days slowly working my way down the country, stopping off at friends and family on the way.

Have made it to George’s house at long last.

This is what we have been making for the last few days: http://www.games.rekarnar.com/

Anyways, in Nelson now.. starting a new stage. Fun.

Deploying Symfony2 on Dreamhost

There is a few things I had trouble with getting Symfony2 to work on Dreamhost shared hosting. All in all it was quite a mission. So here are some of my steps to help for next time.

We would like to use PHP 5.4. But default the PHP Cli is 5.2. So some changes are required.

Note: Also make sure your domain is set to PHP 5.4 in the Dreamhost Panel.

Step 1:
First we need to enable the custom php.ini, since we also need to add in some extensions for Symfony2. More info here

So to enable PHP 5.4 for all sites, create this folder:
mkdir -p ~/.php/5.4

Step 2:

Then in your .bash_profile in your home folder, add:
export PATH=/usr/local/php54/bin:$PATH
So we are always set with the right version.

Step 3:

Run all the code from the first Gist in your home folder. This will compile the APC extension:

Then open this file and add in the config from the second window above:
vi ~/.php/5.4/phprc

(this enables the required extensions and links the apc module we just made)

Step 4:

From now we we should be set. You can test by running:
$ which php
hopefully it says something like: /usr/local/php54/bin/php

Step 5:

Make sure we have composer:
curl -sS https://getcomposer.org/installer | php

Step 6:

We also need to add in Icu to our require field in composer.json since the Intl Apache module at Dreamhost is a little old. As noted here
"symfony/Icu": "1.1.*"

Step 7:

Next update your project to include that:
php ../composer.phar update --no-dev -o

Step 8:
Perhaps you can do a little dance or something if everything went well. But please celebrate any way you feel appropriate.