Wednesday, September 25, 2013

Styling Apps In Android - Not for the Faint of Heart

If it's one thing I would like to see in future Android APIs is more support for the artistic side of app creation.

Coming from a Web/CSS background, I was expecting things like drop shadows, gradients, rounded corners, selective border colours etc. to be relatively easy to implement. As it turns out, it's not. For example, getting rounded corners on an ImageView involves a fair amount of coding (as illustrated here: http://stackoverflow.com/questions/16208365/create-circular-image-view-in-android). It's especially hurtful when doing the same in iOS is so headslappingly simple http://stackoverflow.com/questions/7705879/ios-create-a-uiimage-or-uiimageview-with-rounded-corners I just wish making my apps look cool was a much easier process.


Anyway, if anybody feels the same way, knows of easier ways to achieve aesthetic gold or if the styling and graphics APIs are supposed to get a reboot anytime soon, sound off in the comments below. 

Sunday, August 25, 2013

Play Framework 2.x - Taking the Plunge


So after many months of kicking and screaming against being forced into the new 2.x.x branch of the Play! Framework I finally decided to take a weekend and learn the damn thing and get it over with.





Pros

Much more powerful and feature packed than the 1.x branch
In addition to some serious code optimizations and refactorings, things like an interactive console, built in H2 in-memory database browser and a built-in LESS and CoffeeScript compiler are just a few of the bells and whistles added on that really add to the development experience.

The Scala templating language is not as scary as it sounds
...And that's coming from a Java developer. Yes, I really enjoyed using this templating system even though some things took a couple minutes to really sink in. Parameter groups? What's that?

The new ebean ORM 
Though I've only used it to complete the Zen Tasks tutorial, i'm seeing that it requires a lot less hand-holding in the JPA annotation department. Give it a @ManyToOne annotation in one class and you don't need to go to the related class and set up the mappings. It's something I haven't seen done anywhere else (except Rails, I think) and it's nice to see it available here in sweet ol' Java. 


Cons

Not as friendly, free form an "playful" as the 1.x branch. 
Doing the simplest of things requires a lot more typing, planning and thought now. Gone are the days when I could have just done this:

public static void updateUser(User user) {
 user.save();
 render();
}

Now I have to do:

public static void updateUser() {
 Form userForm = form(User.class).bindFromRequest();
 User u = userForm.get();
 u.save();
 ok(views.html.users.updateUser.html);
}

This approach provides certain advantages, but it really takes away from the appeal and fun I had with the 1.x approach.

Documentation is a bit lacking
I wish the documentation could have been organized better and be more detailed a la 1.x. Certain sections like Forms and Action Composition could use a little attention.

Searching for help turns into a hunt
Searching for help online usually returns 1.x or 2.x Scala results. This is not helpful to a 2.x Java developer.

Other Thoughts

I've been a big fan of the +Play Framework since I walked away from Rails over a year ago. I haven't looked back since. Part of what made me fall so madly in love with it was it's power without being verbose; elegant simplicity without the need for me to get embroiled in XML files and the like. I could have hardly believed it was Java I was using!

As of late though, it's become a bit heavier and less of a tool that I could use to knock out a prototype in no time flat. Don't get me wrong, it's still miles better than Spring or Struts (shudder), but it's just not as free form and delightful as it was when it was younger. I do understand, though, that some of its "agility" was sacrificed to introduce better optimized code and more powerful technologies, so I guess I'll just file this under the price of progress.


For those of you wondering why I took a weekend, this included getting comfortable with +IntelliJ IDEA and wrangling with the many technical issues that came up with the Scala and Play2 plugins. IntelliJ is a marvelous IDE and has proved me wrong in believing that Eclipse was the be all and end all of Java IDEs, but I think the Play 2 plugin could use some work. It won't, for example, let me reference a template via index.render(...), so I have to do views.html.index.render(...) or import views.html.index before I can call the render method. It's a minor issue, but majorly annoying when I'm trying to dance my way across the keyboard to project completion.

Conclusion

In closing I'd like to say that Play 2 is not the horrid, complex mess I thought it was. Sure it's a bit different and sure i'll have to wave goodbye to some of my old habits, but the framework has been made better and future proofed for tomorrows web application developers. I really appreciate all the hard work that +James Ward and the team at Typesafe have been doing. 

Here's hoping that Play 3.0 will be backwards compatible!




Sunday, May 26, 2013

Why I Am Choosing the Playstation 4

It's almost that time again, folks - the time where we choose our allegiances for the next generation of the console wars, while berating and ridiculing anyone else who chooses a system different to the one we chose.

