[91 total ]
Hacking Komodo for Drupal development

Today I gave a quick talk at the Pacific Northwest Drupal Summit, ostensibly called 'Hacking Komodo for Drupal development'. A better ( but less interesting? ) title might have been "here are a bunch of ways you can extend Komodo easily, with ... [More] Drupal-centric examples". I've attached a PDF of the slides and a zip files of the samples I showed.

As well, I just published a Drupal extension for Komodo ( well, the start of one ) on the ActiveState community site:

http://community.activestate.com/xpi/drupal-extension-komodo [Less]

Speaking at Pacific Northwest Drupal Summit

I'm very excited about attending and speaking at the Pacific Northwest Drupal Summit weekend after next in Seattle, particularly because I get to talk about using Komodo for Drupal development, something near and dear to my heart.

My talk ... [More] isn't just a plug for Komodo though, instead I'll be delving into all the ways you can hack Komodo to make working with Drupal and other frameworks easier and more productive. [Less]

Another cool Drupal / Komodo post

Fast on the heels of last week's Komodo / Acquia stack post by Robert Douglass, I just noticed a neat tip from Kevin Bridges on hooking up api.drupal.org in Komodo to do automatic lookups of the Drupal api docs based on your current selection:

http://kevinbridges.org/node/182

Debugging with Komodo and the Acquia stack

Robert Douglass, pre-eminent Drupal hacker and author, has a really nice blog post on the Acquia site about setting up Komodo IDE, Xdebug and their Acquia Drupal Stack ... [More] Installer:

http://acquia.com/blog/xdebug-komodo-and-acquia-drupal-stack-installer

I recently moved to running everything out of MacPorts instead of MAMP, but I do like how Acquia has packaged up a nice simple stack for people to get going on Drupal development.

I've been using OS X as my primary dev platform at work for 2 1/2 years, ever since I got an iMac. I have to say the LAMP development picture has gotten a lot rosier since 10.4 days. I'll shortly be moving back to Linux though, once my new monster dev machine arrives. [Less]

Komodo 5.2.0 has been released

Komodo 5.2.0 has been released, you can use Komodo's Check for Updates menu to launch the auto-update dialog and update your installed Komodo version, or alternatively you can download the Komodo 5.2 installer ... [More] from:
http://downloads.activestate.com/Komodo/releases/5.2.0/

The major changes for Komodo 5.2 are:

better performance and stability
customizable list of primary languages
easily view source of HTML pages
sub-language background colors
PHP 5.3 support
Ruby 1.9.1 debugging support (IDE)
SCC history search-ability (IDE)
dropped the Komodo Mac OS X powerpc builds

More information can be found in the Komodo online documentation:
http://docs.activestate.com/komodo/5.2/
and in the Komodo 5.2 features page:
http://community.activestate.com/komodo-52-features

If you run into any issues, please let us know through any ones of these channels:

bugzilla - http://bugs.activestate.com/enter_bug.cgi?product=komodo
email - http://listserv.activestate.com/mailman/listinfo/komodo-discuss
forums - http://community.activestate.com/products/Komodo

Cheers, Todd [Less]

Komodo 5.2.0 beta1 released

We've just released the first beta of Komodo 5.2.0:
http://downloads.activestate.com/Komodo/releases/5.2.0b1/

We've been busy making a bunch of changes to Komodo 5.2 in order to make Komodo a better, more stable and faster editing ... [More] machine. You can get an overview of the changes by visiting:
http://community.activestate.com/komodo-52-features

Try it out for yourself and let us know what you think.

Cheers,
Todd [Less]

SCP Extension for Komodo

I just noticed a new interesting extension for Komodo that may come in handy for people used to a Dreamweaver-like workflow ( ie working on a project locally and then uploading to a file server ... [More] ):

http://www.thewhyandthehow.com/scp-for-komodo-ide/

"The only frustration I’ve had is that Komodo doesn’t support basic integrated file uploading via SCP. While it is possible to save a file remotely, there is no simple way to save a file locally and upload it to a mapped location on a remote server from within the IDE."

I'll have to give it a spin when I get more time. [Less]

Creating the Fakework macro

If you're a decent programmer, you'll hopefully find this funny. If
you're a completely incompetent programmer, you may find this macro
useful or even essential.

My friend Gozer told
me about someone who had hacked up a tool to ... [More] make his conference
presentations run smoothly. Instead of typing in all the commands and
code in the demo and exposing his poor typing skills, he "pre-recorded"
the presentation. His script would play back the keystrokes, one
character at a time, with the pressing of any key. Random characters
in; blazingly fast, perfect code out.

Obviously others have had this idea too. I found Fake
Notepad which does the same kind of keystroke playback in a Windows
Notepad clone. "File > Open" allows you to choose a text file, but the
buffer stays blank until you start mashing keys.

But that application only works for text files, and even the
pointiest haired boss knows that developers don't use Notepad. That text
needs syntax highlighting! Enter the Fakework macro for Komodo.

