Buca Bay - Always nice

Dua tiko noqu toa loaloa, na yacana ko… laga mai…

Joana’s art

June26

Today we had a real surprise. I come into the computer room, and find legible drawings on two pieces of old A4 paper lying on the floor.

Joana has always liked to draw and paint. She just finished her Mom’s set of watercolor paints a week ago, and now has turned to a new set of crayons and colored pencils we got her a few days ago. However, all her drawings are just scribbles, or blotches of paint. She’s been getting better at filling all the white spaces on the paper with paint, but that was about it.

So, I’m staring at the two pieces of paper wondering who could have drawn the figures on them. Not a 2 year old that was drawing scribbles the day before.

I pick the two pieces of paper up, still puzzled and amused, and take it over to my brother Ben who is in high school. “Did you do this?”. His reply, “Mmmmm no…”. I take it over to Joana’s Nau (Grandma), “No”, same answer. Joana’s Mommy? “Nope…”. Now were all staring at the drawings…

Joana picks up a crayon, starts making lil’ spirals, all the while chuckling at the cartoon she’s watching. I ask, “Joana, whats that?”.

“Car…”


posted under general | 2 Comments »

PHP Object Cache

June25

The last two days I’ve been writing an Object cache in PHP as part of a larger project. I released it today as open source so it will help those doing something similar and get some that helpful feedback open source offers.

PHP Object Cache is a Memory Object cache, implemented with PHP Sockets. It runs on PHP4 or PHP5+ and requires your PHP build to have sockets enabled.

The project is a web (browser) based chat system called Joomla Ajax Chat. The initial development of the chat was 3 and a half years ago, so many of what worked then (HTTP Polling and AJAX) is becoming old school now and not as efficient as what is possible with browsers today.

One of the new features is implementing comet like HTTP, which essentially means keeping the HTTP connection open for as long as you can. XMPP defined a specification for this called BOSH for their Instant Messaging Protocol to work over HTTP. With a good implementation, Comet can be very efficient.

Our problem is that we have to implement Comet on regular ol’ Apache, Lighty, Nginx, IIS servers running different versions and builds of PHP. The code will have to run on the average shared hosting, dedicated servers to cloud based solutions. The other problem is it has to run on top of Joomla, and other CMSs. A call to a minimal Joomla page alone, is around 5-6 database reads and one or two writes and about 5-6Mb of ram. It wouldn’t take much to crash a shared hosting account trying to implement comet on top of that.

So the solution would have to be an object cache of some sort, even if it means a file based cache (last resort). Thus, PHP Object Cache, which hopefully will work for the percentage of shared server that allow sockets. The idea it to take the most intensive IO processes, such as session management, chat events and put them into the Object cache. When everyone online has viewed what they need from the cache, flush that bit to the database or some other persistent storage if needed.

Since the browser is able to do more as time goes on, hopefully php on old shared servers can keep up.

Backup and export Appjet Applications

June10

Appjet recently anounced that they are closing down. They however offer an open source download that allows you to run the appjet engine on your own server.

JGate has gone to the intiative of cloning the Appjet service. This allows you to transfer your apps from Appjet to JGate, including your storage and libraries.

Backup your Appjet Applications

For those needing to backup your applications, I’ve written a backup application that will take all your published applications and create a single compressed download in Zip or Gzip format.

http://export.appjet.net/

This app is actually cloned from two other apps. It has to contact a PHP server on the background in order to create the compressed files. I couldn’t find any JavaScript implementations of ZIP and Gzip readily available.

Using the Application is simple, just input your username and click on “backup my apps” and it will prompt a download after a few seconds.

Export your Appjet Storage

To export your storage you need to import an Appjet Library.

http://lib-export.appjet.net/
http://apps.jgate.de/lib-export

This library exists both on Appjet and JGate, and if you are hosting your own Appjet server then you need to include that library.

