My JavaScript book is out! Don't miss the opportunity to upgrade your beginner or average dev skills.
Showing posts with label console. Show all posts
Showing posts with label console. Show all posts

Tuesday, October 05, 2010

JavaScriptCore via Terminal

Just a quick one, maybe only for a new Mac comer as I am, I found truly annoying I have already Python, Ruby, and even PHP everywhere available in my command line but not JavaScript?

What The Fuck

Even Windows runs .js files natively and since ages, I wonder why on earth after I have downlaoded the whole XCode SDK "my JavaScript" was not there available for all my needs.

OK, OK, node.js is already on /bin, linked and working properly, but now I have the system default JavaScript Engine that comes automatically with WebKit or the "IE for Mac" aka Safari.

How to link jsc to bin folder

A title that produces zero outcome on Google, could be hopefully better addressed via this blog, and this is how I have solved:

sudo ln -F /System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Resources/jsc /usr/bin

The Current folde ris the link to the latest one, all those threads about the ..../A/... folder are not automatically updated if A becomes B, as example.
So, now I can type jsc wherever I am and use JavaScript power whenever I want, writing just quit() anytime I need.
I hope this helps, it took a while for me to sort it out.

Thursday, September 10, 2009

Formaldehyde JS - The Circle Is Close

As announced in Ajaxian, I have created Formaldehyde JS with exactly the same Zero Config logic.

We put this file before everything else and that's it, Formaldehyde will automatically decide how to show errors in a wide range of browsers:
  • Chrome
  • Firefox
  • Internet Explorer 5, 5.5, 6, 7, 8 with or whout console
  • Opera
  • Safari

Logs will naturally degrade until the most primitive alert but hey, Formaldehyde is for debug and development environments, not for production.

Enjoy ;)

Thursday, September 03, 2009

JScript Console - A Simple One

After I've read Ajaxian post about JavaScript as a command line scripting language I thought it could be interesting to know how to create the first Windows console.

The console.js File


function print(text){
WScript.StdOut.WriteLine(text);
};
function quit(){
WScript.quit(1);
};
while(!WScript.StdIn.AtEndOfStream){
try{
eval(WScript.StdIn.ReadLine());
}catch(e){
print(e.message);
};
};
WScript.StdOut.WriteLine("bye!" + "\r\n");


The console.bat Launcher


@echo off
cscript console.js

A double click in latter file, and that's it, the most basic native JScript console ever has landed in your PCs - enjoy :)