Linux Mint / Ubuntu – Beats Audio on HP Laptop

I am glad someone figured it out!! I will repost him so that all those stuck with crappy sound without Beats on their HP laptops while using Ubuntu get a breather.

Please note – if you are using Ubuntu 13.10 or above, you do not need to install hda-jack-retask separately, its a part of the alsa package. Install alsa-tools-gui in that case using the standard software manager.

Follow these steps (skip installing hda-jack-retask if Ubuntu 13.10 or higher)

OK! I figured it out! It sounds *awesome*!

Step 1: Install hda-jack-retask from here: https://launchpad.net/~diwic/+archive/hda (ppa:diwic/hda)

Step 2: Open hda-jack-retask

Step 3: Select the IDT 92HD91BXX codec (may be different on other models)

Step 4: Check the “Show unconnected pins” box (the internal speakers do not show as connected)

Step 5: Remap 0x0d (Internal Speaker, Front side) to “Internal speaker”

Step 6: Remap 0x0f (“Not connected” but is the under-display speakers) to “Internal speaker”

Step 7: Remap 0x10 (“Not connected” but is the subwoofer) to “Internal speaker (LFE)”

Step 8: Apply now, then test with your favorite audio program (some may not work due to Pulse reset, so find one that does, verify sound is coming from all speakers).

Step 9: If it works, select “Install boot override” to save the settings to apply at boot time.

Step 10: Reboot. When it comes back, you should have full sound from all speakers. Also test headphones. Plugging in headphones should disable sound from all internal speakers.

 

This worked awesome on my laptop! If you have questions just post in comments here.

Few tips on improving speed of your MongoDB database

Those of you who have done a project with MongoDB will notice that it functions and behaves quite differently than traditional RDBMS systems. From super fast queries to all of a sudden taking forever to return 10 documents is something beginners always face with MongoDB. I am no expert but these are the steps I took and Mongo worked much nicer than it had earlier.

  • Configure “Mongod” to run as a service Many beginners make this mistake and its a very common one. Make sure you run it as a service which allows MongoDB to do better performance management and handle incoming queries a lot better.
  • Indexing This should not even need to be mentioned, but with Mongo don’t do a blind indexing. Think of the fields you group the documents the most in your queries and set the indexes with that in mind. This will do a lot to speed up your MongoDB
  • Start using _id Again this is something people do a lot, i.e. they don’t use the inbuilt _id field. You should using that over your own ids. Since it’s an ObjectID, it indexes better and is truly unique reducing programmer headache of creating unique id fields
  • Create a re-indexer service Like any other database MongoDB needs to be re-indexed occasionally. One of the easiest ways is to create a daemon or service in your favorite language and make it do some maintenance like re-indexing and data cleanups.
  • Implement Paging in your queries This is good to do in most projects. When showing large data sets, try to page your data so that you only show enough to start with, and then fetch more as you go. Mongo has an advantage over other databases in this regard in terms of speed. Please keep in mind the field you page on is a unique index

So these are a few observations I had while designing my project in MongoDB. I will be adding more improvement techniques as I go forward. If you think some of my above points are erroneous do let me know. Also share your tricks with me!

Secret of the Romani People

A few years back when I used to be big on finding out about the origins of Indo-European people/community, I had learned about the gypsies tracing their roots back to India. Yesterday I stumbled upon the history of Romani people who are a part of the gypsy tribe and have lived in Europe for centuries not really knowing their place of origin. It will be surprising to a lot of readers that the Romani people have been genetically proven to be a race of the North-Middle-Indian territory but have lived across Europe for at least a 1000 years. The language they speak is very closely related to Hindustani or the Hindi language of India which is another startling fact.

What probably remains a big mystery is how did the Romanis or the Gypsys get to Europe from India? What made them forget the land they came from and what made them never make an effort to go back. It is a mystery even the Romani people may not know the answer to. Someday their history and their historic connection to India will be lost in the annals of time and it is unlikely if anyone will be interested in finding out the real reasons.

Do the Romani people consider themselves Indians and would they ever want to come back to India? Hmm interesting question and only a Romani connected to the roots can answer…

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.