AngularJS – Up and Running In Minutes

So I have written about Single-Page-Applications (SPA) frameworks like Ember before.  I have even mentioned that there were others like Backbone and AngularJS.  Recently, I have been doing more and more AngularJS, and I have to say, I love it. I know, I said that too about Ember too.  🙂 Color me silly.

But what I thought was so easy with Ember, that remains true, is even easier in AngularJS.

Take for example, the dependencies you need for Backbone or Ember, there is none, absolutely none for AngularJS.

And there is more, quite more.  With AngularJS, you get 2-way binding automatically can easily defined your won directives (elements, attributes, classes, and comments).  None of the other SPA frameworks offers 2-way binding or directives like AngularJS.  To see how useful those things are and why they are so awesome, I will show two every simple examples.

One key concept in AngularJS is a “directive”.  A directive is what you use in your HTML just like you would an element, attribute, class, or comment.  One of the easiest to use ‘directive’ that comes with angular is the ‘ng-model’ directive.  This directive is used to create 2-way bindings, so let’s see how it is used.

<input type=”text” ng-model=”myVar” />

<h1>{{ myVar }} </h1>

That is it, you now have an input textbox, into which anything you type will show up between h1 tags.  How easy was that?  Why is this 2-way binding? If you change ‘myVar’ anywhere in code, then the UI will also update in as many places as you are using ‘myVar’.  Similarly, if the UI change, that is the input textbox, the ‘myVar’ is updated.  So your UI and model is always in sync automatically by AngularJS.

He is a full example you can put in a text editor and load up in your browser:

<html ng-app="">
  <body>
    <input type="text" ng-model="myVar" />
    <h1>{{ myVar }}</h1>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js" />
  </body>
</html>

If this is exciting to you, then come back soon for my next post on creating your own directives.  You will see just how easy it is and may be start to see why AngularJS is different from the rest.

WaveMaker Saves The Day

Last week, our manager called the entire team into a meeting.  His charge was, a Web Application, using any technology we want, that implemented a portion of the OpenStack Horizon Dashboard UI.  He had a set of pages he wanted developed.

What was really challenging about this task, was that he wanted it about 5 business days later.

Generally, out team develop web applications using Spring MVC and PrimeFaces JSF library for UI.  Unfortunately, with the very tight deadline of just one week, I didn’t think we could pull off all that XML UI editing.

Instead, I decided to do a prototype of the UI to be implemented in WaveMaker after the meeting.  Not surprisingly, after about 20 minutes, I had about half of the UI completed.  Of course, I didn’t have data in the UI yet, since that would have required making RESTful calls to the OpenStack Keystone service.

One of my teammate saw what I was doing and was immediately impressed.  The only thing left to do I told him, was to figured out how to make the rest calls.  Here too, WaveMaker was surprisingly easy.  When it comes to making RESTful API for get, WaveMaker couldn’t be easier.

Soon, I showed the rest of the team and we decided that same day, that WaveMaker was the way to go.  The only problem we had, was doing RESTful API post calls and of course, trying to integrate Web Services token based API authentication into WaveMaker Spring Security.  We eventually, opted to just not use Spring Security and just do the authentication checks ourselves.

WaveMaker saves the day.

Learning Learning Learning

Before I can master one thing, I am off to something else.  Usually, that is my doing if I can’t find something big enough to keep me pursuing a new technology.  For example, I love the language Google Go.  But, I have been able to find a project big enough for me to do anything other than just play with it a bit, get excited about how cool and different it is, put it away for a bit, and then come back to refresh.

But now, just as I was settling into learning and really getting good with Single-Web Applications (using Ember JS, Foundation CSS, and HandleBars) and my other nice web-development application WaveMaker.  I get pulled off by my tasks at work to learn and master Python, Django, and OpenStack.  All of them, except Django, I had learn a bit about earlier, but didn’t really have anything I can do with them besides playing around.  I don’t have enough computers to deploy a meaningful private Cloud.  And while I spend a few days before going to my current company learning Python, that too I had to put away because I didn’t or couldn’t find a real use for.

Fortunately, things are going quickly due to my previous brushes with the language.  So while I am lamenting not being able to focus on WaveMaker, Ember JS, et.al.  I am glad to be working on things that I had tried and found interesting. I still intend to get back to the other things.