In the Toolbox menu, click "Add > New Macro...". Give the macro a
cryptic name ("Fakework" is terribly incriminating), make sure
"Language:" is set to "JavaScript" and click "OK". We'll put some code
in there in a second, but we'll do it in an editor tab where we can get
some auto-completion for the Komodo
JavaScript API. Right click on your
new macro in the Toolbox and select "Edit Macro".

Adding and removing event listeners

First we'll need an event
listener, just like the one I mentioned in a previous
silly macro:

ko.views.manager.topView.addEventListener("keypress", fakework, true);

Now, for that previous macro, I created a separate macro for turning
the event listener off. The equivalent here would be:

ko.views.manager.topView.removeEventListener("keypress", fakework, true);

That's clunky. I've since learned how to do this a little more
sensibly. We'll make a function to turn off the listener, and run it
when the escape key is pressed:

normalMode = function () {
ko.views.manager.topView.removeEventListener("keypress", fakework, true);
}

Here's a stub for the fakework function:

fakework = function (event) {
if (event.keyCode == event.DOM_VK_ESCAPE) {
normalMode();
} else {
alert("No escape!");
}
}

Komodo can use DOM Level 3 events. If you want to use a different
key, choose one from the KeyEvent
interface.

Putting together what we have so far, here's the macro:

fakework = function (event) {
if (event.keyCode == event.DOM_VK_ESCAPE) {
normalMode();
} else {
alert("No escape!");
}
}

normalMode = function () {
ko.views.manager.topView.removeEventListener("keypress", fakework, true);
}

ko.views.manager.topView.addEventListener("keypress", fakework, true);

Inserting text, one character at a time

Let's put some dummy data in there for our fake work:

data = "Look! I'm working really, really hard!"

pos = 0 // current position in the string

... and add the magic in our function to insert it:

fakework = function (event) {
if (event.keyCode == event.DOM_VK_ESCAPE) {
normalMode();
} else {
event.stopPropagation(); // prevent propagation
event.preventDefault(); // stops us from inserting real text
var scimoz = ko.views.manager.currentView.scimoz;
scimoz.insertText(scimoz.currentPos, data[pos]); // insert fake text starting at position 0
scimoz.currentPos++ // increment the position in the buffer
pos++ // ... and the position in the fake text
}
}

Now, open an empty buffer, double-click on your macro, and start
hitting keys. The text in data should be inserted instead
of the actual keystrokes.

Getting data from a file

Now entering a corpus of fake work directly into the macro kind of
defeats the purpose of pretending to work. It would be much better to
take this information from a file, preferably some really gnarly,
impenetrable code written by a much better programmer.

I couldn't find anything in the Komodo JavaScript API for reading
files, and that often means it's something handled directly by Mozilla
(which Komodo is based on). A little Googling led me to a File
I/O article on MDC.
Sure enough, the "Creating an snIFile object" and "Reading from a file"
examples worked as expected:

var file = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("C:\\dev\gnarlycode.js");

var data = "";
var fstream = Components.classes["@mozilla.org/network/file-input-stream;1"].
createInstance(Components.interfaces.nsIFileInputStream);
var cstream = Components.classes["@mozilla.org/intl/converter-input-stream;1"].
createInstance(Components.interfaces.nsIConverterInputStream);
fstream.init(file, -1, 0, 0);
cstream.init(fstream, "UTF-8", 0, 0); // you can use another encoding here if you wish

let (str = {}) {
cstream.readString(-1, str); // read the whole file and put it in str.value
data = str.value;
}
cstream.close(); // this closes fstream

Replace the file.initWithPath() with your favorite l33t
bit of code and remove the placeholder data variable we put
in earlier. When we glue all the bits together we get something like
this:

var file = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("C:\\dev\gnarlycode.js");

var data = "";
var fstream = Components.classes["@mozilla.org/network/file-input-stream;1"].
createInstance(Components.interfaces.nsIFileInputStream);
var cstream = Components.classes["@mozilla.org/intl/converter-input-stream;1"].
createInstance(Components.interfaces.nsIConverterInputStream);
fstream.init(file, -1, 0, 0);
cstream.init(fstream, "UTF-8", 0, 0);

let (str = {}) {
cstream.readString(-1, str);
data = str.value;
}
cstream.close();

pos = 0;

fakework = function (event) {
if (event.keyCode == event.DOM_VK_ESCAPE) {
normalMode();
} else {
event.stopPropagation();
event.preventDefault();
var scimoz = ko.views.manager.currentView.scimoz;
scimoz.insertText(scimoz.currentPos, data[pos]);
scimoz.currentPos++
pos++
}
}

normalMode = function () {
ko.views.manager.topView.removeEventListener("keypress", fakework, true);
}

ko.views.manager.topView.addEventListener("keypress", fakework, true);

So the next time you spot your boss approaching in your rearview
monitor mirror, Alt-Tab into Komodo, hit your Fakework macro
keybinding, and blaze out some irrelevant, plagiarized, incredibly
impressive code. [Less]

