Showing posts with label cross platform. Show all posts
Showing posts with label cross platform. Show all posts

Sunday, 6 January 2008

Moonshine core interpreter


xkcd rockband


Today I will show you a demonstration of the Mooshine core interpreter running two different Lua programs which utilise the Firefox browser.

The first program as outlined below tests the standard module:


-------------------------------
-- test standard module
-------------------------------
print("\n" .. std.version() .. "\n") -- print version
std.msg("Hello from Moonshine!") -- display message
local ans = std.prompt("Enter number:") -- display prompt

It does the following...

  1. Prints the version of the standard module in the interpreter

  2. Displays a message box in the browser

  3. Displays a prompt for user input


The second program retrieves the latest XKCD comic panel (a example of which is in this post) from the XKCD atom feed and displays it in a new browser window...

----------------------------------
-- display latest xkcd web
-- comic from the xkcd atom feed
-- in a new browser window
----------------------------------
-- make a request for xkcd comic feed
feed = net.httpreq("http://xkcd.com/atom.xml")
-- match comic panel
img = string.match(feed,
"http\:\/\/imgs.xkcd.com\/comics\/[%w%_]+.png")
-- display comic panel in a new window
std.window(img)

The current version of the Moonshine core interpreter is an executable written in C with embedded Lua. Most of the functionality itself comes from the included modules.

To properly work as part of my extension, I will rewrite the core intepreter in C++ as an XPCOM component (which use classes).


See the demonstration (animated GIF)

Image courtesy of xkcd (CC-BY-NC)

Digg This Story

Monday, 15 October 2007

Digg API on AIR

Digg API on AIR

Larger screenshot on Flickr.

Hey, everyone. I do have a programming related post today.

I have been coding in JavaScript, XML/HTML and CSS to create the above simple Digg API AIR application, which retrieves the top (e.g. newest) story for each category on Digg.

I have as good as finished it and will be releasing the AIR installation package (*.air) and source code (*.zip) for anyone who is interested in the AIR platform to look at.

Although I could have done an XmlHttp request without any additional framework, I did use the Prototype JavaScript framework for this project.


Here is a quick rundown of the files used in my application and their purpose:


DiggAPI.xml - This is the file which specifies the name, copyright information and file to use for content, etc. An XML file such as this is a standard requirement in any AIR application.


DiggAPI.html - The application content. This contains all of the HTML code for my application and calls to the neccessary JavaScript functions in my external *.js files.


sampleCert.pfx - The certificate used to sign the AIR application. All AIR applications must be signed to be built, even if not by a recognised body such as VeriSign.


script/AIRAliases.js - JavaScript file containing code used by the AIR runtime. Referencing this file provides convenient aliases for use in your code. Included with AIR SDK.


script/prototype.js - JavaScript file containing code for the Prototype framework. I used the cross-browser new Ajax.request provided by Prototype in my application.


script/DiggAPI.js - JavaScript file containing my code used by the application.


style/DiggAPI.css - Style sheet used to format my links and text colours, etc in my application.


style/digg.png - Digg guy logo image used in my application.


Check back soon for included AIR package and source code. Happy coding. :)



Digg This Story

Tuesday, 2 October 2007

Adobe AIR

helloworld application for AIR
Today I decided to check out Adobe AIR.
AIR (Adobe Integrated Runtime) is a runtime platform / environment which allows the creation of desktop applications which use existing web technologies such as HTML and AJAX.
Since it is Adobe, unsurprisingly, it also has support for Flash.

To develop an AIR application, all you need is the AIR SDK (which is freely available from Adobe Labs) and your exisiting development tools. E.g. your text editor for your code.

Following the tutorial for developing for AIR with HTML and AJAX, I coded the customary Hello World application.

The tutorial, you follow for its output is complicated. But I think this is due to the demonstration of how a more complex AIR application should be coded. E.g. You use an XmlHttpRequest to display the message to the user.

Development of the AIR application was quite straightforward, so maybe I'll develop something which uses the Digg or YouTube APIs in it.

Digg This Story