I almost forgot another old friend I started messing with this weekend, Android.  I haven’t had anything to do in Android for about a year or more now.  But a buddy of mine asked me to help me with some Android work, so back into that pot too I go. Again, glad to see Android tooling have improved quite a bit and with the new Android Studio looking very promising, this should be fun.

Frankly, I am glad we will be focusing on the latest devices, freeing us to use the more beautiful UI and features.  Trying to write apps that works well on new and old platforms, while still taking advantage of the new one is a bit of a pain in Android.  The support library helps, but the coding is not the same.

Would We Ever Meet Aliens

There is this point on Slashdot, I have pasted it below.  The think is, the more I think about it, the more I think there is a point to what Paul Tyma says.  An ant to us is really not that interesting, though people do study them.  But is the ant aware of whatever interest we have in it?  But even so, most of us don’t care.  A really advance specie might just see us the same way. Or the future us might just see going to some primitive civilization the same way.

In another post, Physicist Steven Hawkins said that a meeting between us and any advance specie would surely not be good for us. So regardless of which path you consider, either you will be wiped out or not meet.

So much for meeting an alien.

Why We’ll Never Meet Aliens

Posted by Soulskill
from the probably-immigration-laws dept.
iggychaos writes “The idea that aliens will come visit us is fundamentally flawed. Paul Tyma ponders the technology that would be required for such an event and examines how evolution of that technology would preclude any reason to actually make the trip. He writes, ‘Twenty years ago if I asked you how many feet were in a mile (and you didn’t know) you could go to a library and look it up. Ten years ago, you could go to a computer and google it. Today, you can literally ask your phone. It’s not a stretch at all with the advent of wearable computing that coming soon – I can ask you that question and you’ll instantly answer. … How would you change if you had instant brain-level access to all information. How would you change if you were twice as smart as you are now. How about ten times as smart? (Don’t answer, truth is, you’re not smart enough to know). Now, let’s leap ahead and think about what that looks like in 100 years. Or 1000. Or whenever it is you’ll think we’d have the technology to travel to another solar system. We’d be a scant remnant of what a human looks like today. … The question of why aliens might ‘want to come here’ is probably fundamentally flawed because we are forming that question from our current (tiny) viewpoint. The word ‘want’ might not apply at all to someone 1000 times smarter than us.”

Jumping Into Single-Web-Application Via Ember JS

I recently wrote a short post about hearing and now starting to learn the frameworks being developed for Single-Web-Applications (SWA).  SWAs are not new, Google has been doing it for some time as GMail and other applications. It is not the only company either.

But what is an SWA? It turns out, like AJAX, the core technologies for building a SWA is what was there all the time, mainly HTML, JavaScript, and CSS.  Surely, there are a few new techniques and recommendations from lessons learned.  After some time of making SWA the hard way, some people decided to create frameworks and template-ing libraries.

One of the best known library in the SWA space is Ember JS.  Backbone and Angular JS (from Google) are very well known too.  But Ember just has something about it when you start playing with it, it just seems intuitive.  Not surprisingly, many of the Ember JS developers are or were Ruby on Rails developer developerts.

Enough talking, let’s get into and talk later.

Step 0 – Download ‘Ember JS Starter Kit’

Step 1 – Unzip/Extract Archive To A Folder

Step 2 – Load The Index.html File In Your Browser

Step 3 – Customize : Just A Touch

Step 4 – Be Amazed : Reload In Your Browser

Let’s do it.

Step 0 – Head over to Ember JS and download starter kit.

Step 1 – Unzip/Extract Archive To A Folder

Regardless of your platform, extract the downloaded archive to some directory.  I like putting my development projects in my <home directory>/devel/projects or <home directory>/devel/playgound depending on what I am doing.

Step 2 – Load The Index.html File In Your Browser

At this point, you can open the index.html file in the Ember Starter Kit folder you created in the previous step.  BUT, the directory name is probably some long crazy thing.  If you want, and would recommend, that you change the name to something simple like ’ember’.    Regardless of what you decided to do, just use the File->Open menu item in your Web Browser to select the index.html file in the starter-kit directory.

What you should see, is something like “Welcome to Ember.js” and a bulleted-list of “red”, “yellow”, and “blue”.  If you see that, it proves that everything is working just fine.