Running Run Commands for Local Remote Debugging

The title is intentional. I'll explain later. Once you've started
abusing the language, you might as well kick it to the curb.

Once in a while, a question comes in to ActiveState support that
exposes a better way of doing something. ... [More] A user recently contacted us
about debugging Django applications, and I directed him to this
post by Todd Whiteman.

I suggested trying the second option mentioned: running the Django
server through pydbgp. The relevant command is basically:

$ /path-to-komodo-install/lib/support/dbgp/bin/pydbgp -d \
localhost:9000 manage.py runserver --noreload

Using the default Komodo paths on Windows, the command would end up
looking like this:

C:\Django\MyProject>python "Program Files\ActiveState Komodo IDE 5\lib\support\dbgp\bin\pydbgp.py" localhost:9000 manage.py runserver --noreload

Long enough for ya? This is assuming 'python' is on the system path
and that you're in the root directory of your Django project - so the
command could end up being longer still.

This user wondered, quite understandably, why he couldn't just start
the debugger using the "Go/Continue Debugging" or "Step In" buttons.
This isn't actually possible when debugging in frameworks like Django or
Rails, and the reason why involves clarifying something that is a little
murky to a lot of new Komodo users.

Local vs. Remote debugging

When you click "Go/Continue Debugging" or "Step In" in Komodo IDE,
you're doing "local" debugging. Komodo takes the current file and passes
it to the appropriate debugger for the language. Debugging starts in the
file you have open, and everything happens on the local machine.

What we call "remote debugging" involves initiating the debugging
session outside of Komodo, even if the debugger is running on the same
machine. This might seem counter-intuitive if your normal dev
environment has you running a web server on your local machine, but as
far as Komodo's debug listener is concerned, it's an external connection.

Remote debugging with any of the supported languages is a
little more complicated to set up, but it is extremely flexible and
allows you to debug web applications (and web framework
applications) while actually using them in a browser.

So, when you want to debug a framework application, running any one of
the files through the debugger independently is not going to tell you
much. In fact it probably won't run at all because it's not meant to be
run independently by the interpreter. We need to debug the application
in the context of the server it's running in, so we run the whole
framework server through the debugger.

Run commands

Since I've already copped to using the term "remote" ambiguously, I
can now confess to "nouning" the phrase "run command". Komodo's "Run
Commands..." feature allows you to run terminal/console commands without
having to jump to the command-line. Since you can save these commands in
toolboxes and projects, we needed a name for the commands in their saved
state so we could document the feature. In retrospect, we should have
called them "Saved Commands" or something else less confusing, but
somehow "Run Commands" stuck. Sorry about that.

Anyway, they're very good at solving problems like the one above,
because they can use interpolation
shortcuts - basically variables available within Komodo. We can use
these in the folloing alternative to the command above:

%(python) %(path:supportDir)\dbgp\bin\pydbgp.py -d \
%(debugger:port):%(debugger:address) manage.py runserver --noreload

Note especially the "%(debugger:port)" shortcut. Using this, you can
set the debugger connection preferences to use "a system-provided free
port". This gets around a known issue
where the operating system doesn't release the configured port
in a timely way after a terminated debugging session. The standard
work-around solution for this is to use the debugger
proxy, but this is much easier.

Right-click in your project or toolbox and "Add|New Command..." to
bring up the Run Command dialog box. Setting up the command above might
look something like this:

Under "Advanced Options" (click the More button to see them) you can
set "Start in:" to:

%D - the directory of the current file in the buffer (probably
not that useful in this case)
%p - the base directory of your project (i.e. where the .kpf
file is saved ). This should work if you are using a "live
project"
The full path to the app's base directory. This is probably the
most useful way to set it if you're not using a live
project.

You can choose to see the output to the Command Output Tab or open a
new console. You can also setup any environment variables you might
need; these are in addition to any system environment variables, and any
you may have set up globally in Komodo under "Preferences|Environment".

Once you've saved the command you can set a key binding for it,
and/or add it to a custom toolbar. After that, starting a "remote"
debugging session for your app is just a keystroke or click away. [Less]

Komodo and the Palm Pre?

There is some very interesting Komodo work going on in the Palm arena.

Austin (aka "Templarian") has put up a Komodo toolbox package to assist in development of Palm Pre applications:
http://webos.templarian.com/komodo/

Why ... [More] would they use Komodo?

Well, the Palm Pre uses a new web style operating system called webOS - the entire OS runs like a browser, using HTML for application UI and everything related to hardware is accessed using JavaScript through a framework called Mojo... and what is the best HTML/JavaScript application editor... Komodo of course!

So, what else is included in this toolbox package?

project templates - for creating a new palm app
shortcuts to easily launch the palm simulator
JS syntax checking of a complete Komodo palm project

Austin and the team are now also working on creating a Mojo API catalog to be used in Komodo, providing code completions for the webOS API.

Great work Austin! I think that webOS has huge potential, using the power of the web for applications in embedded devices is a fantastic idea. [Less]