Now before I begin, I must declare that this post is not titled why you should choose the Playstation 4, but why I am making it my companion for my next romp in the Elysian fields of console gaming.

Why the Playstation 4?

One word: Exclusives. I am most interested in the properties that are tied to the Sony brand than any other platform. Why buy an Xbox or an absurdly powerful PC when I will only end up quaking nervously to find out if Hideo Kojima will ever release his next game for anything other than Sony Playstation. It simply doesn't make sense.



When that next MGS/Uncharted/The Last of Us drops, I want it IMMEDIATELY.

What's Wrong with the Xbox?

Nothing at all. As a matter of fact, I have never owned an Xbox to find out what are some things I may not like about it. As for whether or not I will even consider picking up an Xbox later down the line, it's a possibility should there be a piece of IP that is just that good that I absolutely have to have it.

Currently though, Halo just isn't my thing and the new Xbox One's slew of living room features just don't make a compelling enough case for me to pick this thing up on day one.

You Fool! PC is Where It's At!

And you maybe right, more so in this console generation than ever. For those of you who aren't acquainted with each system's technical specifications, these new systems are basically just PCs with a smaller form factor and features that make them more suitable for your living room than for editing PowerPoint presentations.

Be that as it may, I have a very awful taste in my mouth regarding PC ports of last generation's games. I found that far too often I had to become this great PC hackboy to get some of my favourite games to work well. When it wasn't replacing particle files to fix visual glitches, it was simply a case of poor PC optimization on behalf of the developers. I'm looking at you GTA 4.

Worse yet, all of my PS2 faves like Vice City and San Andreas just didn't carry over well once I started getting more modern hardware for my PC. I actually had to install a video card "hack tool" to get them to play properly on my Radon 6670. Not to mention the laughable support for more recent joypads.

These are issues that console gamers simply don't have to worry about, but were my nightmare almost every time I installed a game that was ported from the consoles to PC.

Sure you can throw the argument about better graphics and modding ability at me, but the truth is I never really cared for mods and I remember enjoying Vice City immensely on the PS2 in all it's buggy and glitchy glory. I'm prepared to sacrifice a bit of visual fidelity for the sake of a hassle-free gaming experience.

Now it may be safe to conclude that the source of all of the last generation's PC ports were so terrible due to the Playstation 3's Cell processor and that this generation's ports may be much better due to the fact that both consoles are using more standardized PC-like hardware, but that remains to be seen.

I may still end up build a gaming PC to catch the odd game or two that are "tremendously better on PC" but i'll be taking my time with that project.

In conclusion/TLDR:
  • I'm choosing the PS4 because I like the exclusives.
  • I'm not choosing the Xbox One because I don't really care for that platform's exclusives.
  • I'm not choosing PC (from the get-go) because of the terrible console ports of last generation.
  • You are free to decide which one you want to go with.




Thursday, January 17, 2013

Today I Fed A Man

Walking in to my new neighbourhood convenience store, I caught a whisper of a beggar asking me for some change. I mostly ignored him and continued on.

While inside the store his voice ricocheted around the inside of my head like a vindictive stray bullet. I wrestled with logic and my humanity as I weighed the pros and cons of giving this beggar some money - if I give him cash he'll probably spend it on drugs, so maybe I should default and give him some food instead.

By the time I came to this conclusion I was already out the store, groceries in hand.

I saw him looking at me expectantly, all the while counting up some singles and fives; his day's take I guess.

To put an end to this absurdly long thought process I just reached into my pocket and handed him two of the singles that happened to be in there. He accepted it graciously.

A few minutes later, my short term memory kicked back in and reminded me that I needed some matches. There was a small parlour across the street,so there I headed to make my last purchase.

As I'm standing by the counter counting my pennies, up comes the beggar behind me and with the fives and singles he was counting, purchased a small loaf of bread, a snack and a drink. He then looked at me, the delight in his eyes shining through his bushy eyebrows, and said "thank you brother!"

At that point I swore I could feel the Holy Spirit smiling at me and nodding in approval. Best feeling I had all day knowing that I fed my saviour.

Friday, December 07, 2012

It's About Doing Something Good

It's not always about the fame and the fortune. Sometimes it's as simple as saving someone the headache of having to get a new ID card, passport or driver's permit.

I was saved from this torment twice and now I think it's time I return the favour to my countrymen.


Friday, November 30, 2012

Fixing a Problem

Problems. They're everywhere, especially in my country. They range from simple annoyances to huge socio-economic issues that will take a large amount of effort, money and divine intervention to cure.

As humongous or diminutive as problems might be I believe that the solutions to them come about by chipping away at the issue in a very incremental manner. It just takes time and a fair amount of consistency, but eventually the problem will dissolve.