Step 3 – Customize : Just A Touch

So what just happened?  Well, if you didn’t sneak a peak at the index.html file yet, you should now.  You will see that it is a very simple file with what is call “Handlebars template”.  That is the text inside the “<script>” tag with ‘type=”text/x-handlebar-template”‘ in the body.  NOTE: The actual text might be slightly different, but you should be able to find it.

That the Handlebar template, was handled a “model”, the data to put in the list.  Which was just a JavaScript array of the strings “red”, “yellow”, and “blue”.  Handlebars then rendered the HTML which you see.  Pretty simple, huh?

So where is the ‘model/data’ coming from?  That is coming from the js/app.js file. If you take a peak at this file, you will see that JavaScrip array. But don’t worry about anything else for now.  Let’s do something fun.  I know, you still have a few questions, but trust me, this will be cool.

Using your favorite or any text editor on your computer, open the index.html file in the starter-kit directory. Remember, you might have changed the name of this directory.

** Rant on text editors.  For Windows users, this will most likely be Notepad.  Linux user, you are using Linux, you do better be using Vim or Sublime Text if you have a GUI.  As a matter of fact, regardless of your platform, get Sublime Text or Vim.**

Now, replace all the text between the two set of <script> tags so that you only have one remaining with the following text:

<script type=”text/x-handlebars”>

<p>{{input type=”text” value=name}}</p>

This is my name: {{name}}
</script>

Step 4 – Be Amazed : Reload In Your Browser

And start typing in the text box.

Vollia!!!

Take a minute or so to savor the result.  If you had to do that without Handlebars/Embers, you would have to be write a JavaScript function to update the output label, and of course register it to the “onchange” event of the text box.  You didn’t have to do any of that and it is working.

See you soon when we do more fun stuff with Ember and Handlebars.

Week 16

I tried to deploy RedHat’s RDO OpenStack distribution over the weekend. It was very easy to install, but I had some problems with the network configuration.  I have a two servers, one is newer than the  other.  The newest one is a 16-GB RAM with Quad-cores HT (8-cores total), and 2 x 150GB SATA HD.  The other is a bit older and tops out at about 4-GB RAM, single core-HT, and 1 x 150GB HD and a 250GB HD.

I had first deployed the RDO “allinone” option on the newest server, but realized that this is be my Nova-Compute node.  But since I still had a few server apps on the other computer which I couldn’t just remove, I had to find some way of moving them to the new computer. Then installing the “allinone” on that slower computer, not a problem since that would only be really be used as the Controller.  Then I can add more nodes, first a better computer node using the newer server.

Unfortunately, moving the services from the existing server is a pain and slow.  I am trying to move a physical server into a VM on the newer computer where I have installed KVM and libvirt.

At first, everything was going well. Until I did something and now it is not working reliably.  Now I have something else to look forward to fixing during the week after work.

Riding A Cloud

For about a year now, I have been playing with OpenStack cloud platform off and on.  Always, just running it on my laptop or in some limited virtual environment.  But last week, my manager asked another colleague and I to deploy OpenStack at work on a few computer to play with some ideas.

It was so much fun to be finally be able to play with it on several machines.  Because our tests were very promising after a few days, we did have some hiccup due to our inexperience and faulty hardware. But now, we will be getting some new servers and blades to play with.

A buddy of mine recently asked me to setup a CentOS server for him.  Well, little does he know, he will be getting a server in a VM running in a small cloud deployment at my home. He is remote, and often uses my server, so since he won’t be seeing the actual machine, I will get him what he wants and ton of flexibility from doing a cloud.

I love OpenStack, but it is a bit of a pain and a usuable deployment needs a few machines.  I will be deploying CloudStack (from Apache) for my small cloud at home. Mostly due to its simplicity and management.  What I should say, it would be easier to deploy using the UShareSoft CloudStack distribution.

You Are Almost Everything, Spring Framework

I have been using the String Framework on and off for a few years.  I heard about it back around 2005 or some time then.  I tried using it around 2006, but really didn’t have much use for it. But I stayed interested and would checking now and then to see the direction.

