Category: open source

rss

JsBehaviour 1.0 released

This is a tiny library I have been using to create inline dynamic effects at docsforit without inline javascript. Since it is not spludo (serverside javascript mvc framework) specific and works as long as mootools is available, I release it for the public today.

How does it work?

The idea behind JsBehaviour is pretty simple. Put a class (jsb_) on all elements which should be enriched/enhanced by javascript. Additionally put a class jsb_keyword on the element to define which behaviour should be applied to the element.

Each behaviour can register on such keyword by using this

1
JsBehaviourToolkit.registerHandler('keyword', KeywordBehaviour);

method. As soon as the dom is loaded

1
JsBehaviourToolkit.applyBehaviour(window.document);

is executed. You might even overwrite your Request.HTML method to do the same.

Hope you enjoy to work and tweak this little piece of MIT-licensed software.

Download @ DracoBlue.net and js-behaviour@dracoblue.

Demo + Spludo-Integration at "Editing the sections" on docsforit (double click on the content, this is all done by using JsBehaviour!!).

In open source, JavaScript, Mootools, Spludo & JsBehaviour By DracoBlue @ 23:42 06.07.2010

Hot reload for node.js servers on code change

If you are working with node.JS, you may experience the need to restart the node server as soon as a file has changed.

There are plenty approaches for this field. One is, to parse for all require statements in the code and watch those files then.

I took a different approach, which could be described by this linux command:

1
$ find . | grep "\.js$"

It searches for all .js files in the folder and restarts the server, as soon as one of those changed. Very easy, but yet powerful.

To use it, just copy: run_dev_server.js into your server directory.

This script expects your server script to be called run_server.js. If you want to change it, just change the line.

Instead of running your server with

1
$ node run_server.js

you now start it with:

1
$ node run_dev_server.js

That's it!

This feature is of course part of the spludo framework's 1.0-dev version. In spludo, you can use

1
$ bash run_dev_server.bash

instead of

1
$ node run_server.js

to achieve a hot reload on each .js change.

Update 2010/08/27: Wilkerlucio created a version for hot reloading coffee-scripts.

In open source, JavaScript & node.JS By DracoBlue @ 23:08 04.07.2010

Connecting to a VirtualBox Guest Machine

Today I was setting up some test machines running a minimal debian installation.

Since it's not that handy to work always in the virtualbox window, I tried to connect to them by using ssh.

In the debian machine I typed:

1
2
$ su
$ apt-get install openssh-server

And tried to connect to the machine. It did not work.

I found plenty instructions how to fix ports and stuff with host-only-networks, but figured out, this is not what I was searching for!

The reason was, that virtualbox's default network mode is NAT.

I changed it to "network bridge". After that a restart of the machine did the trick, my router gave a proper IP to the guest debian.

In open source & VirtualBox By DracoBlue @ 18:22 02.07.2010

DJson 1.6.2 released

Today I have an important little bugfix release for djson available.

The issue was, that reading a value after an invalid set, breaks the reading. Thus, if you did a djInt on a value, which does not exist, any later dj call does not work. Thanks to Raphinity for reporting the issue.

Zamaroht reported a strange issue, when setting a value between two append-operations. This was due to a problem with the caching algorithm and has been resolved! Thanks Zamaroht for the report!

Another problem occurred, when you tried to write a string containing " (quotation marks). Those are escaped now properly, too.

These issue are of course fixed with the latest version djson 1.6.2 download.

In open source, pawn & DJson By DracoBlue @ 11:36 08.05.2010

Enhanced API Browser for node.JS

Today I created a little (~450loc) extension for the official node.JS api page. It's a client side Live-Search: filters over content and navigation as you type.

http://dracoblue.net/showcase/enhanced-node-api/enhanced-node-api-preview.png
Feel free to try it out at http://dracoblue.net/showcase/enhanced-node-api/.

This is made 100% javascript (with jquery) and does not change the api.html at all.

Source is available at enhanced-node-api@github.

Comments appriciated!

In open source, JavaScript, node.JS & jQuery By DracoBlue @ 12:53 24.04.2010

Chain + Group Callbacks for NodeJS

If one develops with Node.JS and wants to use the full event-loop power, you got to use callbacks for everything.

That said, it looks ugly to do that:

1
2
3
4
5
posix.rename("/tmp/hello", "/tmp/world").addCallback(function () {
posix.stat("/etc/passwd").addCallback(function (stats) {
sys.puts("stats: " + JSON.stringify(stats));
});
});

The api advices to use:

1
2
3
posix.rename("/tmp/hello", "/tmp/world").wait();
var stats = posix.stat("/etc/passwd").wait();
sys.puts("stats: " + JSON.stringify(stats));

but this is a problem, too. Why? Because you can't do that too often (just ~10 times) at the same time.

That's why I created two little helper methods: chain and group.

In open source, JavaScript & node.JS By DracoBlue @ 21:38 17.02.2010