But what about this case - what do you do in a case where the solution to the problem is so simple, yet the people for whom you are solving the problem are too paranoid and distrusting for them to even dip their toe in the solution unless they see someone else drinking the proverbial Kool-Aid first? What do you do then? What becomes of the problem? Can it still be classified as a problem since nobody seems to want it solved or everybody balks at the presented solution?

There is a culture in my country that says no solution (or product in a general sense of the word) is any good unless millions have been spent in creating it is presented with lavish press conferences and promotional campaigns. I honestly find this highly annoying and it shows where we are as a people in terms of our mental development.

I'm daring to change that culture and see if I can bring my country even one step closer to the 21st century. That's why I'm challenging myself to fix a problem that plagues everyone in my country, and i'm going to fix it with a budget of $20USD and I want to see how my countrymen react to it. It's going to be practical, free and simple to use. Let's see how it goes.






Thursday, August 23, 2012

jQuery QR Code Generator

So I came across a QR Code (2D Barcode) generator tonight that is written in pure JavaScript, relies on jQuery and makes 0 calls to any external API.

It's called jQuery QR Code and it's written by Jerome Etienne. Take a look at his GitHub project and tell me  what you think. This will definitely come in handy on my current project!

Saturday, March 03, 2012

Fixing Ubuntu Issues: No Wireless on Reboot

Continuing on with my series on solving problems I've encountered while using Ubuntu 11.10, I've found yet another solution to a problem that I heard a lot of people talking about. It's also a hot topic on the Ubuntu forums. I',m speaking, of course, about Ubuntu and wireless internet access.

In recent times it has not been uncommon for Ubuntu to not be able to connect to my wireless network on boot up, so I did some digging and found out that the problem was that the Automatic DHCP IPv4 settings were to blame. My solution: use manual IPv4 configuration. Here's how.

My internet set up is as follows :- My modem is connected to my wireless router which propagates the signal that my PC's USB wireless adapter receives. There's plenty of networking going on there, (something I am not the best at) but I do know that finding out the IP addresses of my various pieces of network hardware will be the key.

So on my Windows machine i ran ipconfig and found out those addresses:

192.168.1.1 - My modem's address
192.168.2.1 - My wireless router's address (Default gateway)
192.168.2.5 - Address of PC
255.255.255.0 - Subnet mask

I took those settings over to Ubuntu, opened the network manager by clicking the Wireless icon in the top task bar, selecting Edit connections... > Wireless > FBI_VAN_467 (My SSID) > Edit... > IPv4 Settings and entering the information as follows:


I chose a random non-conflicting IP address for my Ubuntu PC's address, used my wireless router's IP address for my default gateway and set my DNS server address to my modem's address.

After that it worked like a charm. I hope this helps!


Thursday, March 01, 2012

New Search Engine - DuckDuckGo

After reading this very interesting and informative article (http://dontbubble.us/) and hearing mentions of it in the tech-o-sphere, I was intrigued to look into this DuckDuckGo search engine to see what it was about.

Now, anybody who knows me knows that I'm a G-Man (Google Man) through and through, but honestly i've not been to happy about their recent skirmishes with the law when it comes to people's privacy and the extent to which they will go to get your personal information so that they can target ads to better suit you.

Truthfully I was never a fan of the idea that I was being herded and processed by a big company that was going to use my personal information, my likes, dislikes, hobbies - my personality - to make money, but I had to tolerate it because it was the companies behind some of the best internet services that I use were doing this.

Now there's a new duck in the search engine pond and this one is more morally secure and less thirsty for money and is doing... just fine! I'm talking of course, about DuckDuckGo.

Granted i've only been using it for a grand total of 6 hours, I was very impressed with the speed, the relevance of the search and the cleanliness of the design... I'm just not too fond of the name. It doesn't quite adhere to the web 2.0 naming convention of 2 syllables, real/unreal word but I guess it sort of works for them. DuckDuckGo doesn't really roll off the tongue like Google or Yahoo or Bing but the name contributes to the overall playful charm of the site and to be honest, I would be reluctant to use another Web 2.0 named search engine like Searchly or Fynd or something like that.

A Sample Search

I did a Google search for  Railscasts and compared the results to those I found on DuckDuckGo. I preferred Duck's search results. They pointed to some more relevant resources.

Google Search Results

Results from the Duck
I personally prefer Duck's results. As you can see I snatched up the Railscasts them for Vim :) What do you think?

Friday, February 24, 2012

Validating Virtual Attributes in Rails 3.1

When validating virtual attributes in Rails it's important to remember that they are just that - virtual attributes. I spent almost an hour last night trying to figure out why my validations were throwing an error when I called Object.valid? My class was structured similar to the following (forgive me, I am a Rails n00b):
Class User

attr_accessor :password

validates :password,
:presence => true,
:on => create

validates :password,
:length => { :minimum => 6 :maximum => 8 },
:if => :password?
.
.
.
end
When calling valid? on the User object I got a method undefined error for password?. I could't quite figure it out and I was wondering what I was doing wrong until eventually I tried appending the following to the bottom of the class definition:
.
.
.
def password?
 self.password.present?
end
.
.
.
An seemingly simple and obvious solution, I know, but this took me about an hour to figure out after Stack Overflow failed me for the first time.

I hope this helps save someone else the frustration I endured.

Thursday, February 23, 2012

Fixing Ubuntu Issues: Ugly Font Rendering in NetBeans

Recently i've had the displeasure of working in NetBeans on Ubuntu. The IDE is great but the font rendering is terrible. Here's my solution to this problem.

The first step is to uninstall Open JDK (if it is installed) and install Sun's JRE. Do that by selecting the following packages in the synaptic package manager:

  • sun-java6-bin
  • sun-java6-jdk
  • sun-java6-jre

Mark all installed instances of Open JDk for uninstallation if you have to, then click Apply.

Confirm your Java version by going to the console and entering

java -version
You should see
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)
Now that that's done, install Microsoft's Core Fonts. Do this by going to the Ubuntu Software Center and searching for 
ttf-mscorefonts
Install them, then open NetBeans, go to Tools > Options > Fonts and Colours and choose the Courier New font. I set mine to size 18 bold. Here is my result:


Before


After

Wednesday, February 22, 2012

Fixing Ubuntu Issues: Restart Wireless Without Reboot

Sometimes after resuming from sleep, you would find that your wireless connection no longer works. Up until now, my only solution to this was to reboot. I've found an alternative solution from user mariosx on http://ubuntuforums.org/archive/index.php/t-913407.html that involves simply restarting the wireless interface. To do so, enter the following in a terminal window


sudo ifconfig eth1 down
sudo ifconfig eth1 up

Where eth1 = your network interface. Could be wlan0 or something like that. I have not yet tried this out, but it's one of the more sane solutions i've come accross for this problem during my searches.

Fixing Ubuntu Issues: Flickering Pointer

Upon instlaling Ubuntu 11.10 some of may notice that the cursor constantly flickers and sometimes disappears randomly. To solve this do the following:

Note: xorg.conf is depreciated in Ubuntu 11+

Type the following in a new console window:

cd /usr/share/X11/xorg.conf.d

sudo touch 10-monitor.conf

sudo gedit 10-monitor.conf

Paste the following into the file, changing variables where indicated by the comments

Section "Monitor"
    Identifier    "Monitor0"
EndSection

Section "Device"
    Identifier    "Device0"
    Driver        "nvidia" #Choose the driver used for this monitor
EndSection

Section "Screen"
    Identifier    "Screen0"  #Collapse Monitor and Device section to Screen section
    Device        "Device0"
    Monitor       "Monitor0"
    DefaultDepth  24 #Choose the depth (16||24)
    SubSection "Display"
        Depth     24
        Modes     "1680x1050" #Choose the resolution
    EndSubSection
EndSection

Save the file.

Press CTRL + ALT + FI to enter terminal mode and type the following:

sudo stop lightdm

sudo start lightdm

Log in and notice that the cursor does not flicker any more. You may have to unplug your mouse and plug in back in to get the cursor to work. If you do not get back to the graphical mode after starting the display manager, press CTRL + ALT + F7

Reference: http://ubuntuforums.org/showthread.php?t=1730188

Friday, July 29, 2011

Venturing Into Vim

So I heard that there's this new code editor out, and it's been out for about three decades now... so I guess when I say new I mean new to me.

As an aspiring Ruby on Rails developer, I looked around to see what was the best code editor I can/should use for handling the development of a RoR web application. The vote went almost unanimously to Vim - a minimalist as (according to its veterans) extremely powerful code editor.

So this week I took a journey into Vim land to see what all the buzz was about and boy was it a rough one. Vim is not Notepad++, Komodo Edit or any other code editor that you've used before, and that's a key concept to remember when learning to use Vim, because operating as you did in your previous editors will send you into a mad swirling fit of rage and confusion.

Vim is it's own beast. The fact that you have to press a key before entering text and press another key when you've finished entering text should tell you a lot.

After a week of use, though, I must say that I chose wisely in the investment of my time and I would like to encourage my fellow coders to do the same. Get in the know with this great (yet sometimes frustrating) piece of software; it's powerful, simple and fast.

