Uncategorized

Base64 Encoding/Decoding in JavaScript… wrapped in jQuery

Integrating a Google Gadget with Solve360’s API, I needed to have a way to Base64 encode some strings before appending them as headers to my server calls… instead of rolling my own, I went to look for my old friend: Nick Galbreath’s base64 string encoder

In the search results I stumbled upon a 2 year old jQuery’fication of it by Carlo Zottmann

Check it out…
https://github.com/carlo/jquery-base64 

Advertisements
Uncategorized

Introducing Backbone.js…

Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions,views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
http://documentcloud.github.com/backbone/

When working on a web application that involves a lot of JavaScript, one of the first things you learn is to stop tying your data to the DOM. It’s all too easy to create JavaScript applications that end up as tangled piles of jQuery selectors and callbacks, all trying frantically to keep data in sync between the HTML UI, your JavaScript logic, and the database on your server. For rich client-side applications, a more structured approach is often helpful.

With Backbone, you represent your data as Models, which can be created, validated, destroyed, and saved to the server. Whenever a UI action causes an attribute of a model to change, the model triggers a “change” event; all the Views that display the model’s state can be notified of the change, so that they are able to respond accordingly, re-rendering themselves with the new information. In a finished Backbone app, you don’t have to write the glue code that looks into the DOM to find an element with a specific id, and update the HTML manually — when the model changes, the views simply update themselves.

This is similar to most other template based general purpose javascript frameworks today, and the way Backbone.js is approaching is code centric and gives the developer a high degree of very finely granulated control over how the application is tied together and driven…

Backbone Aura is a decoupled, event-driven Backbone architecture for developing applications and can in the same sentence be coined as a General Purpose Application Micro Architecture.
https://github.com/addyosmani/backbone-aura 

The application is broken down into AMD modules that contain distinct pieces of functionality (eg. views, models, collections, app-level modules). The views publish events of interest to the rest of the application and modules can then subscribe to these event notifications.

All subscriptions go through a facade (or sandbox). What this does is check against the subscriber name and the ‘channel/notifcation’ it’s attempting to subscribe to – if a subscriber doesn’t have permissions to do this (something established through permissions.js), the subscription isn’t allowed through. The rest of the application is however able to continue functioning. 

Uncategorized

Jasmine – A JavaScript Testing Framework

Jasmine is a Behavior Driven Development testing framework for JavaScript. It does not rely on browsers, DOM, or any JavaScript framework. Thus it’s suited for websites, Node.js projects, or anywhere that JavaScript can run.

Check it out…
https://github.com/pivotal/jasmine

Jasmine is a behavior-driven development (BDD) JavaScript testing framework Pivotal Labs maintains it and makes it available on GitHub under the MIT license. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. You run Jasmine in a browser, or headless without a browser by integrating with other frameworks such as Rhino, Envy, or the Jasmine-headless-webkit library.

Jasmine API includes features such as:

  • A more natural BDD syntax for organizing the test logic than JUnit style assertion test frameworks
  • Asynchronous testing
  • Mocks
  • Spies
  • Easy to create custom matchers
  • Ability to share or isolate behaviors between tests within a spec encapsulating parts of your spec.
  • Continuous integration support

If this has caught your interest, I recommend that you check out this article on the Adobe Developer Network about how to get started using Jasmine to test your Javascript applications…
http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html

Uncategorized

UglifyJS — a JavaScript parser/compressor/beautifier

Introducing UglifyJS… a package that implements a general-purpose JavaScript parser/compressor/beautifier toolkit. It is developed on NodeJS, but it should work on any JavaScript platform supporting the CommonJS module system (and if the platform of choice doesn’t support CommonJS, its easy to implement it, or discard the exports.*lines from UglifyJS sources).

The tokenizer/parser generates an abstract syntax tree from JS code. its then possible to traverse the AST to learn more about the code, or do various manipulations on it. This part is implemented in parse-js.js and it’s a port to JavaScript of the excellent parse-js Common Lisp library from Marijn Haverbeke.

Check it out…
https://github.com/mishoo/UglifyJS

Technology, Uncategorized

Meteor

Meteor is a set of new technologies for building top-quality web apps in a fraction of the time, whether you’re an expert developer or just getting started.

Pure JavaScript
Write your entire app in pure JavaScript. All the same APIs are available on the client and the server — including database APIs! — so the same code can easily run in either environment.
Live page updates
Just write your templates. They automatically update when data in the database changes. No more boilerplate redraw code to write. Supports any templating language.
Clean, powerful data synchronization
Write your client code as if it were running on the server and had direct access to the database. No more loading your data from REST endpoints.
Latency compensation
When a user makes a change, their screen updates immediately — no waiting for the server. If the server rejects their request or executes it differently, the client is patched up with what actually happened.
Hot Code Pushes
Update your app while users are connected without disturbing them. When you push a new version, the new code is seamlessly injected into each browser frame in which the app is open.
Sensitive code runs in a privileged environment
Write all of your code in JavaScript (if you want.) The user interface runs in your browser. The sensitive functions run in a privileged server environment.
Fully self-contained application bundles
One command to compile your entire application into a tarball. Unpack it anywhere there’s node.js, run one command, and you’re on the air. You’re never locked into a particular hosting provider; you have all the code for the platform.
Interoperability
You can connect anything to Meteor, from native mobile apps to legacy databases to Arduinos. Just implement the simple DDP protocol.
Smart Packages
Meteor’s Smart Packages are actually little programs that can inject code into the client or the server, or even hook into the bundler to preprocess your source. Great care has been taken to give the core Meteor packages the minimal set of dependencies, so you can use your favorite templating, testing, or DOM manipulation frameworks.
Check it out…
http://www.meteor.com/
Uncategorized

Getting Started with the HP Cloud…

It wasn’t more than 24 hours after I had submitted to the BETA program of the HP Cloud that I received my activation key…

And then… besides having a UI that was obviously build using BootStrap (by Twitter), I was impressed by the cleanliness of the UX and the ease of knowing what to do next…

(To be Cont.)

Uncategorized

Cloud Based Object Storage… a quick comparison

OK, so its Friday night in Bangkok, and I’m doing what everybody would be doing in that situation, comparing Cloud Based Object Storage Options for some solutions I’m putting together…

Among my priorities is that they should…

  • support REST (just as a benchmark)
  • have more than one datacenter (preferably one in Asia)
  • offer a free ramp up opportunity

An assumption is that every candidate should adhere to the general requirements for data management, security and availability.

After having done a little research and talked with some friends, I have come up with the following candidates. I have listed their drawback and attractions…

Eventually I will have to come to a conclusion as I finish this micro-survey, and off course I will share that here as well in case others like me would find themselves in a similar situation…