Monday, December 26, 2011

Sooner or later, software licenses

Sooner or later, as a software developer (or even as a server admin) you'll have to deal with software licenses. You just can't escape it.

For the uninitiated, a software license defines what you can do with a piece of software. As for the case of a developer, it defines what someone can do with YOUR software. There's a lot of licenses freely available in the internet like BSD, GPL and LGPL. The discussion of permissive, not-so-permissive, free-but-closed, etc. families of licenses will be like writing a research paper. That's too much work for me.

In any case, these licenses are a bit thick or has too much legalese which sometimes I don't like. So, I found sometime that's easier to read and people to understand, the DBAD license.

Quoting Phil Sturgeon,
"As developers we all want to protect our code from dicks that try to steal, sell, infringe or just generally rip us off. For this we have licenses like GPL, MIT, etc.
Sometimes however, you release a project where you just don't care what happens to the code. For this Sam Hocevar created the WTFPL which is a brilliant license.
For those of you who want something in between, try the DBAD license."
Here's the full verbatim text of the license.


                    Version 1, December 2009

 Copyright (C) 2009 Philip Sturgeon

 Everyone is permitted to copy and distribute verbatim or modified
 copies of this license document, and changing it is allowed as long
 as the name is changed.

                  DON'T BE A DICK PUBLIC LICENSE

  1. Do whatever you like with the original work, just don't be a dick.

     Being a dick includes - but is not limited to - the following instances:

 1a. Outright copyright infringement - Don't just copy this and change the name.
 1b. Selling the unmodified original with no work done what-so-ever, that's REALLY being a dick.
 1c. Modifying the original work to contain hidden harmful content. That would make you a PROPER dick.

  2. If you become rich through modifications, related works/services, or supporting the original work,
 share the love. Only a dick would make loads off this work and not buy the original works
 creator(s) a pint.

  3. Code is provided with no warranty. Using somebody else's code and bitching when it goes wrong makes you a DONKEY dick. Fix the problem yourself. A non-dick would submit the fix back.

Thursday, December 22, 2011

6 Simple types of Inverted Queries

Whatever kind of database you are working on - NoSql, ORM, relational, or OO you will still need to query for data.

There are two ways in which data can be queried. The first way is for each entity to have a identifying or unique attribute. This identifying or unique attribute then can be used to select the entity or entities. The second way is an inversion of the first and is designed so that the entity identifiers associate with a given attribute may be obtained. The first way is useful for answering the question: What are the properties of a given entity? The second is useful for answering: What entities have a given property?

Assuming that we have entities E; attributes, A; and their attribute values, V. We have these 6 types:

Form Type of Query Example
Common attribute inquiry How much did Saleman No. 15 earn last month?
Which entities have the given value? Which salesman or men earned more that 20,000 last month?
List all attributes having a given set of values for a given entity Which month's earnings for Salesman No. 15 have exceeded 20,000?
Request for all information about a given entity List all the information stored about Saleman No. 15
List the value of a given attribute for every entity List last month's earnings for every salesman
List all entity attributes having a given set of values For every salesman, list every month when this earnings exceeded 20,000
You can mix and match the six types to create very complex queries. You could for example ask the question: Which salesman earned more that 20,000 in May OR June OR July?

Sunday, December 11, 2011

Enable that Drupal Module from inside Netbeans

Drupal development - module or theme - in Netbeans work but you'll have to deal with a few quirks, gotchas and trade-offs. One of my pet peeves is where that I have to open a command outside of Netbeans to use Drush. I have gotten use to my Java flow where I can call or use Maven or Ant inside Netbeans. I don't have to suffer anymore! Because I have found a plugin that makes Drupal development in Netbeans cool, pleasurable again. Introducing NDDT or Netbeans Drupal Development Tool.

NDDT is developed by Jamie Holly who just happens to be the owner of Holly Information Technologies which owns the code to NDDT. Amazingly he is currently allowing Drupalist to freely download the plugin as a NBM package. A NBM package is the file format for Netbean plugin. 

I haven't tried out all the features as of yet but I've noticed that I've been using three features of the NDDT everytime for the past week since I installed NDDT.
  1. Drush console - No more opening the admin module page for me. I just run pm-enable from Netbeans.
  2. The snippet and templating feature - You just gotta love any feature that cuts down on the typing
  3. Drupal API search feature - I don't have to keep open a tab for the site. 
Any Drupalista who uses Netbeans SHOULD give NDDT a spin. It's FREE and it WICKED!

Tuesday, November 29, 2011

Centering an inner div vertically inside another div

Green div is centered on a gray div
So how do you:
A div tagged as "divsmall" is contained inside a bigger div tagged as "divbig". the challenge is how to *vertically* align/center divsmall inside divbig.
Interesting question although having limited applications but still this should be possible. So, broke out my favorite IDE and started coding away. We start with our HTML.

 <!DOCTYPE html>  
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
     <link rel="stylesheet" type="text/css" href="css/mystyle.css"/>  
     <div class="div-big">  
       <div class="div-small">  
This should be easy to read. We then move to the CSS.

    background: #999;
    border: 1px solid #000;
    min-height: 640px;
    margin: auto;
    text-align: center;
    width: 940px;

    background: #66cc00;
    border: 1px solid #666;
    min-height: 600px;
    margin: 20px auto;
    width: 25%;
The trick in the margins. If you look at line 14, that all you need to center inner div. The width doesn't really matter. Try modifying the width value at line 15. The div should adjust in relation to its parent div.

Monday, November 28, 2011

All I want for Christmas is a XiaoMi

You simply can't knock it. This new Android phone from Meizu is off the hook! Spec-wise its gorgeous for only $310 bucks. That's about P13,500 in my pesos.

You will admit that it looks like an iPhone and that's what exactly its makers want it. The iPhone 4s is just weak if you do a side-by-side comparison.

The iPhone runs on a A5 dual core clocked at 800MHz. The Xiaomi run a Cortex-A8 dual core at 1.5Ghz. Xiaomi 1, iPhone 0.

Internal RAM? iPhone 500MB; Xiaomi 1GB. Xiaomi 2, iPhone 0.

The iPhone has a capacitive 3.5inch touch screen while the Xiaomi has 4inches. Xiaomi 3, iPhone 0.

The Xiaomi has this massive 1930mAh battery. I forgot what iPhone has on it but I will bet it running a standard 1430 mAh. Xiaomi 4, iPhone 0.

And please don't make get started on the price. We all already know that the iPhone is like 29k. How can you beat 13.5k phone with better or equivalent hardware?

Heck, the manufacturer is also promising that by January, Ice Cream Sandwich build will be available. FTW!

So for Christmas, unless your a fanboy, skip the iPhone.

For a more in-depth review, read this.

Anyone want to buy a Cherry Mobile MagnumHD?

Thursday, November 17, 2011

CM Magnum HD + MIUI = iDroid