Fast forward a few years, now would be good, give or take a few months. I am working on Java applications for the cloud, and I get to play with Spring almost daily. The framework has matured so much, and so many new features have been added.  Not to mention the many new sub-projects that covers many of the other disciplines.

Like anything else, the more you use it, the better you understand it. And that either makes you like it more or like it less. Fortunately, for me, the more I use Spring, the more I like it. I have found it very easy to create RESTful applications and it is brain dead easy to add database persistence to your application. For those who use Roo, Grails, or Ruby on Rails, will know just how easy it is to follow convention and just have magic happens. Spring does some of that too.

Here are some people saying why they like spring. But if you want to learn a bit about Spring, you can start here.  I would like to do some Spring tutorial once I know the audience and their expectations. So if you don’t have time for reading or watching long videos  drop me an email and I will can start working on some short-to-the-point tutorials.  I have done some at work for my co-workers and they really like the format of focusing on getting a task done and showing how to do that with Spring.

Passenger Bill Of Rights

It is not quite a “Passenger Bill Of Rights” yet, but I was very pleased to read in one of the Guyana online newspaper that the Tourism Ministry will be proposing a set of guidelines for Taxi operators.  The guidelines includes such things as not being rude to passengers. Who knew that was something taxi and minibus drivers had to be taught.

This effort is several decades too late, but I am glad to see that they are make progress. Another proposal by the Tourism Ministry is a blacklist for operators who don’t follow the rules.  As a potential tourist destination, the ministry needs to take several steps which to show visitors and transportation operators that safe and proper rules must be followed.

It wasn’t so long ago, that I had proposed to a friend of mine working at the Ministry of Tourism, that they have a passenger’s bill of right.  I have not traveled to all the States within the USA, but most of the ones I have visited, have  passenger bill of rights. It is posted at the back of the front seat so that passengers can easily see how they should be treated and what is expected of their driver.

Recently, I have suggested to said friend the the Tourism Ministry needs a way to measure the experience of visitors.  The goal of the idea was far bigger than that, or the one agency.  But the gist of it was that people should be able to say how a service or experience was.  This let’s you know what and where to improve if necessary, and can tell you the people who participated in an activity views it.

If Guyana wants to give visitors and the people living there the kind of quality of live they deserve, then it needs to include news ways of getting the pulse of the people. To see what they want and how best to make that happen.

Where To Complain?

Sometimes, not being able to do very simple, or what you think is simple, things can be very frustrating.  Making you want to pull your hair out or shake someone.  For example, you might want to pay your bill online or register for classes. But some silly policy gets in your way, and wonder why would anyone conceive of this process.

I have been witness to many a inefficient processes and procedures, and I usually vent by writing or telling someone else.  But, I had once used the first incarnation of Lorrev-dot-org as my place to vent and other to vent should they want to. I have been thinking lately of a new spin on that very old idea, a place to vent when you are frustrated by what would seem rather simply and straight forward things.

Quite recently, I was reading my FaceBook wall, and a friend was venting their frustration at having to take the same on documentation (proof of address, etc.) to the University of Guyana for the new semester registration.  The problem was, nothing has changed, they never said anything changed, yet they are going thought this process as if this is the first time they are registering.

The problem here is this, even if you know that is what you need every semester for registration. It just seems to be a waste of time on both the part of University of Guyana and the students, since should by now have a way to just bring up your information and ask you if anything change. If you say “no”, use that as current and move along.  But that is not what they do, and it just doesn’t seem like it should be. The solution doesn’t seem that complex to pull off at a university with Computer Science department.

I totally get wanting to vent if you have to go thought this or similar experiences. So I was thinking, again, yet another idea of a website where people can come put their grievances and other can pile on.  Adding comments, pictures, video, or whatever. The intent of the site won’t be like change.org. There are a few “let’s start a petition” or “let’s start a movement” type website. This won’t be anything like that, in my mind. It is just a place to complain on issues for which you have similar experiences or sympathy.

Why not use a site like FB? Saying that not everyone has a FB account, would be true, but not a valid enough reason. I like to think that the purpose of this site and what FB is in general are quite different.

May be I will have sometime to mock-up a simply site to see if it makes sense.  May be a I will use that for my ranting and vents instead of putting them here. My first entry would probably be buying food early in the day at a restaurant and felling like it was from the day before.

.v