Either another instance of LibreOffice is accessing your personal settings or your personal settings are locked.

With error messages like that, you can forget getting my mom to use LibreOffice :). That said, I’m not my mom and LibreOffice is the best free alternative to MS Office IMHO so I should not really complain!

This all started when I tried to open a 200+ MB CSV file on my Mac. I usually right click and select Sublime Text but I was busy and ended up double clicking it triggering LibreOffice Calc to start opening it up. LibreOffice froze my machine. I killed LibreOffice, proceeded to open the file in Sublime Text, did my due and forgot about it. Today when I’m started LibreOffice, I got the following error message:

Either another instance of LibreOffice is accessing your personal settings or your personal settings are locked.
Simultaneous access can lead to inconsistencies in your personal settings. Before continuing, you should make sure user 'karthicr' closes LibreOffice on host 'LA14001.local'.

Do you really want to continue?

I sure as hell know LibreOffice is not running but you can verify the same via the Activity Monitor or via the Terminal using the following command:

ps -A | grep soff

If LibreOffice is running, you should see something along the lines of :

695 ?? 0:03.16 /Applications/LibreOffice.app/Contents/MacOS/soffice
710 ttys000 0:00.00 grep soff

If LibreOffice is not running, you should not see the first line, only, the second line. The second line with grep represents the process you were running to search for a running instance of LibreOffice.

If LibreOffice is in fact running, kill that process right from within the Activity Monitor or do it from the Terminal via the following command:

kill -9 695

where 695 is the process id of the instance you get from the earlier command.

If LibreOffice was not running, as in my case, it usually means that a dirty shutdown left behind a .lock file which is usually created by LibreOffice and removed on a clean shutdown. In this case, all we need to do is locate that .lock file and remove it.

Common places where you will find the .lock file include:

On a Mac:

~/Library/Application Support/LibreOffice/4

On a Linux Machine:


The 4 in indicates the version of LibreOffice and will change depending on the version of LibreOffice you are running. Delete that .lock file and run LibreOffice again, you will see no more scary errors.


Django REST Framework: ‘module’ object is not callable

This post is more of a note to myself, but, I’m throwing it up here as a benefit to myself and my brethren who end up making the same mistake.

If you ever encounter an error that reads: 'module' object is not callable, while using the reverse() function, you are using the wrong import!



Serving Django Admin over HTTPS behind a Nginx Proxy

I was deploying my first Django application today on a production server. Nginx is the proxy server and gunicorn is the WSGI web server. Supervisor is being used to ensure the gunicorn workers are always re-spawned if they die. The firewall is setup to only allow HTTPS connections. After a lot of tweaking the settings, I was finally able to see my page over the public internet.

An interesting thing was happening when I was trying to get to the admin. I would use access the admin over HTTPS and login. However I was being redirected to HTTP after the login and I would never see a page as the firewall would block the request. But when I reload the admin page using HTTPS I can see that I was logged in. So basically I needed to figure out what to do so Django admin would be served over HTTPS after login.

After some snooping around on the net, I find the answer on stackoverflow. So without further adieu:

Force Timezone in Javascript Date

So I was working on a project for which I needed to force the Eastern timezone while displaying dates. Though not relevant to the post, I thought I need to share a few words about the method I chose to accomplish the task. I discovered prototype object (not the framework) today. (You are welcome to skip this section and proceed to the implementation) Here is an excerpt from the excellent Mozilla Development Network pages:

All objects in JavaScript are descended from Object; all objects inherit methods and properties from Object.prototype, although they may be overridden (except an Object with a null prototype, i.e. Object.create(null)). For example, other constructors’ prototypes override the constructor property and provide their own toString methods. Changes to the Object prototype object are propagated to all objects unless the properties and methods subject to those changes are overridden further along the prototype chain.

The items we are interested in are:

  • they may be overriden
  • changes are propogated to all objects

This is applicable to both user defined types and built-in types in javascript. This is awesome! I decided to use the Object.prototype object to extend the built-in Date type to add some sugar to my code while keeping it readable.

Notice the extension of the built-in Date by the addition of getStandardTimezoneOffset() and isDst() methods. Also notice how getEastern(datetime) is not an extension but just a straight up javascript function since it is a very specific use case and it makes no sense to make this function available to all instances of Date.

The code is pretty self explanatory but if you have questions drop me a note and I’ll do my best to answer them. Accomplishing this task and this post would not be complete without posting references to the articles that guided me through this process.

  1. How to ignore user’s time zone and force Date() use specific time zone
  2. Check if Daylight Saving Time is in effect, and if it is for how many hours
  3. Daylight Saving Time
  4. Time Zone Offset Calculation

Shell Script Converting WAV files to MP3 files using SoX

Here is the script to convert a WAV file to a MP3 file quickly. This is my first foray into the world of shell scripts and I quite enjoyed it.

Cheers and stay classy!

Squirrel SQL, jTDS and Windows Authentication (SSO) for Microsoft SQL Server

If you are like me and you hate spinning up a virtual machine every time you need to run a few simple queries in MS SQL Server, you have reached the right place. Read on to find out how to setup up SQuirreL (a universal SQL client) to connect to MS SQL Server via Windows Authentication (SSO). The great thing is this process will work on a Mac and Windows machine as well if you’d like to keep things consistent and use a single tool across platforms to accomplish tasks.

The key point to note here is, unlike other posts on the web that have you add the dll file in some PATH or similar environment variable in the system, I show you how to add it within SQuirreL SQL. I like this approach as it keeps things clean and self contained and not to mention that is very easy to memorize and replicate in other machines and on other OSes.