MIUI Home screen
I bought my Cherry Mobile Magnum HD about about a year ago and if you have been following this blog, you'll remember that I installed and been using the Welcomm ROM. The Welcomm ROM has served me well but time to look for another.

Enter the MIUI.

Now MIUI is a custom Android ROM. The most striking feature is its UI. Its very reminiscent of a iPhone's user interface. That's why I sometimes confuse people when I tell them that I have an iDroid. *big grin*

Now, you will notice that in the official MIUI webpage that the Cherry Mobile Magnum (or its variants) are not support. That's because it isn't. I'm using a modified MIUI ROM by an Indonesian guy named TJ_Style. He hangs around the website.

To get your grubby hands on the rom, you'll have to register to the forum. Just run the site thru a translator since most of the post is in Indonesian.

Also, you'll need to get that custom CWM recovery for your phone so you can install the ROM and get superuser rights. That shouldn't to hard.

Anyway, here's a couple more screenshots of my newly flashed Cherry Mobile Magnum:

Wednesday, November 9, 2011

My 15.4" laptop backpack

I've had been searching for a laptop backpack for months now but my city certainly had slim pickings for a 15.4" laptop. As it turns out, a lot of options for a 14" laptop.  I think I've visited at least once all the bag, backpack retailer in every mall, department store in this city. No such luck, so I turn to the internet.

This is where I found Its's this online shop based out of Hong Kong. The real kicker is that they ship stuff you buy from the site anywhere in the world for FREE. Gravy.

Search the site for a "laptop backpack" and browsed the results. I finally settled on this Waterproof 15.4" Travel backpack. I stupidly thought that the brand is Waterproof. Hehehe. When I got my backpack after 4 weeks, the brand is Swissgear. Just its made in China which probably makes it a knockoff. But don't let that put you off because honestly I can't tell it apart from the original. The backpack seems to be well made.

And it fits all my gear nicely. Just take a look at the image at the right. The bag has this padded compartment for the laptop and extra pockets for the mouse and power brick and cord. In fact, the pads are so nice that you can forget about getting one of those soft carrying sleeves.

I also need to mention has this cool feature where a special small bag designed to load CD/MP3/MP4 players (ie. an iPod) with 3.5mm cable and jack allowing you to enjoy music at anytime. The interface jack is on the harness. But I think you have to get one of those headphones with controllers so you don't have to dig through the pack.
Despite all of that stuff, the pack still has enough space for a couple of books, a shirt or two and a from the looks of it, a netbook. And that's just from the inside compartment. The pack still has space on the front and sides for a water bottle or canteen or camera or overnight kit. Heck, it even has space for your shades.

My best purchase ever!

Monday, November 7, 2011

Views and jCarousel fun

So, to make a long story short, I got a client who wanted to display his Drupal site's content nodes just like the image above. We are working with Drupal 6.

He wanted:
  1. A callout box that contains location and a link
  2. An image carousel 
  3. A social networking toolbox 

So we start off with a custom content type. My setup is composed of CCK, Location, Image, ImageCache. 

Content Construction Kit (CCK) needs no explaination. You can't make custom content type without it. The Location module is used with CCK to capture Location data. The Image module so we can attached, well, images to the node. The ImageCache complements this; allowing us to process the attached images to whatever size we need it.

We are are off to writing code in the our theme's template.php. We are going to preprocess our node data. Here is mine. Your CCK field names might not be same as mine but you can look at the CCK field names up with a dpm($vars) call. Remember that you can't make a dpm call without the devel module.

