Spidermonkey – Execute javascript from console

SpiderMonkey is the code-name for the Mozilla's C implementation of JavaScript. This is useful to test part of our JavaScript from the console or in scripts.
In Debian we have a package called spidermonkey-bin.
apt-get install spidermonkey-bin
After installing you will have a program called smjs.
If you start the program without parameters you will get a Javascript shell, in which you can write and test javascript.
$ /usr/bin/smjs js> function test() { print('test'); } js> test function test() { print("test"); } js> test(); test js> function test() { print('test'); test2(123); } js> function test2(param) { print ('test2: ' + param); } js> test(); test test2: 123 js>
To exit the shell, just press "Ctrl+D".
It's important to note that in spidermonkey you doesn't have the "document" Object. If you want to print out text, you cant use document.write, you should use print.
document.write('test'); // In browser print('test'); //spidermonkey
You can also make smjs to execute the content of a file.
Netbeans Performance Switches
I recently have began to use Netbeans because I'm sad that Eclipse is every time slower and it frozes every time when you are doing something to fast.
Netbeans is not perfect, and there are some features that need to be polished (Ex.: SVN Support, Time Tracking like Mylyn), but the PHP/HTML/CSS/JS Support is excellent, in my opinion better than the Eclipse PDF support.
These is my netbeans_default_options for Netbeans for MacOSX (under Windows you can leave out the --laf switch, it's for changing the look and feel):
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-Xmx512m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Xverify:none -J-XX:CompileThreshold=100 -XX:+CompressedOOPS -XX:+AggressiveOpts -XX:+TieredCompilation -XX:+DoEscapeAnalysis -XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true --laf javax.swing.plaf.metal.MetalLookAndFeel"
Some switches come from Netbeans Performance site.
- -J-Xss2m - Define Stack Size (Too small and you will get StackOverflow Exceptions)
CNET Mootools libraries
Mootools para mi es uno de los frameworks javascript que mas me gustan y que estoy utilizando bastante ultimamente. El otro dia estaba buscando unas librerias interesantes para Mootols y me tope con las CNET Libraries, que son unas librerias OpenSource compatibles con Mootools 1.2
Las librerias cuentan con una buena documentacion y ejemplos, estan divididas en varias categorias:
Entorno de desarrollo web con Eclipse
Ultimamente estoy mirando de encontrar el mejor entorno de desarollo multiplataforma que me vaya bien para llevar los proyectos de webs. Finalmente el que me ha convencido ha sido Eclipse con los plugins para PHP/HTML/CSS/Javascript y SVN:
- Aptana: HTML/CSS/Javascript. Update Site: http://update.aptana.com/update/
- PHPEclipse: PHP. Update Site: http://phpeclipse.sourceforge.net/update/releases/
- Subclipse: SVN. Update Site: http://subclipse.tigris.org/update_1.0.x
Lo unico que hace falta para instalarse todos los plugins, es bajarse el ultimo Eclipse e ir a "Help->Software Updates->Find and install..." y añadir los "Update Site" de cada uno bajo "Search for new features to install".
Abrir links en nuevas ventanas en XHTML 1.0 Strict
Siguiendo con los problemas de ceñirse al XHTML 1.0 Strict me he encontrado que en la etiqueta <a> ya no existe la propiedad target por lo tanto para abrir links en paginas nuevas es algo que se hace dificil. Pero googleando me encontre con esta solucion.
function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "_blank";
}
}
window.onload = externalLinks;
Y luego lo unico que hay que hacer es usar rel="external" en todos los links que se quieran abrir en ventanas nuevas