There isn't an opinion of Vim that wasn't stated by Jeffrey Way over at his blog, so I'll leave it up to you do some further reading.


Happy Vimming!

Monday, March 14, 2011

Regular Expressions

I'm sure most of you from the programming world are familiar with regular expressions. For most of you that are from the programming world and aren't familiar with them - you should be ashamed of yourselves. I'm only this haughty because I only figured out how to use regular expressions LAST NIGHT. Can you believe that? In the middle of a large project where the deadline looms among the next sunrise and validation on a HUGE form is key, I learned to master the use of ye ole RegEx... But not without a large amount of help, though. I really have to give credit to the guys over at GSkinner.com for their RegExr tool. With this tool, I was able to turn my email address validation code from this :
function echeck(str) {

  var at="@"
  var dot="."
  var lat=str.indexOf(at)
  var lstr=str.length
  var ldot=str.indexOf(dot)
  if (str.indexOf(at)==-1){
     alert("Invalid E-mail ID")
     return false
  }

  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
     alert("Invalid E-mail ID")
     return false
  }

  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
      alert("Invalid E-mail ID")
      return false
  }

   if (str.indexOf(at,(lat+1))!=-1){
      alert("Invalid E-mail ID")
      return false
   }

   if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
      alert("Invalid E-mail ID")
      return false
   }

   if (str.indexOf(dot,(lat+2))==-1){
      alert("Invalid E-mail ID")
      return false
   }
  
   if (str.indexOf(" ")!=-1){
      alert("Invalid E-mail ID")
      return false
   }

    return true     
 }

function ValidateForm(){
 var emailID=document.frmSample.txtEmail
 
 if ((emailID.value==null)||(emailID.value=="")){
  alert("Please Enter your Email ID")
  emailID.focus()
  return false
 }
 if (echeck(emailID.value)==false){
  emailID.value=""
  emailID.focus()
  return false
 }
 return true
 }
 
 
To this :
function validateEmail(str) {
  var RE_EMAIL = /^[a-z]+[\w-_]+@[a-z]+\.[^@]*\w\w$/
  if(RE_EMAIL.test(str)) {
    return true;
  }
  else {
    return false;
  }
}
If you are like me and you never understood regular expressions, I would advise you give them a try. If you're a web developer, one of these days you are going to have to develop a form component that needs validation. Learning regular expressions is a definite time saver and I would suggest you invest the necessary time into learning them.

Saturday, February 26, 2011

Friday, February 25, 2011

Clients from Hell

Me: “Ok, we’ve pushed the site live.”

Client: “Why isn’t the site #1 on Google yet?”

Me: “We just pushed it live five minutes ago.”

Client: “Optimize the fireball.”

Me: “I’m sorry? Do you mean the firewall?”

Client: “I need more hits NOW, so I need you to optimize the fireball. I know what I’m talking about!”

Me: “We’ll get right on it.”

This is what makes my job so damn difficult. These types of clients.

Taken from: Clients from Hell

Tuesday, February 22, 2011

Productive Unproductivity

As a programmer, you learn to set deadlines for yourself - progress checkpoints along a timeline of activities that will eventually result in the completion of the application you've been assigned to create. As a programmer who went to one of the top computer science schools in the country and is now the only person in the history of that school to finish their software engineering degree in a year, you set deadlines that are to the average person highly unrealistic, but to you are a shoulder badge of confidence in your triple-A, hot shot programming skillz.

Unfortunately this confidence is the source of your frustrations as you will find that the deadline for that multi-faceted, highly featured business web application is closing in and you realize that you've spent an entire day trying to find out why the jQuery.post() function isn't receiving JSON information from your PHP script on the login page.

With just a few days left to finish this app, and a myriad of other documents, reports and meetings to tackle, this is going to be one interesting week.

Monday, February 21, 2011

Left FB For Good

I left FB for good the other day. Starting to feel those old withdrawal symptoms as of late, Facebook's team did a great job planting that seed of backtracking possibility in my sub conscience when they mentioned that "All your stuff will be there when you sign in again using your email address and password..." - talk about confidence.

The internet is really a lonely place when you're doing everything your friends aren't. In this case, i'm glad to be alone though - FB was a giant waste of time and a huge distraction from more important things.

Oh well, on to the next thing I suppose.

Tuesday, October 27, 2009

Lovely Titan Robot on Gitex Exhibition 2009 - Dubai

As a (soon to be certified) Computer/Software Engineer, it really would amaze me if I even glimpsed the components and programming that went into creating this machine.

As a primitive citizen, seeing a walking singing robot of this size is just plain scary!