Linux Saga: Fixed the long standing bug of WiFi not connecting after sleep/suspend

Now this was a weird one which I later read on other forums that it was a common problem on most HP laptops. Well finally I got to fix this with a very simple fix!

Added a line in /etc/modprobe.d/iwlwifi.conf
options iwlwifi bt_coex_active=0

Getting your cheap Android Phone/Tablet to get detected for Debugging by Linux (Mint or Ubuntu)

Welcome to a post another road block I recently solved on the Android development saga. I got myself a cheap Android tablet (Byond Mi-1). In an effort to use it for Android Development with Linux Mint / Ubuntu, I had to get across quite a few steps other than what is normal. Lets go step by step:

  1. Figure out your Tablet’s Vendor ID – Use the lsusb command. It will dump out the details of all the USB devices connected to your machine. Usually your cheap tablet will not show up with a name on the dump, however in most likelihood it will be the last item on that list. To be sure, copy the output of the lsusb command into a text editor or spreadsheet. Then connect your Tablet with the computer and turn on Mass Storage (on the tablet). Run lsusb again and grab the dump and put it into a text editor or spreadsheet. There should be an extra line pertaining to your device. There will be an ID in the form of ID 1234:5678. 1234 will be your Vendor id. Take a note of it.
  2. Run the command:
    sudo gedit /etc/udev/rules.d/51-android.rules
    Copy paste these lines:
    SUBSYSTEM==”usb”, ATTR{idVendor}==”1234″, MODE=”0666″, GROUP=”plugdev”
    SUBSYSTEM==”usb”, ENV{DEVTYPE}==”usb_device”, ENV{PRODUCT}==”1234/*”, MODE=”0666″
    SUBSYSTEM==”usb”, SYSFS{idVendor}==”1234″, MODE=”0666″ 

    Please appropriately change 1234 to your correct device id.

  3. Run the following command to create a adb_usb.ini file in your .android folder in your home.
    sudo gedit ~/.android/adb_usb.ini
    Simply write your device id in this format:
    0x1234
    Save and exit
  4. Reboot your computer
  5. Unlock your tablet and go to settings. Find Developer Settings and switch on USB debugging. This step will depend on your Android version.
  6. Connect your tablet to the computer
  7. Get to your android sdk’s platform tools folder and run the command:
    ./adb devices
  8. If your device is listed, then yuhoo you got your cheap tablet ready for development.

Pretty cool eh!?

Laptop LCD screen brightness in Linux Mint 13 or Ubuntu 12.04

I recently set up a Linux workstation and based on my lookup on best distributions available, two came to fore: Ubuntu 12.04 and Linux Mint 13 (Maya). Ubuntu has always been a fantastic Linux distro, but as I learned Linux Mint is actually based off of Ubuntu and did a better job at being a full featured OS, I decided to get it setup on my desktop. I have been very pleased so far!
One of the issues faced was inability to control brightness of the screen. I could not do say from the keys on the keyboard and neither did system settings work. The fix was easy as I learned about it on other forums. Here is the link to fix the problem:
http://shellboy.com/linux-mint-13-on-dell-xps-15-brightness-keys-not-working.html

Upgrading MonoDevelop to the latest stable build on Linux Mint / Ubuntu

All those developing with MonoDevelop on Linux Mint or Ubuntu must have noticed that the software repository does not provide the latest release of MonoDevelop (3.0.3.5 as of this writing). The only way to get to the updated version is to compile it on your own. Compiling a big project like Monodevelop on Linux usually scares the crap out of some, specially those migrating in from Windows backgrounds. Although there is nothing special about it, you satisfy project dependencies and compile using the provided tools. Also it is basically a standard linux three step process, configure, make and make install.

In spite of all of that, there are some of us who believe in keeping things simple. That allows us to channel our creative energy and spirit into other things that matter. I obviously don’t want to fight dependencies after dependencies and have no energy left to work on my own project. So here is a the best way I have found to make a clean build of Monodevelop from fresh stable source code. Actually the credit goes to John Ruiz who put up this simple shell script that does the job for us. Get his script from https://raw.github.com/jar349/tools/master/install-monodevelop.sh and save it to a folder. Usually it would land up in your Downloads folder in your home. Make sure to give it “execute” permissions. You can use the UI, right click the file, go to Properties, select Permissions tab, and check the box that says “Allow executing file as a program” With that done, now you need to start your Terminal, navigate to the Downloads folder and run the script as ./install-monodevelop.sh

It will do a bunch of stuff and by the end of its run, it will have monodevelop built and installed. Simply type monodevelop on the command line to run! Yep you are done!

Android Development Beginning

Having begun learning Android development a little while back, and today I made some excellent progress. In order to get all my knowhow straight, I planned to create a simple app that would show me a list of people in a group. The list of people will be shown using a ListView control on the Android UI. The App would fetch this information from a RESTful Web Service written in ASP.NET C# on the Mono platform. I plan to use JSON as my choice of data communication format. Internally, the ASP.NET service will pull this information from a PostgreSQL Server.

Here is how I approached the task. I quickly threw in a table on my PostgreSQL installation which contained the names of people I want to show. On Monodevelop, I created a ASP.NET project with a simple ASPX page that dumps out a JSON for the list of users. To fetch the data from PostgreSQL we need a library called npgsql. Its pretty slick and gets the job done. Using standard mechanisms, I was able to pull data from the database and convert into a readable JSON.
The most important and challenging part (for me) came after this. That is, how to consume this service in my Android application. Coming from C# Windows Forms background, I am used to doing this in a line or two and if the call is small enough, I don’t even bother making it Async. But Android really wanted me to make the network call on a separate thread, and it did make sense! They enforced a good practice from the very beginning. Alright, so my quick reading led me AsyncTask<> class. I found some really nice tutorials on it’s implementation, specially this one: http://www.vogella.com/articles/AndroidPerformance/article.html
I faced an interesting situation here. I was trying to access my local ASP.NET server via a standard URL format like http://localhost:8080/ but that always threw an exception at me that the connection was refused. Then I tried browsing that URL from the Android emulator and that too failed. It took a while but it did strike me then, that localhost would be a loopback address on the emulator itself, not the host development machine. A quick search showed me that the emulator then uses the IP 10.0.2.2 for loopback on the host machine. Modifying my url to http://10.0.2.2:8080/ worked on the Android browser. Pretty sure it would run in my code as well, I ran my App, which to my not-my-surprise, threw the same exception.
Digging further over the internet, I realized I had missed a very basic step. Asking permissions on Android to use the Internet service. So all I had to do was put in a line in the Manifest file like:
The next I ran the App, and viola! it worked! But hey, that didn’t work all the way till showing it on the UI as a list. It only pulled the JSON string into the variable.
I now had to parse the JSON and appropriately get it into a Java consumable format. Gson by Google came to my rescue, which is a nice little framework for working with JSON on Java. I added references to it on my project and wrote some test code to see how it works. It was simple, clean and perfect. You use a Gson class, initialize it, and simply call the fromJson method to convert a JSON string to the desirable type.
Now came another roadblock, i.e. to bind it to the list view. The way ListView works is that it has an Adapter for it which can be of any custom implementation type. I used a standard ArrayAdapter and set it to the ListView. What kept tripping it off was the fact that the ListView would not consume the adapter on a thread other than the UI thread. Now this is pretty basic in the Windows Forms world and I should have thought the same would be true here. Solution would have to be similar as well, and as I found out, there is a very much similar method in Android called the runOnUiThread which takes a delegate, similar to the Invoke method on controls in Windows Forms. Now I gave a final run and yeah it was the Eureka moment to see everything working. Even after 6 years of programming, sometimes the smallest of achievements in new areas turns me on. Yeah to an extent that I spent this much writing about it… Though this write up is just for my own log purpose in an effort to track the development process of whatever it is that I am developing.
I am following a self imposed Agile Development methodology and am attempting to follow a Sprint cycle. Sprints are short burst of all round developments that enable us to understand the end-to-end process from the very beginning. For example, in my really silly simple project, I learned how to get PostgreSQL installed on my Linux box, how to get it working on C# in Mono and finally how to consume it on an Android App. This allowed me to do an integrated test of all three work environments that will form the major part of my upcoming days in deep development…
I will sign off now and log my next effort!

Complexity Adaptive User Interface (COMPAD UI)

In a Nutshell

How about a UI that doesn’t present you with all the complex features of the application just at once. Instead, it slowly adapts in that direction based on your usage pattern.

The Need

Applications, as they move up in release versions, start cramming up the UI with features. This is a gradual progression we see in most software applications available today. In a world were simplicity speaks volumes, we might be better off with showing less. Why would I hide features when my application supports it, you would ask. The answer is simple – Users may only need to do certain things with your application, never will they use every single feature from day one (unless they are used to previous versions, of course).

The Solution

Bring about a UI which understands user usage pattern, and then gradually starts enabling/showing features. This would allow the end user to start with a minimalist interface and then as the user gets comfortable with the core functionality, that they can start using more features.

Practical Example

Like all theories, it’s better to put the point across with a practical example.

The best example I have from my own experience is the story of Winamp (from my perspective). Like most fans of music during the late 90s, I too was a Winamp + Napster fan. Winamp had always been my media player of choice ever since I had started listening to MP3s. In spite of my dedicated loyalty towards all the versions up until 2.81, something happened with Winamp 3 that totally threw me off and almost made me regret my decision of upgrading. It had become this bloated piece of software from the original version, that in less than 10 minutes I lost all charm of wanting to use it. My grunt was simple – I had no interest in Music Libraries or tons of those new features that it shoved at me. Plus all of those features made it slower to load. It didn’t take me much time to roll back to Winamp 2.81 which had been my previous version.

One day I got this newsletter bragging about the launch of Winamp 5. Honestly, I was not too excited to give it a try given my past experience with the version 3. What I did notice is that this time it came with a Lite version as well! Instinctively, I downloaded that and fired it up. Expecting to see a worsened avatar of the version 3, what eventually showed up was a surprise – The UI was almost just like 2.81. Wow, what a relief that it does retain the 2.81 simplicity, I was instantly telling my geeky friends! I immediately got to using it and no second thoughts about reverting back to the old version haunted me. What this meant was, I was not the only one complaining about the cramped up Winamp 3 UI and certainly I was sharing a general consensus. In about next few days I unlocked almost all of the features I had seen in Winamp 3 plus a few more. Not necessarily I used all of them, but at least I knew they were there and I will use them when the need (or the urge) arises. An important lesson was learnt that day – make it comfortable for someone to fit in to what is otherwise new.

Learning off of that experience, came a thought to my mind – what if the software understood that when a user was ready to be presented with more stuff that they might want! If that would happen, then even a non-geeky user could be eventually roped in to use some of the more advanced features.

Alright, we are sold, how do we implement Complexity Adaptive UI (COMPAD UI)?

What I plan to suggest in series of successive posts, is a set of  configuration XML markup structures, terms and design patterns to enable successful implementation of this feature in programming language and technology of your choice. I am also in process of setting up a Wiki page so that more of us can collaborate on the idea.

iPhone water damage causing no sound to come from the handset

Wow I never thought I would spill water on my precious iPhone 4… until yesterday when I actually did the forbidden. Like most cell phone companies, Apple doesn’t cover any water damage to the phone. The moment I spilled water on it, I reacted in about 3 seconds and wiped my iPhone dry. I pressed the home button and it seemed to light up and everything was responding ok. What I didnt notice at that time was that it wasn’t making the usual click sounds while unlocking and neither did it play tones when I pressed numeric buttons. It became apparent to me when after an hour I tried making a call to a friend and I wasn’t able to hear their voice from the handset. I switched it to the Loud Speaker mode, then I could hear my friend. Crap, I thought to myself and believed I had successfully damaged my iPhone’s earpiece.

Alright so lets do the problem-solution round:

Problem:
No sound coming from the handset’s earpiece, however loud speaker working fine

Solution:
The solution came to me from this link:
http://faithtoh.wordpress.com/2010/01/20/how-i-fixed-my-iphone-has-no-sound-problem/

What I did was to simply take a thin napkin that would absorb water and wrap it delicately over something like a toothpick. Turn off the phone and then clean the headphone jack with it and make sure the toothpick touches the very end. Ensuring that all the water was out of the headphone jack and then turning on the phone brought my sound back!!! It was like a miracle!!!

You must be wondering what does the headphone jack have to do with sound not coming from earpiece of the handset. Well my theory is, that water when gets inside the headphone jack, kind of shorts it and makes the phone believe that a headphone has been connected, hence causing the sound to not come from the handset earpiece.

If this post helps you, please yell yay!

Creation story of Rig Veda (Hinduism)

Recently I had a debate with some overtly religious people about creation stories and the Creator God. The ardent Hindu followers will instantly put across the trinity theory which has Brahma as the creator, Vishnu as the saviour and Mahesh as the destroyer. The Judeo-Christian belief system has it easier with one-God-does-all theory. The stories in both these philosophies go into very intricate details like how Brahma appeared on a lotus and began the creation of the universe and how God created the universe in 6 days and on the 7th day he rested.

In spite of these stories being fascinating in their own accord, they have never found their place with science. Quantum physicists would disagree with most of these theories and rubbish them. The scientists are completely correct in my opinion. Personally I have never understood the Creator God theory, because after solving one problem, it just creates another. Where did God come from? What is its plane of existence? Is He/She/It beyond the fabric of our space and time? If so then where? At some point logic breaks down. So I am not too convinced by either the Trinity of Hinduism or the One-God-Does-All theory. The only religion that has appealed to me in this respect is Buddhism which makes it very clear in the very beginning that it has no place for a creation theory. Very reasonably, because it doesn’t matter!

But then recently in an effort to understand creation theory in my own religion I turned to one of the oldest surviving literature in the world – the Rig Veda. The creation hymn CXXIX is a total stunner! Something which I hadn’t expected it to be.

1. THEN was not non-existent nor existent: there was no realm of air, no sky beyond it.
What covered in, and where? and what gave shelter? Was water there, unfathomed depth of water?
2 Death was not then, nor was there aught immortal: no sign was there, the day’s and night’s divider.
That One Thing, breathless, breathed by its own nature: apart from it was nothing whatsoever.
3 Darkness there was: at first concealed in darkness this All was indiscriminated chaos.
All that existed then was void and form less: by the great power of Warmth was born that Unit.
4 Thereafter rose Desire in the beginning, Desire, the primal seed and germ of Spirit.
Sages who searched with their heart’s thought discovered the existent’s kinship in the non-existent.
5 Transversely was their severing line extended: what was above it then, and what below it?
There were begetters, there were mighty forces, free action here and energy up yonder
6 Who verily knows and who can here declare it, whence it was born and whence comes this creation?
The Gods are later than this world’s production. Who knows then whence it first came into being?
7 He, the first origin of this creation, whether he formed it all or did not form it,
Whose eye controls this world in highest heaven, he verily knows it, or perhaps he knows not.

The Rig Veda clearly leaves the entire matter to questions with the exception of a few statements. What intrigues me the most is the fact that it states that Gods came after the universe was created. Most would challenge that, saying God has always existed etc. etc. But think about it, if whatever your religious texts says about what God wants, wouldn’t he be able to

The second statement it makes is that the first thing to appear was Desire, the primal seed and germ of Spirit. If it hasn’t struck you yet, its exactly in tandem with Buddhist teachings. So clearly Buddha was trying to bring the people of India back to Dharma as it should have been.

Besides the uncertain language of the entire text oscillates in uncertainty just as Quantum Physics does now…

Solving the infamous AppStore not working problem!

I run a Mac clone and recently switched over to Mac OS X Lion. One of the problems that has been infamous amongst most Mac users, both regular as well as Hackintosh, is the AppStore complaining – “Your device or computer could not be verified. Contact support for assistance.” after an upgrade.

I will jump straight to a problem-solution approach:

Problem
After an upgrade, your AppStore stops working with the following error:
“Your device or computer could not be verified. Contact support for assistance.”

Cause
As I gathered from numerous blogs, it happens due to the fact that your Ethernet card is not the first network device.

Solution
Before we start, let me make it clear that there is no one-solution-for-all to this. We have to try a series of steps and see which one works.

First solution:

  • Go to Network Preferences and remove every network interface (by selecting and pressing the ‘-‘ button at the bottom)
  • Delete the NetworkInterfaces.plist and com.apple.network.identification.plist
  • Reboot
  • Go to Network Preferences and add your network connections/interfaces again – BUT start with Ethernet first and make it eth0
  • Check if AppStore works by trying to sign into it

Second solution:

This solution involves following these steps which I gathered from TonyMacX86 forum:

To do this i:
– downloaded EFI Studio, selected Ethernet, selected Add Device. Then clicked write to com.apple.boot.plist.
– Then went to /Library/Preferences/SystemConfiguration/apple.com.boot.plist and selected the new key and string it added.
– Then coped this string and pasted into the /Extra/apple.com.boot.plist file and saved.

Then important STEP!
– Remove all network devices from System Preferences/Network.
– Delete deleting library>preferences>system configuration> NetworkInterfaces.plist file.

* Finally, Reboot.

After reboot, go to System Preferences/Network add add devices. Click (Ethernet) FIRST!! Then add the other adapters you use to connect to the internet.

For me the above steps also didn’t quite work. I had to do one final thing to get it working. I added the two keys mentioned below to the com.apple.boot.plist in Extra folder (in my case org.chameleon.boot.plist)

<key>PCIRootUID</key>
<string>1</string>

<key>EthernetBuiltIn</key>
<string>Yes</string>

It worked for me after that!

If it still doesn’t work for you, review each of your steps again to make sure you didnt err somewhere. Then follow this thread and see what you can gather out of it:

http://tonymacx86.com/viewtopic.php?f=169&t=31774

DiskMax hard disk cleaner

Recently I have been having problems on one of my hard disk drives running low on free space. DiskMax really was a life saver in critical moment. Not only does it do a general cleanup, but it also cleans up cache of common tools like IE or Chrome browsers. When I ran it first time it recovered close to 4 gigs in 10 mins!

Terrific tool for those who have smaller windows partitions!

BlogBooster-The most productive way for mobile blogging. BlogBooster is a multi-service blog editor for iPhone, Android, WebOs and your desktop