I just realised that I’ve been posting more on Twitter than on my blog. Must fix this.

Anyway lately I’ve change the things that pull me. Considering the crazy cold weather here I had decided to make the most of the warm weather and perform some physically taxing activities. Included are taking the kids for a walk and having to chase them.

More than that I started and for the first time in my life actually worked on cars. Yes. Cars. Something that very few folks from Software world would imagine although the first things in OOPS is the car analogy. I can say with reasonable amount of confidence, that the analogy is based on simplifying the problem domain and I do not think the analogy answers questions appropriately anymore.

I purchased a 2008 Maxima and it had significant hail damage. I am not fixing any of the damage. It is a high value car for the simple reason that its powertrain is in a good shape and it is the last of the 6th generation Maximas. The engine VQ35E is pretty much bullet proof and best of all has a timing chain.

Lam, a colleague at work, knows his way around a car. I am quite lucky to have spotted him and he’s mentored me in quite a few aspects around the car. With Youtube for theory and Lam for reviewing my work I managed to work on quite a few pieces including wheel bearing hub, rotors, brake pads, electrical work on the window, inner fender liner and a bunch of other pieces. More importantly I mustered up enough courage to help Rakesh, another colleague, replace his serpentine belt. This means a lot to me and sometime after this Winter I’d like to get going with a proper engine swap or even better an engine rebuild. Hopefully on a Subaru as I love those cars.


Batik, SVG and weird javascript errors

I am using Clojure to generate SVG documents. To do this I use a library called lacij which in turn uses tikkba; a wrapper around the Apache Batik SVG generation library.

I added support for embedding javascript inside the SVG document (not the html) by manipulating the DOM as described here

The problem was that I was getting weird svg error “unknown language text/ecmascript”. As it turns out I was using the wrong xlink namespace and posted the answer on the above mentioned thread.

The code I wrote now is like this:

(defn build-svg-graph [graph]
(def new-graph(-> graph
(LALayout/layout :hierarchical)

(def element
(:xmldoc new-graph)
[:script {"xlink:href" "myscript.js" :type "text/ecmascript"}]

(Dom/append-child (Dom/document-element (:xmldoc new-graph)) element)

(Dom/spit-str (:xmldoc new-graph) :indent "yes")

Note that I needed to use xlink:href instead of src for embedding javascript refs in svg. src works in HTML not in SVG

Clojure import/require/use defrecord from another namespace

Good GOD!!
Mixing Lisp and Java leads to weirdness of infinite magnitude when I just spent 1 hour trying to figure out wtf was happening with a compilation error. Here’s the situation.
– I created a package called building_blocks (directory building_blocks).
– Namespace called building-blocks.activity (activity.clj file is under building_blocks directory)
– I have a defrecord called Activity inside the building-blocks.activity namespace
– I wanted to use the above mentioned Activity defrecord inside another namespace called adder.core

I continuously got “java.lang.ClassNotFoundException”, “exception in thread “main” java.lang.IllegalArgumentException: Unable to resolve classname: Activity, compiling:(adder/core.clj ” and a bunch of other errors.

As it turns out there were two errors:
– Importing defrecord from another namespace is not just :use. I had to first :require the namespace, then import the defrecord. This was a trivial problem to solve and I figured it out quickly. Only this did not work in my case
– Dashes “-” and Underscores “_” are a nuisance since we are mixing Lisp with Java. While the file system uses underscores Clojure converts things to dashes. Brilliant.

So to fix the second error I use the follow in the ns block

(ns adder.core
(:require building-blocks.activity)
(:import [building_blocks.activity Activity])

then I do
(def new-activity (Activity. name))

North Carolina and Tesla – the need for common sense

North Carolina has plans on banning direct sales of Tesla motors’ cars because Tesla does not have deals with dealerships in the state. This law has in many ways been labeled as “unfair competition”, “protecting customers” and “customer service first”. Words and phrases aside what are the pillars on which the above phrases stand?

Unfair competition:

 Sure Tesla selling directly to customers by the click of a button on the internet is unfair competition. Read it as unfair competition to dealers whose sole purpose is to be middle men between a company and customers. They rare add any value, always seek out best ways to maximise their revenue and profits and never really care about the sold cars. When I tried to purchase a car I was always pulled into various situations that I can phrase as “unfair”. Trying to add unnecessary fees, add ons and asking me to go for financing and then ultimately asking me to purchase a new car – all these have happened in incremental fashion at various dealerships I had visited. To that extent I ended up going to dealerships, sitting around for 3-4 hrs and then returning without a car because the initial price and the final price were quite different.

 How does Tesla sell? You book your car online just the way you purchase electronics. Any issues you have get resolved over phone with customer service or you bring it into the service centre and they service the car. Towing is not that different from the usual cars. How often do you actually have a service centre right around the corner from where your car broke down?

 Where is unfair competition in this segment? Here’s where it is. The only remaining cost optimisation without hurting the customer is reducing the number of layers before the car gets to the customer. i.e; the dealerships getting eliminated. Car companies do not compete with dealerships. There is no real need for dealerships to exist in the first place. Tesla competes with dealerships in the same way Apple competes with Fry’s.

 Labeling it unfair competition would be like Bose labeling Microsoft competition because they share the same floor space at Fry’s. I had a chance to visit two of the Tesla showrooms and I must say that it is one of the nicest places to be. No one pressures me to buy the car. How would you like that taken away?

Protecting Customers:

 I can only read that as mosquitoes petitioning the govt to protect humans to protect customers. If a customer no longer wants to be a customer they are not customers. This statement assumes that the dealers want to protect the customers. Read it as dealers trying to protect their revenue sources by eliminating competition through lobbying. Try putting this to test by asking customers. Close your shops for 1 week and see how customers react. Try comparing Tesla sales to those of dealership sales for similar category cars. Oh you can actually – Tesla outsold Audi, BMW and Merc in the first quarter of 2013. Now whether this is sustainable over the year is not known. If this is just a flash in the pan then Tesla deserves to die. In which case exactly what is this legislation trying to solve?

 If Tesla does not provide good service to its customers it will be restricted to existing sales and the word of mouth will kill it. Tesla will get sued if it does not fulfill its obligations to the customers. Does it look like USA does not have enough lawyers? Does anyone thing Tesla does not figure that into their business plans?

 Customers can be protected in a multitude of ways without actually forcing the dealership model. I would love to see those laws enacted with fairness. I’d love to see laws that actually protect the customer – let us start with the outrageous EULAs.

Customer service first:

 Tesla, if it wants to survive, has to put the customer first. Every Tesla owner I’ve talked to has only good things to say about the car. Ofcourse Tesla is small fry in the car market and it remains to be seen if they can sustain this level of engagement but here’s the thing – the worst they can get to is the existing car manufacturers’ status. If that’s the case Tesla’s high price point will kill it anyway. We’ve seen what happened to Microsoft’s Windows 8 when they did not put out a compelling product for customers. Customers know what they don’t want. They don’t necessarily know what they want. No one out there would want bad customer service. Given a choice they’d flock to better service. That’s exactly what I did when AT&T was not sensible about its service. I switched the carrier and went to a smaller one.

 If you have to legislate compulsory customer service go for legislating the car company to customer relationship across the board. It makes no sense to mandate a dealership because the dealers only act as middlemen.


What will happen if dealers don’t exist?

 The first thing that will happen is Tesla’s profits will go up and perhaps the costs will come down, but on a bit because the car itself costs >$60K. The problem, if at all, would be that there will be few service centres available to service the cars. Sure that will put off some people and Tesla has to solve this problem before it steps out of being a lifestyle company. At the moment Tesla is rather small to be able to plan this well and on such a massive scale. When it grows it will be forced to expand the service centres if it wants to go solo.

 Tesla needs to have feet on the ground instead of just call centres. Towing will be the insurance company’s responsibility anyway so that is not an issue. Tesla doesn’t really have the financial tie ups so fewer people will be able to avail credit for purchasing the car. Obviously leasing options will help but still this is limited. This is where the dealerships have an edge.

 Dealerships have feet on the ground and are generally one node away from customers. Tesla has a disadvantage here so if dealers can ride this wave they have a point to prove. If they can help customers with:

* Leasing options

* Finance options

* In person experience better than Tesla

the dealers will win the battle. That would send a message to Tesla. Then again am I asking the dealers to evolve? To mutate? To fundamentally stop being leaches?

What should Tesla focus on?

 Here’s my take on the problems that Tesla needs to solve to get to the next level.

 * It needs to increase the charging stations but I get the feeling that this is only temporary fix to the fundamental problem of instant range boost (aka pump some petrol)

* The bigger and better problem to solve is storage capacity. Extending the range from the current 200-300 miles per charge to 500-600 miles would make this an appealing car to the masses

* Not all the problems need to be solved through battery and materials breakthrough. One example is to understand that the car is a transportation medium. As such it should be able to understand what its next task would be. For example if the car only has a 100 Mile range, drive back and forth between work and home is not an issue. Having a means (integrating with travel plans on the phone for example) to find out the next task will help better schedule charges and thus reduce irritations due to sudden death (aka zero charge) mid way between Los Angeles and San Diego.

* Present the economic viability of the car. Tesla has already done a brilliant job at showing some of the economic savings of using the Model S but that is for the filthy rich who use 100 dollar bills instead of tissue paper

* The obvious point of reducing the price to below the $25K mark

* Please do not compromise on the quality. I don’t like driving in the Honda Civic to San Diego because of the horrendous road noise. I prefer my Audi A6 (yes I own an Audi)

* Redefine the car as a lifestyle product and thus differentiate from other cars. The missing piece of the car spectrum is the lifestyle product that allows you to perform tasks/duties/have fun. Tesla has the unique capability to fulfill all these roles if only the massive screen centres around the driver. A GPS takes you from A to B but how about understanding the routine? How about suggesting groceries and planning for the best route? How about planning for picking up the kids? How about posting for a battery charge for the coming weekend? How about telling the user that driving from LA to SF is a risky proposition but here are ways you can reduce it (charging stations, preemptive charges, interesting locations enroute as distractions)? In every case the car understands the context and not just the route.


 I have NOT purchased a Tesla and for my income, my circumstances and my mindset I consider it too expensive and extravagant. I do love the ride of the car, the amount of space it offers, the next to zero road noise and zero engine noise. In my opinion after the Electronic Fuel Injection the next major step in automotive industry is Tesla Model S (not the Roadster). Come to think of it, the car has not fundamentally changed since the first combustion engine got tossed into it. I am fighting for Tesla purely because it has the potential to change the car industry that has been stagnant and content with reaping the benefits of inertia.

 Tesla also runs purely on electricity and that has huge implications. It is easier to optimise electricity generation and transmission than to change how we consume fossil fuels. Switching out the source of electricity from dirty coal to pseudo clean nuclear to clean solar/wind/tidal sources is a lot easier and transparent to the end user. Heck it is also scalable since various countries can mix and match the various sources of electricity they can produce. Nordic region can use the geo thermal energy while countries close to the equator can go for solar power. Electricity is the most atomic form of energy.

 If we cannot realise this and sweep everything out due to politics and leeches that plague our world, we as humans will be presented only one choice eventually – extermination. Tesla is one of the few instances where economics and common sense converge to form a cool product that can’t be labeled hippie. Who in their right mind would want to douse that flame? Apparently some folks in NC do.

Remote access to mysql

I have a Mysql daemon running on a my Ubuntu system and I was trying to remotely access it from my development machine. That is where hell broke loose because I just couldn’t. I read a lot of articles and stackoverflow articles with no proper resolution. I thought that it is important for me to post on my blog because I am certain this will turn up on google at a later stage when 2 yrs down the road I face the same problem.
I tried changing iptables, mysql bind address etc but none of them worked. So what worked?


# Edit /etc/mysql/my.cnf

Added bind-address as the dev machine’s ip address (or add % if you want to open it up to all ip addresses, though won’t suggest this)

# Add a new user accessible over the network

I used mysql workbench for this. In the administration pane, I added the Ubuntu (mysql) server, created a new user and gave the required access levels. Then I added my dev machine’s IP address as accessible sources

# Restart mysql

sudo service mysql restart

This worked. Other things did not work.

Paypal and KeePass

Something’s wrong with the folks at Paypal. I use Keepass for password management and my passwords are auto generated. They are not really ones you can type easily. Try auto typing from Keepass and Paypal says that the password is incorrect. The worst and misleading message around here. It doesn’t even fit any of the security procedures I am aware of. Does anyone have any idea why they do this?

Adventures in DIY

It began as what should I do this weekend and ended up with me owning and fixing a bicycle.
Last weekend I went by a yard sale where I spotted a Schwinn Aluminium bicycle. Upon a little digging the owner was willing to part with it for $15. Well it can’t hurt and atmost I’ll give up and drop it off at Salvation Army. So I bought it, brought it home and checked what the status on the bicycle was. Turns out the chain was jammed due to massive grime buildup, the two rims were wobbly and needed truing, the hand grips were more like booby traps, brakes were misaligned and more importantly the front tire and tube had burst open (presumably because the front wheel sat right in front of the exhaust on their car)
So off I went looking for all the parts. I could have paid like 100 USD to get all these things fixed but where’s the fun in doing that? So instead I made myself a new project.
Here are all the things I bought and/or had to use on the bicycle. Some were from Walmart while others were from Home Depot:
1) Tire
2) Tube
3) Bike lock
4) Grip gloves
5) Vinyl gloves
6) Wire brush
7) Simple Green
8) Dupont Teflon Silicone lubricant
9) Rags
10) Spoke wrench
11) Bearing grease
12) Bike helmet

Mind you that I did not have to purchase all of these. I had some already with me. Overall the bill I spent directly or indirectly on the bike would come to $70. I can guess that of these only the spoke wrench ($8) is a one time use thing. Others are perfectly usable on regular basis. I bought the Teflon/Silicone to fix my squeaky mechanical keyboard btw.
Overall I got the bike ready to roll for $85. I am certain that my bill would have been 140 instead of 70 had I gone for a professional repair shop and in all probability they would have done a much better job. I wanted this to be my project. Heck if I can’t fix a measly bicycle I don’t think I’ll be in any shape to fix anything else right?
When I first rode it, it was awesome and then I started noticing some kinks. The gears were slipping a bit and the chain fell off. I am certain this is a minor tweak as the chain is in good condition. I am thinking about a DIY lighting hack sometime later.
I must thank the numerous videos on Youtube where folks taught me a ton of things especially this video