Here are the steps to export your appjet storage:

  • Import lib-export into both apps ie: import(’lib-export’);
  • Show the Admin Panel. On appjet.net, you can do this via the preview window. In JGate y ou need to include showExportAdminPanel(); after your import command and view the app in regular mode.
  • First set a password on both apps.
  • Then in the app you want to export from, turn off the admin panel. ie: remove the line showExportAdminPanel();
  • In the app you want to import to, click on the “import” link in the admin panel.
  • Fill in the details, make sure the URL does not include a trailing slash. eg: http://example-app.appjet.net
  • Submit the form.
You can also view the JSON representation of your root storage object (storage) by going to the URL: http://appname.appjet.net/export?password=mypass where appname and mypass are substituted for your own.

Other uses of lib-export:

If you’re interested in how it works, check out the source for lib-export.
Since appjet uses object storage instead of a traditional relational database, you can serialize the storage Objects into regular objects, and then into JSON, for export.
You can also do the opposite and unserialize JSON into native JavaScript Objects, and native JavaScript objects into Appjet storage Objects. (StorageObject and StorableCollection instances).
This can be useful if you want to storage random JavaScript Objects without knowing their type. It should even store your custom JavaScript instances, though I haven’t tried it.
eg: storing native and custom Objects
import('storage');
import('lib-export');
// native object
storage.date = storablelizeObjects(new Date());
function MyCustomObject() {
   this.name = 'my custom object';
}
// custom object
storage.customObj = storablelizeObjects(new MyCustomObject());
eg: storing Arrays
import('storage');
import('lib-export');
storage.myArray = storablelizeObjects(['hi', 'bye']);
eg: Store anything
import('storage');
import('lib-export');
storage.myArray = storablelizeObjects({
   'myarr': ['hi', 'bye', {"another object": "value"}],
   'myObj': new MyCustomObject(),
   'date': new Date(),
   'url': wget('http://example.com')
});
Convert Storage Object to native Objects
import('storage');
import('lib-export');
var myObj = objectizeStorables(storage.myObj);
Export your Storage Objects as JSON
import('storage');
import('lib-export');
var myObj_str = serializeStorables(storage.myObj);
Note that properties resolved from Object.prototype is not stored. Obviously, using StorableCollection() and StorableObject() will be faster then casting native Objects to Storables using lib-export, though the latter is more convenient for storing objects of unknown types.

Notes

The library lib-export is provided without any guarantees. Please do not use it if you do not take full responsibility for any outcome. ie: It works for me, but I cannot guarantee that it will work for your app.
Please note that the export lib is still in development, so there may be some changes to it which I will document here.

Appjet service ends

June2

Appjet, a web based javascript application development platform, sent out an email to members today that they are closing down the service.

According to the email, they are closing their Appjet service because of the success of Etherpad - which is a real time document collaboration service that they built on Appjet. I think what they really mean is, appjet isn’t making any money and has become a liability. In that case, they just didn’t find a good way to capitalize on what they have, because it is quite awesome.

Appjet has been the only server side JavaScript development platform that offered a web based editor so you could create applications with just a connection to the internet, nothing else. There are many server side JavaScript alternatives, and many JavaScript Application development Platforms, none had the simplicity Appjet had. Nor is there a platform that encourages the sharing of libraries amongst developers like Appjet.

I have quite a few applications running on Appjet. One the fetches updates from freelance sites and posts it to a twitter account, freelance_jobs. Another pings websites and keeps a log of their uptime.Yet another acts as a proxy allowing RSS feeds to be fetched cross domain as a JSON callback. Theres even one that allows to to cheat at facebook’s wordtwist game by guessing all the possible combinations of words available for that round. There’s more then 10 of these apps I wrote and they were all hosted freely by Appjet. These were all developed in my spare time and at first I thought of them only as fun apps, but a few of them have become quite useful.

Now comes the porting of these apps to a new location. The great thing is that the appjet engine is available for download.

I’m considering installing this on my own server, or just rewriting everything in PHP.

Tag Cloud