Setting up the driver in SQuirreL:

  • Open up SQuirreL SQL Client and select Drivers on the left to pull up the drivers list
  • Scroll down to jTDS Microsoft SQL and select it. Then click Modify the Selected Driver at the top. The icon looks like a pen or a pencil for this function.
  • In the modal window that pops up, select the Extra Class Path tab.
  • Click Add and navigate to the folder where you have downloaded the jTDS-version.jar file. Select OK to add it to the list.
  • Click Add again and navigate to the folder where you have ntlmauth.dll downloaded to. Ensure you select the driver for the appropriate architecture (x86, x64, or ia64).
  • Here is a picture for some easy reference.
Configuring SQuirrel SQL Client.

Configuring SQuirrel SQL Client.

Setting up the connection:

  • Select Aliases on the left to pull up the aliases list.
  • Click Create a new Alias at the top. The icon looks like a thick plus symbol for this function.
  • In the modal window that pops up, give the connection a name.
  • Select jTDS Microsoft SQL in the Driver drop down list.
  • Enter your URL in the following format:
    • jdbc:jtds:sqlserver://your.server.or.ip.address.com/;domain=YOURDOMAIN;
  • Use your domain credentials for username and password and hit OK to save the connection

Now double click on the newly created connection and hit connect to log on.

Happy coding!!!!

You have to install development tools first.

It appears, at first, to be a very dignified error message, very poised in telling you what exactly needs to happen and here you are thinking, oh look, it tells me what I have to do. Don’t let that fool you, I spent the better part of a evening trying to get past the above message.

Here is my stack trace:

Long story short, I was trying to install adhearsion on my laptop running Ubuntu 12.04 LTS. I had never worked on ruby before so I set about installing:

  • rvm (using curl)
  • ruby (using rvm)
  • rubygems (using rvm)
  • adhearsion (using gem)

I was having trouble getting ruby_speech (an adhearsion dependency) compiled. After loads of googling and installing all sorts of packages you think will help you get past this error, I finally found the solution documented here: Can’t install ruby_speech gem, checking for pcre.h… no

All you need is this:

And you are scott free! Cheers and happy coding!

Using WebAPI with ASP MVC 3

If you are like me where in your organization you are using the membership provider that came with ASP MVC 3 template but you also have the need to provide RESTful services from within the same application and would really really like to use the awesome WebAPI, here is what you need to do:

  1. Create a brand new MVC 3 internet application or open up your existing application
  2. Install the following NuGet Package using the package manager console:

  3. Open the Global.asax file and add the following route after this routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); line as shown:

  4. Also ensure that you have used or imported System.Web.Http depending on C# / VB in Global.asax like so:

  5. Add a new WebAPI controller using the Add -> New Item context menu option or just use Ctrl + Shift + A keyboard shortcut.

I believe this is a lot easier than starting a MVC4 application and trying to incorporate the membership provider into that.


Force MySQL to be case sensitive in Windows

I develop on Windows / Linux and deploy on Linux. I always run into the issue of my tables having different cases on my development and production environments causing stupid time wasting errors. If only everything in this world was nice. Hold your breath! There is a work around.

I don’t know why this is not default by design but according to the Identifier Case Sensitivity section in the manual:

How table and database names are stored on disk and used in MySQL is affected by the lower_case_table_names system variable, which you can set when starting mysqld. lower_case_table_names can take the values shown in the following table. This variable does not affect case sensitivity of trigger identifiers. On Unix, the default value of lower_case_table_names is 0. On Windows the default value is 1. On Mac OS X, the default value is 2.

0 – Table and database names are stored on disk using the lettercase specified in the CREATE TABLE or CREATE DATABASE statement. Name comparisons are case sensitive. You should not set this variable to 0 if you are running MySQL on a system that has case-insensitive file names (such as Windows or Mac OS X). If you force this variable to 0 with –lower-case-table-names=0 on a case-insensitive file system and access MyISAM tablenames using different lettercases, index corruption may result.

1 – Table names are stored in lowercase on disk and name comparisons are not case sensitive. MySQL converts all table names to lowercase on storage and lookup. This behavior also applies to database names and table aliases.

2 – Table and database names are stored on disk using the lettercase specified in the CREATE TABLE or CREATE DATABASE statement, but MySQL converts them to lowercase on lookup. Name comparisons are not case sensitive. This works only on file systems that are not case sensitive! InnoDB table names are stored in lowercase, as for lower_case_table_names=1.

The best option to simulate this behavior in Windows is to set lower_case_table_names = 2 in your my.ini file. In my Windows 8 for a MySQL 5.6 server install, this file is located at C:\ProgramData\MySQL\MySQL Server 5.6\my.ini. Depending on your installation, this path my be a little different. Open the file and update the value of the lower_case_table_names variable or if it is not present just add the value to the end of the file.

Remember to restart the MySQL service in Windows by running services.msc. Grab a beer and keep rocking!

Reset the Start Screen in Windows 8

The Metro Start Screen is a new concept to a lot of us. So we experiment at first and after a lot of time spent, we come to start using Metro in a way that suits us most. Personally I cluttered up the start screen with all my icons and I realized that it is way easier to open any application by just hitting the Start key and just typing its name rather than click on a tile. So I decided to reset my Start screen.

Open an elevated command prompt. There are many ways to do this. The easiest way to do it is to hit Windows + A. When you see the popup menu, choose Command Prompt (Admin) or simply hit A.

Once the command prompt opens, run the following commands:

Now when you hit the Start key, Explorer will restart and you will have the stock menu. Keep it this way or customize it to your liking again.