function [YOUR_THEME]_preprocess_node(&$vars, $hook) {      
    // construct callout box for organizer and venue
    $organizer_url = $vars['field_organizer_link']['0']['view'];  
    $venue_name = $vars['field_record_venue']['0']['name'];  
    $venue_street = $vars['field_record_venue']['0']['street'];  
    $venue_city = $vars['field_record_venue']['0']['city'];  

    $field_venue = '<div class="venue"><span class="venue-title">' . $venue_name . '</span><br/> <span class="venue-location">' . $venue_street . ', ' . $venue_city . '</span></div>';  
    $field_organizer = '<span class="organizer"><p> For more Information,<br/> visit the organizer\'s site</p>' . $organizer_url . '</span>';  
    $vars['callout'] = '<div class="callout">' . $field_venue . $field_organizer . '</div>';  

    // construct embedded view for image carousel  
    $embedded_view = 'embedded_related_img';  
    $embedded_args = $vars[nid];  
    $emdedded_view_display = 'default';  
    $vars['embedded_carousel'] = views_embed_view($embedded_view, $emdedded_view_display, $embedded_args);  
We then can insert the newly constructed callout box via the $callout variable. See line #12.

The next step here is the image carousel. I did this using Views and jCarousel. When you read up on how to use jCarousel it should be apparent that you can use a Views argument to make an image carousel of the current node using its id and get all the attached images. I then named the view "embedded_related_img". Set the view style to jCarousel. The options shouldn't be a problem. It will not preview correctly since Views will not load the javascript for the carousel. I then attached this on the node via the $embedded_carousel variable. The magic is the views_embed_view() function. See lines #15 - 18.

And as for the social networking bar that's done with the addThis module. This should be a no-brainer.

For reference, here is the node.tpl.php file.

<div id="record-<?php print $node->nid; ?>" class="node record clear-block">   
   <?php if ($page == 0): ?>  
     <h2 class="title"><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>  
   <?php else: ?>  
     <h2 class="title"><?php print $title ?></h2>  
   <?php endif; ?>  
   <div class="content clear-block">  
     <?php print $picture ?>  
     <?php if(!$teaser): ?>  
       <?php print $callout; ?>  
     <?php endif; ?>  
     <?php print $content ?>  
   <?php if(!$teaser): ?>  
     <div class="embeded_view clear-block">  
       <?php print $embedded_carousel; ?>  
   <?php endif; ?>  
   if ($links) {  
     print '<div class="node-links">'. $links .'</div>';  

Saturday, November 5, 2011

Overcoming CSS's limitations with Less CSS

I have written my fair share of CSS for almost every kind of project. CSS is easy to use but on a whole I always wished that CSS had some kind of programming elements. You dont' how many times I have come across a scenario where I had to write a style rule over and over again or target specific children classes inside a parent element. The resulting CSS is not pretty. This was until I came across Bootstrap from Twitter and Less CSS. The tag line says:
LESS extends CSS with dynamic behavior such as variables, mixins, operations and functions. LESS runs on both the client-side (IE 6+, Webkit, Firefox) and server-side, with Node.js.
Yes, CSS with "dynamic behavior" and everything still boils down to pure CSS. You just drop in less.js and off you go. Here's an examples that I think makes writing CSS interesting again. Supposed that you have a hex colors that is used all over the place, this wouldn't be a problem until you have change it. Now you can crank up your editor's Find and Replace but we know that sometimes that thing replaces values that it shouldn't be replacing. So....
/* Less CSS sheet */
@color: #4D926F;

#header {
  color: @color;
h2 {
  color: @color;

The variables @color allow me to specify widely used values in a single place, and then re-use them throughout the style sheet, making global changes as easy as changing one line of code. With a little foresight, I can set this up so what I change say only affects #header divs or certain areas in my HTML page. Don't worry because, when you pass the site to the browser, your Less CSS will be "compiled" by the less.js spitting out pure, clean CSS.
/* Your CSS as far as the browser is concern */
#header {
  color: #4D926F;
h2 {
  color: #4D926F;

I think this will become another important tool in a web developers toolbox. I already use it indirectly anyway. I'm a big fan of the Bootstrap framework from Twitter.

Monday, October 31, 2011

Adding unique CSS classes to primary menu elements

Adding unique CSS classes to primary menu elements in a Drupal theme is quite easy. You just need to override the theme_menu_link function in the template.php.

I'm working on a Fusion sub-theme named nebula. So the function is named nebula_menu_link .
 * Manually add unique CSS classes to primary menu li elements
 * @staticvar int $item_id
 * @param type $variables
 * @return type 
function nebula_menu_link($variables) {
  $element = $variables['element'];

  static $item_id = 0;
  $element['#attributes']['class'][] = 'nv_' . (++$item_id);
  $sub_menu = $element['#below'] ? drupal_render($element['#below']) : '';

  $output = l($element['#title'], $element['#href'], $element['#localized_options']);

  return '' . $output . $sub_menu . '';

Refer to line #11 that's where the meat of the function. The line adds a "nv_1" class to the first primary menu element. It should be easy to figure out that the succeeding elements would be "nv_2", "nv_3". That's the (++$item_id).

Here's how it would look when theme renders.
<ul class="menu">
      <li class="first leaf nv_1">
          <a href="/" class="active">Home</a>
      <li class="leaf nv_2">
          <a href="/content/about-us" title="">About Us</a>
      <li class="leaf nv_3">
          <a href="/content/solutions" title="">Solutions</a>
      <li class="leaf nv_4">
          <a href="/content/services">Services</a>
      <li class="leaf nv_5">
          <a href="/" title="" class="active">News</a>
      <li class="leaf nv_6">
          <a href="/" title="" class="active">Library</a>
      <li class="last leaf nv_7">
          <a href="/content/contact-us" title="">Contact</a>

Now we can target individual li elements of the primary menu. Theme away!

Saturday, October 8, 2011

Writing new Java is Groovy

Way back when - this was when I was in college, you had to choose a programming language. Unfortunately for my instructors, I wasn't the sheep they thought I was. I wasn't about to be cowed into using VB6, which by the way, they were ramming it down the throats of my classmates - well most of my classmates. A few of us decided it was our duty to give them the finger and tell them to shove where the sun don't shine.

So I looked at and tried a lot of stuff during this time.
  1. C/C++. Its like using a chainsaw without the chain guard - its liable to cut of your hand when you do something stupid. Damn overflows and pointers in the wrong addresses.
  2. Pascal and/or Delphi. Very cool IDE but very heavy with the keywords. I also just didn't like the language - this is more of a personal preference rather than something that has technical merit. So, Pass.
  3. xBase languages like Clipper. No IDE during that time so programming was done with notepad and a stash of batch files. No dice.
  4. Powerbuilder. It was the gold standard for rapid software development that time. It just cost a couple thousand bucks for the whole thing. Ouch.
So that just leaves Java, which was still owned by Sun Microsystems. It was free, no pointers, had several IDEs to choose from and language idiom that "spoke" to me. That was 10 years ago and like any good hack, I'm still learning, hacking, tweaking new stuff. And this is where Groovy came into the picture.

I'll be the first one to admit, Java as a programming language is far from perfect. Java code is overly verbose is one such flaw. Groovy is more leaner but its still Java; consider the fact that Almost all Java code ever written is also valid Groovy. 

To make my point, take a look that this standard but rather trivial Java POJO.

import java.util.Date;

public class Person {

    String firstName;
    String lastName;
    Date birthDay;

    public Person() {}

    public Person(String firstName, String lastName, Date birthDay) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.birthDay = birthDay;
    public Date getBirthDay() {
        return birthDay;

    public void setBirthDay(Date birthDay) {
        this.birthDay = birthDay;

    public String getFirstName() {
        return firstName;

    public void setFirstName(String firstName) {
        this.firstName = firstName;

    public String getLastName() {
        return lastName;

    public void setLastName(String lastName) {
        this.lastName = lastName;

No suprises here. I will concede that this can be generating by the IDE but you can't escape the fact that the code is still extensive. Compare this to the equivalent Groovy code.

class Person {
    String firstName;
    String lastName;
    Date birthDay;

Seriously, that’s the whole class. Groovy classes are public by default, as are Groovy methods. Attributes are private by default. Access to an attribute is done through dynamically generated getter and setter methods, so even though it looks like we’re dealing with individual fields, we’re actually going through getter and setter methods.

Also Groovy works with my favorite Java framework, Tapestry5 and is supported by Netbeans since 6.5.

And like Ash in Army of Darkness getting the powered glove in place of his right hand: Groovy.

Friday, September 23, 2011

Getting Ubuntu to play nice with your Android phone

Doing Android app testing on virtual devices isn't really that bad but it aint the good either. It's always much, much better to test that app on a real device.

But Ubuntu (and possible the other *nixs) doesn't recognize your Android phone. You instead get something like this:

$ adb devices
List of devices attached
???????????? no permissions

Unfortunately this is easily fixed. All you have to do is to create a file in the /etc/udev/rules.d directory which contains one (1) line.
Now, what that line is depends on what your phone is. You can figure that one out by using this command:

$ lsusb

And if you haven't connected your phone via the USB before your typed in the command then pat yourself in the back because your are just as brain dead as the rest of the world.
lsusb output
At any rate, you'll notice that my phone is on Bus 002 and the Vendor ID is "0489" and the Product ID is "c000". Remember these values.

Now, lets make the file:
$ sudo gedit /etc/udev/rules.d/51-android.rules
And then, type in the following line: 
All that's left then is to restart udev. Some devices will require you to disconnect and reconnect them to be recognized.
$ sudo restart udev
To check if your phone is now recognized.
$ adb devices

Monday, September 19, 2011

Rooting your CM Magnum again

Ok, so you had to update your CM Magnum to Gingerbread via the official Cherry Mobile ROM. This will basically "unroot" your already rooted phone and bring it to 2.3.4 or something. I know its been months since then but I have been doing stuff. I do have a life.

But that still brings us back to the issue at hand, how do I root my Magnum, Ideos X6, etc. again? OK, I can answer that but remember,

I. Will. Laugh. At. You(twice as hard). If. You. Blame. Me. If. You. Brick. Your. Phone.

 So, as far as I know, these don't work:
How do I know? Duh, I tried them of course.
The only one that I have verified that works is tj_styles CWM recovery procedure. Najmods has posted the procedure here.

But if you are too lazy to open a new tab (sheesh...) then here is the procedure:

AWRRR! Walk the Plank, Android!
First step: Replace original recovery with ClockWorkmod Recovery
1. Download ClockWorkMod Recovery
2. Put the device in download mode (Power+Vol Up) and connect to PC,
and the PC will recognize the device as Removable Disc/Storage open it and you will find FIH > Image folder and select recovery.img, copy it anywhere to your PC as backup just in case if anything go wrong
3. Replace recovery.img in 'image' folder with recovery.img inside the Clockworkmod Recovery v4.0.0.9 you download and extracted earlier
4. Disconnect device from PC, open up the battery and reboot.

Second step (DO FIRST STEP FIRST): Rooting the phone
1. Download Su and put it in sdcard (but don't put it in any folder)
2. Put the device in recovery mode (Power+Vol Up & Vol Down)
3. Select "install zip from sdcard" and select "Choose zip from sdcard" and search for 'Su' and click install.
4. Select "back" and click "reboot system now"

Now to install busybox and do something really stupid/cool like put a perl/ruby/whatever interpreter in my phone. Why install a perl/ruby/whatever interpreter in my phone, you ask? Because I can.

What is your excuse?

Tuesday, August 30, 2011

Embedding Images to a Tapestry5 page very easily

OK I'll admit that the title might be problem but then again that's up to you.

Here's the thing, adding dynamic images in Tapestry5 templates is pie. You can read up on it here. But that seems to be best way if you are dealing with a file system or uploaded files. But what if the source is JSON data and doesn't need to be manipulated? Where we'd rather just stick it in directly into the template and display it.

Apparently this is just as easy as pie. First off, I'm dealing with a Base64 string as representation of the image within the JSON data. The image format is JPG, by the way for the just curious. Fortunately, Firefox and Chrome like Base64 strings. Then we can basically do this.

<img src="data:image/jpg;base64,iVBORw0KGgoAAAANS..." />

So what we need then is a webservice that pulls the JSON, process it a bit and pass it into the template.

public interface ICustomerService {

    public JsonObject getCustomerFromWebService(String id);
    public Customer getCustomer(String id);
    public Map<String, String> getCustomerHistory(String id, String code);

The ICustomerService is quite straight-forward. The implementation is where it gets interesting.

//Don't forget to add this into Tapestry5's service registry using binder.bind()    
    private Messages messages;

    JsonSystem system = StandardConfig.createSystem();
    public Customer getCustomer(String id) {
        JsonObject obj = getCustomeFromWebService(id);
        Customer customer = new Customer();
        // various gets;
        // lets skip to the interesting parts
        return customer;

    public JsonObject getCustomerFromWebService(String id) {
        StringBuilder url = new StringBuilder( messages.get("localhost.mywebservice") );
        JsonObject object = system.get(url.toString()).asObject();
        return object;

The first thing here is getting the URL of my web service - which I'm hosting locally. My dilemma was how to do this not in code so if the web service URL changes, I don't have to recompile. My answer was to use the Tapestry5 global properties via the messages catalog. All Tapestry5 web applications have this properties file in the WEB-INF folder. All you need to do is just @Inject the org.apache.tapestry5.ioc.Messages object and then you have now access.

The next bit is using ItemScript. ItemScript is very good JSON toolkit. I think you have noticed that getting JSON data with ItemScript is quite easy. Just create a JsonSystem object and then supply the URL. You should then get a JsonObject which now you can parse for data.

The final parts is just basically now use the new service. We'll start with the file.

    private ICustomerService iCustomerService;
    public Customer getCustomer(){
        //let's try out our web service
        return iCustomerService.getCustomer("2033405");

The Index.tml file is just as easy. Add this right after the ${message:greeting} line.

<p>Test Customer</p>
<p> ${Customer.firstname}, ${Customer.lastname}</p>
<img src="data:image/jpg;base64,${Customer.photoB64}" />

Here is a screenshot.
The guy in the image is Aristotle "yoyong" Ucab. He's the guy who wrote the web service.

I don't really know where the heck this photo was taken.

Anyway, have fun with this.

Sunday, August 28, 2011

Drupal Themes and Favicons

A favicon also known as a shortcut icon, Web site icon, URL icon, or bookmark icon, is a file containing one or more small icons, most commonly 16×16 pixels, associated with a particular Web site or Web page. Its that small image that you see on you Firefox tab along with the name of the webpage.

Clients like favicons but making one can be easy or hard, it depends on your approach. If you're old school, then you can use MS-Paint or GIMP or if you're like me,I cheat. I use a web favicon generator. I use favicon.ico generator. Most amazing thing about is that its free. FREE!

You have a favicon, you'll need to copy it to your theme folder. Make sure that is on the same folder as your .info file. Don't put in a sub folder like say img or css.

You'll need to edit your theme .info file. Here is a excerpt of mine theme .info file.

; ------- Declare default theme information

name        = LGR
description = Omega Sub-Theme for LGR
screenshot = screenshot.png
core       = 6.x
base theme = omega

; ------- Declare default theme features
features[] = logo
features[] = name
features[] = slogan
features[] = mission
features[] = node_user_picture
features[] = comment_user_picture
features[] = search
features[] = favicon
features[] = primary_links
features[] = secondary_links

The thing here is the theme features section where it says feature[] = favicon. This basically says to Drupal to look for your favicon on the same level folder where the .info is placed and use it. Normally, this is automatic to Drupal themes especially if you subtheme one of its many primary themes like Zen or Omega.

Monday, August 22, 2011's prepkit for Cisco640-802

I was asked to review's prepkit for Cisco640-802. I was intrigued. I immediately thought about comparing it to the other Cisco prepkits that I already know like Testking and Pass4sure. I was caught by surprise that Ucertify's prepkit was very different than that of the other guys.

The other guys had a question dump packed into the database. Ideally, this would work for you if you are already experienced in the field of computer networking and need to get that certification fast. But this would be a disadvantage to someone without the training or experience. Sure they can memorize by rote the answers to the questions but I doubt that they understood anything. This is where Ucertify's prepkit comes in.

Enhance your understanding
The prepkit is like this whole ecosystem of learning Cisco in a single piece of software. Not just Q and A database that you can browse.

The prepkit has this "Enhance your understanding" section which I find very nice. It complements the study helper (AKA study guide) that comes with the prepkit.

The prepkit has this "Create a fixed time test" feature. I thought it was a hooky feature until I tried it out. It basically allows you to create limited time test. Say you have a break for 15-minutes, you can spin this up and get a custom 15-minute test which can be in "Test mode" or "Learn mode".

You see, Ucertify prepkit test has modes like "Test mode" and "Learn mode" when its time to do a test. The difference being that "Test mode" lets me see the feedback at the end of the test while "Learn mode" provides me with the feedback immediately after each answer.

So far, I am very impress with Ucertify's Cisco prepkit and I haven't tried out every feature out yet. I would certainly recommend this to someone who wants that Cisco certification with the actual skills to back them up. Let's face it, how many people do you think you can convince when all you can do is talk and not the walk?

Friday, August 19, 2011

Rediscovering blog syndication on Facebook

This blog of mine always had a feed but I didn't use it much other than that odd programming experiment like trying out that new library for parsing XML data. That was until someone at mention that you can add your blog post into your Facebook wall automatically. You betcha the light bulb went TING!

Someone needs to update that Help page!
So jumped to Facebook's help center to read up on using this feature. You should get the sense that you'll need to use the "Notes" application for this. But that when things started to go a little bit sideways.

There is no "Import a blog" link in mine. WTF! But no worries, I did figure out what the "Edit import settings" is all about. And the link is not on the right side of the page.

With that solved, now I can automatically publish my post into my Facebook wall once I save it. Gravy!

Wednesday, August 17, 2011

And then one day....CM7 came

Yes you read that right! CyanogenMod 7.1.0 can now be installed on your Cherry Mobile MagnumHD and I have pictures to prove it!

Well...its not exactly my phone as of yet. I pulled that one from the XDA-Developers site. But it shows that you can now install Cyanogen on your Magnum. The CSL-Mi410 is basically the same phone as the CM-MagnumHD.

For the full set of images proving this fact go here.

As for me, I'm waiting for a bit. The images were put up on August 13, 4 days before this post. I'm taking a see and wait approach.

I'll probably try it out this weekend or something.


Monday, August 1, 2011

Maven and db4o

db4o (database for objects) is an embeddable open source object database for Java and .NET developers. It is developed, commercially licensed and supported by Versant.

I use db4o on a lot of personal projects. I even have started using db4o on a few of my Android projects. But I keep looking up that Maven snippet for adding db4o. So that snippet goes something like this:


By adding this snippet to my Maven POM file. I should be adding the latest db4o jars to my project. db4o is currently right now on its 8th version.

Thanks to Pascal Thivent for this. Hey, you gotta give credit where credit is due. Edit(5/1/2012): changed repository url and artifactId

Saturday, July 30, 2011

Singapore and Back

So, I just got back from Singapore and I have seen what Cagayan de Oro can be. DAMN. Clean, efficient, orderly and modern but unfortunately there are a few things amiss.

1. MRT Zombies. They give a whole new meaning to Skull Candies. They have headphones - the noise canceling kind (headphones that you stick inside your ear) but I can still hear the techno music that they are listening too. How loud is loud? No wonder they stare into space and get cranky when you ask for directions.

Going to see that iconic Singapore mascot:
The Merlion

2. Old people OK but the kids are likely to flip you off. By kids here I mean the teenagers and up. Now, I don't mean every kid here but you just get that vibe.

3. The heat! I wasn't expecting Singapore to be that hot. I wasn't sweating. I was melting. But then again, you could always duck inside a mall or MRT station.

4. That horrible Singlish. Singlish is a crime. Its even worst than Taglish. What's even worst is that they think that they are speaking good English.

Aside from that my Singapore experience was exceptional. I should say that everyone should go and see Singapore. Its just a 4 hour flight from Cebu and its not like you'll feel out of place as a Filipino. Roughly, 1 in every 5 Singaporean is a Filipino. Go figure.

Monday, June 20, 2011

CM's update and their s****** instructions! AMP!

Last week Cherry Mobile just release their update for the MagnumHD. Thanks to Aryan Limjap for the shoutout telling me about it. Its a nb0 file about 160MB which uncompressed to about 402MB. Sweet, right? Screw that, they goof the instructions.

They said to download the file, and copy it into your SD card. No problem unless your one of those asses who didn't buy a SD card or believed he didn't need one. And if you couldn't afford one, then you might be simple be screwed. Fine lets move on.

Next, they said to enter bootloader mode - done by pressing and holding the volume up + down + power buttons. Now, they didn't explicitly say to hold all three buttons down at the same time. Unless, you're like me, you'd be forgiven if you thought that you should press and hold the volume up then down and then power in sequence. But then again...You're such a newb.

Now, you should Press ‘Home’key to show the update utility. Use the volume buttons to select the option “Download nb0 from SD card”. I think this is where it gets scary for you tadpoles. You should see a bunch of text popping up. Now if it says something to the effect that is was successful then no worries. But if not, then you'll have to do an extra step.

You have to rename that stupid file: FB0-318B-0-5019-A01.nb0 to say firmware.nb0. After you have rename it just re-enter the bootloader mode. And redo the whole "Download nb0 from SD card" procedure.

BTW, make sure that you have atleast 70% battery when doing this. We don't want any bricked CM Magnums, do we?

One more thing, by doing this, you will need to root your phone again. Yeah, I know, what at bitch.

Friday, June 17, 2011

How I see things: A Drupal devel to a Drupal Designer

Its hard dealing with clients that are so...."technologically challenged". You would think that with a designer, things would go a bit easier - well not exactly. As a Drupal developer, I had done my fair share of hand-holding first time designers working on their first Drupal site - also true for clients.

From experience, first time clients and designers need to understand that we simply won't always see eye-to-eye on all things when it comes to Drupal.  All this reasons have been confirmed by a recent research done by the University of Minnesota on Drupal Usability.
  1. Drupal terminology confuses clients and designers alike. Words like "node", "block", "views" or "module" have different meanings to clients and designers compared to what I understand what they mean in the Drupal context.
  2. Clients and Designers see different things when looking at a Drupal webpage.
  3. How they see and what I see
  4. Drupal doesn't really make distinctions between frontend and backend - Yes, I am taking about clients familiar with Joomla.
  5. As a developer, I don't do design that well. As Forrest Lyman (of Pro Zend Framework Techniques) said:
    A great deal of this boils down to one of the most striking differences between programming and design:
    • The foundation of programming is binary logic; there is a right and wrong way to implement a given algorithm.
    • The foundation of design is how your brain interprets what it sees; since everyone interprets things differently, it is impossible to say whether something is right or wrong.
    True That.
Go with the flow, I guess. What else exactly am I gonna do other than educating them?

Thursday, June 2, 2011

Make up your mind! - How an error made me "ang amp @#$@#!"

I admit that I don't really use Microsoft software but that doesn't say they don't put out some fantastic stuff. So I decided to check out Microsoft's Expression Web 4. EW4 is for web design, also lucky for me the university that I am working for had an academic alliance license for it. Woohoo!

It should have been a straight-forward procedure installing EW4. But it had me to jump a couple of hoops.

First, I had to download the .NET 4 framework. Fine. OK. No problem. So, I got the web installer and ran it. Being a web installer, I had to wait for it to download the whole thing.

I also got Silverlight. What fun would I have with I couldn't run all those cool demos from EW4 without Silverlight. BTW, getting Silverlight should be pie if you are running Windows 7.

With everything set, ran the app and I then ran into this error:

I don't know about you but the error confused me. Take a closer look: "is either not designed to run on Windows..." Not designed to run on Windows? Are you sure?

Anyway, I did fix this error...eventually.

Tuesday, May 17, 2011

Rounded Corners in Drupal - the easy way

Doing rounded corners is pie in Drupal. There's really 3 "real" options.
  1. Do it with a module (
  2. Do it with hardcore CSS + images
  3. Do it with jQuery
I don't know about you but options 1 and 2 take too much work (for me anyway). So, I went option 3 and let jQuery do all the work.

You start off by downloading the jQuery corner plugin. This is a sweet little plugin written by Dave Methvin and Mike Alsup. After downloading the corner plugin, copy it to into the /js folder of your target theme. Create the folder if it doesn't exist.

Refer to the screenshot to the right. If you are wondering, I am using Netbeans 7 and that is a partial screenshot of my workspace.

After that create a second js file. I named by icc960scripts.js. This is where I wrote the javascript to use the jquery corner plugin. Here is the content in mine:

$(document).ready( function(){

    // the top part of the block
    $('#sidebar-last .block h2, #header-regions .block h2, #main-content .odd h2').corner("top");

    // the bottom part of the block
    $('#sidebar-last .block .content, #header-regions .block .content, #main-content .node-content ').corner("bottom");


Top part of the block is an H2 element which is rounded only on the top part. And then bottom part is a
DIV element with a border. You might have to override (or modify) the node.tpl.php template if you are using a template with a different markup.
Screenshot from firebug of the HTML structure
Rounded Block
What left is just to add some CSS to make it look good. Here's how mine turned out. The header background color is #CBB859 and the border value of the div is 1px solid #ccc.

BTW, don't forget to declare the scripts in the .info file of your Drupal theme.

; ------- Declare default javascript includes
scripts[] = js/jquery.corner.js
scripts[] = js/icc960scripts.js

It should be easy to figure out that the same technique can be applied to other elements in the Drupal theme output. Experiment and see what works and what doesn't!

Wednesday, April 20, 2011

Dealing with duplicate taxonomy terms

I haven't encountered this views bug until last Monday. I was working a view where I needed to show unique taxonomy terms in a grid. I was setting up something along the lines of "browse by category" view and what I got was a grid filled with multiple/duplicate terms.

Knowing the error, I started googling for answers but that exercise just made me run around in circles. Until I got to himerus' blog (he's also the guy working on the omega theme, you should check it out) and a node.

With the solutions I started trying them out. I settled for the "custom" module solution. The first time I tried it, it didn't work right off the bat. Take a look at the code:

// $Id$

* Implementation of hook_views_pre_render
* This function is in place to filter out duplicate taxonomy terms
* From listings. It will cycle each result, and store a new array of
* unique terms, and when a duplicate is found, will unset that result
* @param $view
function your_module_views_pre_render($view){
// first we make sure we are dealing with the correct view
if ($view->name == "your_view_name") {
  // create our array for comparisons
  $unique_tids = array();
  // let's cycle through each default result, and do some dirty stuff
  foreach($view->result AS $k => $result){
   if(in_array($result->node_node_data_YOUR_FIELD__term_data_tid, $unique_tids) || !$result->node_node_data_YOUR_FIELD__term_data_tid) {
    /* we already have seen this TID in the results, so blow that crap away
     * also will blow away any that are empty for some odd reason
   else {
    // this is a term we haven't seen, so let's not blow it away, but add
    // it to our array of unique id's to present as the "true" result of this view
    $unique_tids[$k] = $result->node_node_data_YOUR_FIELD__term_data_tid;
  /* now, we have an accurate unique list of terms in $unique_tids
   * next, we cycle those to reorder the crap random ordering
   * since these tids were pulled from the nodes in the order they were
   * set to sort from the node type view
  $alpha_arr = array();
  // cycle each of our unique tids, referencing the original key of the view->result array ($k)
  foreach($unique_tids AS $k => $tid) {
   // we need to grab the term now, not the tid to sort alpha
   $alpha_arr[$k] = strtolower($view->result[$k]->node_node_data_YOUR_FIELD__term_data_name);
  // sort the array, maintaining the $k key so that we may again reference back to the original data
  // create new array of results to overwrite the current one
  $new_results = array();
  /* cycle one last time now that we have unique terms, sorted alphabetically
   *    the point of this is to now take our $k reference, and grab the original $view->result data
   *    that references this item
  foreach($alpha_arr AS $v => $term_name) {
   $new_results[] = $view->result[$v];
  // get rid of the original result set
  // replace it with our new, accurate result set
  $view->result = $new_results;

Take a look at the "your_view_name", node_node_data_YOUR_FIELD__term_data_name and node_node_data_YOUR_FIELD__term_data_tid items. It should be easy to figure out the "your_view_name" thing. Just replace it with name of your views.

The  node_node_data_YOUR_FIELD__term_data_name and node_node_data_YOUR_FIELD__term_data_tid items is slightly different and made me to install a devel module to figure it out. Take a look at the $result array, I relized that I needed NOT to use the node_node_data_YOUR_FIELD__term_data_name or the node_node_data_YOUR_FIELD__term_data_tid but instead used a much shorter array key. So instead of "node_node_data_term_id__term_data_tid" use "term_id".

What's left is to turn on the module and flush the cache.

You should be golden!

Tuesday, March 29, 2011

Fixing that buggy stock ROM on your CM MagnumHD

My phone's
home pane
For those who are lucky enough to get Cherry Mobile's MagnumHD, we all can agree that the stock ROM f***** sucks. I really mean it sucks - the random restarts, the FCs, context buttons stop responding and the the most annoying is the screen times out (i.e. blacks out) when you make a phone call. So, being a geek, I will have none of this and I started scheming (along with Aryan Limjap which BTW, provides us the lovely images attached to this post) to get a fix into my CM Magnum. Warranty be damn!

System Pane
And what do you know, the Indians Indonesians came up with a better ROM. As you can see I'm now running a Wellcom-A99 ROM on my CM MagnumHD. I can tell you it runs better, cooler and longer. Also I would like to point out the Android version 2.2.2. I will still flash this thing to 2.3 when it comes out. But trust me on this, MY PHONE IS RUNNING BETTER on this ROM.

You might wonder how is this possible, then you apparently didn't inherit enough "bright" genes from your parents. But to get my point moving, CM MagnumHD is OEM phone from Foxconn and is rebranded in a lot of other countries.
  • Philippines - CM MagnumHD
  • China - Huawei Ideos X6
  • US - Viewsonic ViewPad 4
  • India Indonesia - Wellcom A99
  • India - OliveSmart V-S300
With the Apps
And that is why children, I can stick an Wellcom A99 ROM on my CM MagnumHD. But still want to beat this into your head, if you are doing this you are voiding your phone's warranty. As for me, I already voided mine when I rooted my phone. Refer to the screenshot with the apps.

So if you understand what I am telling you and you still want to flash in the Welcomm ROM then click here. Just scroll down and look for the link. The download is about 200MB. 

And btw, did I mention to you all that there's still a slight chance that this will put your phone into a boot-loop or (worse) brick your phone?

Edit: Mecha50 corrected me that the A99 ROM is Indonesian. My bad.

Friday, March 25, 2011

Yeah, I run Ubuntu...Wanna make sumthin' out of it?

Yes, I know my desktop looks cool. It also very, very sweet! My 3 year old ACER laptop which has only 1gig of RAM is running quite smoothly and responsively. To quote yoyong ucab,
"Best performance kaayo."
Trust me on this - when you see this thing run Vista, it makes you wanna cry. Vista is the OS that was bundled with this thing when I bought it and it so f'in slow. And to add insult to injury its Vista Starter. Yes. It's the fork-over-more-bucks-so-you-can-run-more-than-3-apps Vista Starter OS.

You will also notice that I got Netbeans running on this thing. I am a developer after all and its gravy. I even got to sync my code from my repo.

You should be looking at Ubuntu on you next laptop. I'm beginning to question the wisdom of paying for the "other" operating system when there's this.

Now, I wonder if I can set this one up as an Android dev/test machine...hmmm.

Sunday, March 13, 2011

Using JQuery to read an external XML file

A student of mine asked me this question. He wanted to read an external XML file, parse it and load the data into a HTML Form control. In his case, he wanted to populate a select component (combo box). And he didn't want to use any PHP, Java or whatever. So that leaves me with JavaScript and HTML. This intrigued me for a bit. I haven't tried anything like this before.

So after a bit of research I stumbled into jQuery.ajax. I am familiar with jQuery - been using it for a bit so this should be quick. So, we prep the HTML file for our display:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Parsing Data from a File</title>

        <link rel="stylesheet" type="text/css" href="css/demo.css" />
        <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
        <script type="text/javascript" src="js/demo.js"></script>

        <h2>Parsing Data from a File</h2>
        <p class="compress">Data will be from an external file. It will formatted as an XML file
            (this could be easily be a html file). It will be be parsed using JQuery library.
            We could do this with raw JavaScript but why would you want to do that when
            there is a simpler solution?</p>

        <p>To learn in detail how this thing works <a href="">read this.</a></p>

        <div id="form-div">
        Our Combo box:
            <form id="form1" class="cmbox">
                <select class="combo1">
And here is the demo.js file that comes with that file. If you run both now you'll get an error. This is because we have to create a file called data.xml. You should also notice that in the demo.js file (refer to the comments) loads the data.xml if it successfully loads the file it should call a function called "parse" and should it fail it calls the "loadfail" function.
$(document).ready(function(){       // load jQuery 1.5
 function loadfail(){
  alert("Error: Failed to read file!");
 function parse(document){
     var optionLabel = $(this).find('text').text();
     var optionValue = $(this).find('value').text();
  url: 'js/data.xml',    // name of file with our data
  dataType: 'xml',    // type of file we will be reading
  success: parse,     // name of function to call when done reading file
  error: loadfail     // name of function to call when failed to read
Here is the data.xml file.
        <text>Option 1</text>
        <text>Option 2</text>
        <text>Option 3</text>
        <text>Option 4</text>
        <text>Option 5</text>

Do note that this will fail with Chrome because of its security model. If you look at the console it will not allow you to load local files because of Origin null is not allowed by Access-Control-Allow-Origin. Whatever that is.

Thursday, March 3, 2011

Your Nexus One or Moto Droid suck balls

Screenshot after benchmarking
with Quadrant
Being the idiot that I am, I got sucked into a "hot" debate on which Android device is faster. And as we all know, everyone wants to say that they have the "better" device. Well, they can all kiss my phone's ass! So talked about it and we agreed to use a benchmarking tool and get the bottom of this. We all got this benchmarking tool called Quadrant from the Market. It free by the way. And well all agreed to get the Standard Edition. This would be the 1.1.7 version with a build date of Feb 1, 2011.

And let the benchmarking begin! And my Cherry Mobile Magnum HD kicks all their asses! And then some!

The graph does not lie!

"Screw that. The results your getting must be a fluke." they said, I then replied: "I don't know. Am I the one bending over and getting screwed?"

I couldn't begin to tell you how big my grin was walking away.


Saturday, February 26, 2011

Void your warranty and root your CM Magnum HD at the same time

This is basically a repost of Takahiro Sonogi's post over at PHAC. He posted a way to root your Cherry Mobile Magnum HD which is also known as Viewsonic ViewPad 4 and Huawei Ideos X6 (also known as Huawei U9000).

There a lot of reasons to root your Magnum HD, one of them is to void your warranty. The other good reasons are:
  1. To install custom ROMs. The problem is just that the device is so brand spanking new that there are no custom roms...yet.
  2. To turn it into a target dev device. Which is my reason. It just sucks writing code that needs access to some /system binaries and get cock blocked because its not rooted.
  3. Its Friday night and got nothing to do. Ok I made this one up.
In any case, I'm telling you again ROOTING YOUR CM MAGNUM VOIDS THE WARRANTY. I want to be clear about that.

Now if you are one of those Windows GUI babies and doesn't know his way around CMD or DOS you are way over your head. Stop what you are doing because YOU MIGHT BRICK YOUR PHONE AND I WILL LAUGH AT YOU. You heard me, if you screw this one up and blame me, I. WILL. LAUGH. AT. YOU.

If you haven't changed the webpage then download and install the Android SDK.

Here are steps to root your CM Magnum HD

adb devices
  1. Take your Magnum and plug it in into your PC and make sure it is recognized by ADB. Run ADB from the command line and type adb devices. If there are no devices, then you need to install something like a USB device driver. There should be on with your phone. Whatever the case you are looking for something like the screen shot on the right;
  2. Then download something called rageagainstthecage. Unpack it and put it somewhere where you can get to it from the command line. 
  3. Copy the rageagainstthecage-arm5.bin to /data/local/tmp folder on the device:
    adb push rageagainstthecage-arm5.bin /data/local/tmp
    adb shell
  4. Now do a CHMOD and run it:
    chmod 755 /data/local/tmp/rageagainstthecage-arm5.bin
  5. Get a copy of Superuser (SU) and busybox. Now unpack it. Do the following:
    mount -o remount,rw /dev/block/mtdblock3 /system

    adb push su /system/xbin
    adb push busybox /system/xbin
    adb push Superuser.apk /system/app
    adb shell

    chown 0.0 /system/xbin/su
    chmod 6755 /system/xbin/su
    chmod 755 /system/xbin/busybox
    chmod 644 /system/app/Superuser.apk

    ln -s /system/xbin/su /system/bin/su
  6. Reboot and redo step 1. Once you get your PC to recognize your phone do the last step.
  7. Got root?
  8. And for the moment of truth, if you haven't bricked your phone yet, time to see if we really have root access. Refer to the screen shot. You are looking for the "#" symbol. You might have to accept a prompt from your phone.
If you got this far, congratulations. You just voided your phone's warranty and rooted your Magnum HD at the same time.


      Tuesday, February 22, 2011

      Screencaps from my new phone

      So, I got a new phone yesterday. I decide to get something that sweet and Android. Sweet! I had to drag my resident Android ph33rk to come with me when I decided to get this phone. It's always nice to have someone who knows his stuff to help buy, well...stuff. So a shout out to Aryan Limyap.

      "BAI, Don't hate." ;-)

      So what phone Did I get? I got the Cherry Mobile Magnum HD. And anyone who said shit about Cherry Mobile either doesn't own one or doesn't know crap about buying a smart phone.

      The price is steep but not that painfully when you think about getting a Galaxy5 or HTC Desire at 30k. That's at least a 10-12k different. On a side note, the CM Magnum HD specs kicks the Galaxy5 and HTC  Desire specs in the ass.

      I paid 20k for mine because I had to get a 16G MicroSD card. I am also thinking of shelling out a couple more hundred buck to get a quality screen protector and case for it.

      Yeah, I know you might hate me right now. Especially, my sister who is one of those rabid and lunatic Apple users. I love you ngit but "heck no, I ain't getting no IPhone."

      Here are more screens:

      phone screencaps

      Sunday, February 20, 2011

      Springing DAO: Spring + Hibernate (Part 1)

      So now that I have a rough idea I could get this puppy to code. We are winging it after all. Then again, software development is really like this. Hey, I have made projects with even less.But lets got get ahead of ourselves. Before we write anything, we have to deal with the database design.

      Now about the database, I am using the MySQL that comes with XAMPP. Its free for the download and it already comes with phpmyadmin. I know I can do this "old school" and go command line but who needs that aggravation. Masochism isn't really my thing.

      Using phpmyadmin, here is the schema.
      Figure 1 Our project database schema

      *Now if you say this can't be done just by using phpmyadmin alone then apparently you are using it wrong.

      The design is quite straight-forward. There are four primary tables:
      1. User Table - contains the log-in and password recovery data. Its support tables of role and user_detail is quite easy to figure out.
      2. Request Table - handles all the request generated by the users. It should be noted that creating a request doesn't mean you automatically have an "approved" avr reservation.
      3. AVR table - contains the available AV rooms that can be reserved. The "isAvailable" flag is used if the AVR can be reserved and is not under repair or something.
      4. Status table - it tracks the state of the request. If you can recall in my previous post, the flow chart logic is on this table. On a side note, the "set_by" field should be linked to the user table via a foreign key.You should be able to figure that one out.
      Stay tune for part 2 when we actually starting writing code.

      Saturday, February 5, 2011

      What exactly are we up to?

      First thing first. We have to agree on a couple of points:
      • I will be using Netbeans for this - you could use Eclipse if you want.
      • We will be using MySQL
      • We are going to make a web application using Vaadin
      So to start off by setting up our environment. What we are going to need are:
      Download it, copy it off someone whatever. The sooner you get the stuff into your dev machine the sooner we can talk about what exactly are we up to?

      Figure 1.0 Installing the Netbeans Vaadin plugin

      Have it? Installed it? Good.

      What we are going to build/make/develop is a facility-reservation system. So what exactly will our "FRS" application be doing? Here are our requirements:
      • All reservations must be submitted and processed online
      • Must have AAA type security
      • Granular user permission system
      • Resolve scheduling conflicts
      • Track histories like facility usage, request status, room schedules, etc.
      • Have a basic set of reports (exportable to PDF)
      Figure 1.1 FRS Flow Chart
      Our FRS web application is not that complicated. Take a look at the flowchart. A request is made. The request data is quite simple. It contains the facility being requested, when its to be used, how long its to be used and for what purpose. The request is of course submitted by a user authenticated by the web application. Anonymous users can't submit make a reservation request. The request is then evaluated by someone with higher privileges say an administrator. The request is then either disapproved, approved or rescheduled (or  reallocated). The request once approved does not end the cycle. It only ends when the request is carried out. This is done by a different role or class of user.

      We will talk about the database design later in this series.

      Thursday, January 27, 2011

      Vaadin is what exactly?

      If you talk to a Finn, he will tell about Vaadin being a mythical creature in Finnish folklore, the goddess and divine ancestor of the mountain reindeer. They even got a song about it.

      Interesting, but not the Vaadin we should be thinking about.

      Now if you go to Wikipedia, it defines Vaadin as:
      "Vaadin is an open source web application framework for rich Internet applications. In contrast to Javascript libraries and browser-plugin based solutions it features a server-side architecture, which means that the majority of the logic runs on the servers."
      Technically correct, but it doesn't exactly tell you what to expect when programming or developing a web application using Vaadin. You read that right. Vaadin is for creating web applications - Rich Internet Applications if you want to be an ass about it. The key thing with Vaadin is that it allows you to make these web app without writing a line of HTML or CSS. Ok, you can write HTML and CSS, but only if you really, really want to. Take a look at its design.

      General Architecture of Vaadin

      The architecture of Vaadin allows you write Java code as if you were creating a AWT, Swing or SWT application. You heard me! You don't have to write a line of HTML, CSS or even JavaScript. Because HTML, JavaScript and the other browser crap is hidden away, you won't be wrong in thinking that the web browser as a thin-client terminal or platform. Still not buying? Well, let's move on to an example. In the long tradition of hello worlds (if you don't get it, then you suck as a programmer), here a Vaadin "Hello world":

       import com.vaadin.ui.Window;  
       import com.vaadin.ui.Label;  
       public class HelloWorld extends com.vaadin.Application {  
         public void init() {  
           Window main = new Window("Hello World");  
           main.addComponent(new Label("Hello World!"));  

      That's it. No HTML template, no JavaScript. Here is the screen shot of web app after it has been compiled and deployed.

      That shouldn't be that hard to figure out. I just wrote Java code, a very short one and made a working web application. Can you spell chuyness?

      Wednesday, January 26, 2011

      Swing-like Chuyness (My Vaadin course of beginners)

      It's that time of the year again where I had to teach yet another batch of students. This time I don't think I'll be doing Tapestry5 again - You don't repeat the same gag, to do the next one. So, what is the next gag? This time around it's Vaadin. I wanted to learn how to use Vaadin ever since a former student of mine showed it to me. So, I plan to build something using Vaadin and take my students along for the ride. 

      Like my Tapestry course, I will walk you through a complete web application development from design to deployment using the Vaadin framework. I think you should read "walk you through" like "we will be winging it". Making good lesson plans isn't really one of my strong points.

      The course will look like something this:

      1. Vaadin is what exactly? 
      2. What exactly are we up to?
      3. Springing DAO: Spring + Hibernate
      4. Breaking Tradition: GUI programming for webapps
      5. Tweaking out! 
      6. Coming back alive: Deploying for WAR
      This isn't exactly set in stone, more like something I just pulled out of my ass. So if there's something missing, we will deal with it when we get to that bridge. We will make up the requirements and specification as we move along.