Nilesh Trivedi http://www.nileshtrivedi.com Most recent posts at Nilesh Trivedi posterous.com Fri, 10 Feb 2012 02:12:40 -0800 936 Months http://www.nileshtrivedi.com/936-months http://www.nileshtrivedi.com/936-months This Abstruse Goose comic inspired me to make this: http://936months.staticloud.com/

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/YS9rJnwFTvH Nilesh Trivedi contemplation Nilesh Trivedi
Sat, 14 Jan 2012 23:13:00 -0800 Why I Will Not Buy Asus Transformer Prime http://www.nileshtrivedi.com/why-i-will-not-buy-asus-transformer-prime http://www.nileshtrivedi.com/why-i-will-not-buy-asus-transformer-prime

When I first heard about Asus Transformer Prime, I was very excited. This was the first combination of power and portability with a touchscreen that made the cut for me. Other tablets are more of consumption devices, where as I want a device with which I can get some real work done too. That meant 10" screen at the minimum and a keyboard dock, good battery life and decent processing power. In other words, I want a netbook / tablet hybrid. The specs for Asus Transformer Prime seemed perfect.

Then came the bad news. Problems were reported with the WiFi and GPS capabilities of the device because of the all aluminium casing. The tablet launch was delayed because of these. WiFi issues may have been resolved now but the GPS issues are real and Asus has acknowledged that there is nothing they can do about it. They have now removed GPS capability from the specs page.

The deal breaker, however, was when people discovered that Transformer Prime would come equipped with a locked, encrypted boot loader. That means users won’t be able to install alternative operating systems on this machine which it is otherwise perfectly capable of. It will come pre-installed with Android which you can fix or upgrade ONLY IF Asus provides the updates. This is utterly unacceptable to me. Buying a computer which cannot run code of your choice is like buying a hard disk which cannot store data of your choice. While OEMs have started following Apple's lead in convincing the buyers that software is tightly coupled with hardware and you really buy an iOS or Android device, and not a general purpose computer, I expected the taiwanese / chinese manufacturers to skip this bullshit and offer decent hardware, without limiting it artificially with locked boot loaders.

Predictably, there was immense outcry against this. Users were angry because they had pre-ordered this machine without knowing that it would come with a locked boot loader and Asus had pulled an unexpected betrayal. Asus then responded to criticism by giving a bullshit defense and at the same time giving in, saying that they will develop a boot loader unlocking tool. However, and this is important, the warranty will be void if the boot loader is unlocked.

Better, but still unacceptable to me. Let's assume that they actually do provide this boot loader unlock tool for free and without restrictions - even though making this assumption would not be prudent considering how they behaved. Even with this, Asus Transformer Prime is a product that effectively comes with no warranty. Let me repeat that: Asus Transformer Prime effectively has no warranty. Installation of operating systems on a computer is as natural and intended use case as is filling your car's fuel tank. If Honda offers a car with the restriction that warranty becomes void if you refuel it at a gas station which is not owned by Honda, how good would you think the deal is? To make this deal acceptable, Asus would have to heavily discount the Transformer Prime. Since they are not doing that, Transformer Prime remains a crippled and expensive product - just like all the other tablets in the market right now.

My conclusions from this episode:

  • Transformer Prime is not worth its price.
  • Avoid pre-ordering anything. Buy only after it is launched and real data is available on what is included and what is not.
  • The search for a good computer OEM continues.

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/YS9rJnwFTvH Nilesh Trivedi contemplation Nilesh Trivedi
Sat, 05 Nov 2011 02:01:00 -0700 My letter to CERT-IN http://www.nileshtrivedi.com/my-letter-to-cert-in http://www.nileshtrivedi.com/my-letter-to-cert-in

CERT-IN has destroyed its credibility

It took a single statement to completely demolish the trust which I had in CERT-IN.

According to your website, your charter is "to become the nation's most trusted referral agency of the Indian community for responding to computer security incidents". It is not a political organization and should not have a political agenda of it's own. Thus it is expected that you have the ability and the intention to analyze a situation objectively.

However, when a Director General (Dr. Gulshan Rai) of CERT-IN resorts to personal attacks without any basis instead of focusing on the question at hand, it becomes obvious that the personnel of CERT-IN have a political agenda of their own. This completely destroys your credibility and authority to lead a technical organization.

I am referring to Mr. Gulshan Rai's accusation (source: http://www.medianama.com/2011/11/223-were-not-a-front-for-anyone-were-not-funded-by-google/ ) at Cyber Security India conference that all of Indian media (like Medianama ) as well as citizen groups like CIS India are financed by MNCs like Google when the interviewer wanted to know about RTI queries on blocking of websites. Instead of dealing with the actual content of the question, he resorted to ad-hominem attacks just like a politician.

You have destroyed your credibility, made it obvious that the leadership of CERT-IN is politically biased and therefore, I am no longer interested in what you say on any technical issues.

Regards

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/YS9rJnwFTvH Nilesh Trivedi contemplation Nilesh Trivedi
Sun, 30 Oct 2011 12:59:00 -0700 Should We Philosophize ? http://www.nileshtrivedi.com/why-philosophize http://www.nileshtrivedi.com/why-philosophize

Given that philosophy literally means "the love of wisdom", the question can be rather simply stated as "Should we think?". While it may seem trivial, it still needs to be investigated. Let me attempt to understand this question by breaking it down into parts. The affirmative answer is subject to 3 underlying premises as I understand it.

First belief that all of us possess is that we are free agents with an ability to exercise choice. Although free will is far from understood, the so-called "illusion" of choice is a rather strong one. Even though, as biological entities, we are born with an intricate web of instincts and desires, there does seem to be a part of us which has the power to veto. Call it the conscious mind or the self-aware brain, the whole exercise becomes futile and leads to nihilism if we give up this premise that we have choice. The fact that you are asking the question "Should we think?" implies that you already acknowledge the choice of not philosophizing. Neo said it rather succinctly in The Matrix: "The problem is choice".

The next assumption is that the choices we make lead to consequences which are somewhat, if not completely, predictable. This basically means that there exist laws of nature which are discoverable and comprehensible. This is the subject matter of the natural sciences. The more you know about the laws of nature, the better guesses you'll be able to make about the future.

And the last premise that is needed is that the future "matters". That is, some of the consequences are more desirable than the rest. This desirability of a state of affairs may be hard-wired into us, but it exists nonetheless. Moreover, as free agents, we also have the ability to "chose" our own goals and our own paths. This last question of "What really matters?" is where science cannot help and philosophy alone needs to carry the burden.

In short, yes, you should philosophize if you accept that (1) you have the ability to exercise choices, (2) you have the ability to guess the consequences of those choices and (3) some consequences are more desirable than others. Philosophy is useless if you disagree with any of these premises. (Exercise: try removing each of those premises and see what conclusion it leads to). A much simpler summary of this would be - any agent who wonders "what should I do?" is a perfect candidate for philosophy.

To reach the affirmative answer, we have only used these 3 premises and nothing else. You may believe in immorality or solipsism, but philosophy would still be useful to you. And even if you disagree with these premises, philosophy in itself may be a pleasurable activity thus needing no justification of utility at all.

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/YS9rJnwFTvH Nilesh Trivedi contemplation Nilesh Trivedi
Fri, 14 Oct 2011 12:58:00 -0700 A Quick Introduction To Ruby http://www.nileshtrivedi.com/a-quick-introduction-to-ruby http://www.nileshtrivedi.com/a-quick-introduction-to-ruby

I wrote a no-nonsense introduction to Ruby for people who already know how to program in some other language. This article does not waste time with programming basics or syntax details which one can learn easily anyway. I hope this gets you started in the beautiful, happy world of Ruby.

Introduction to Ruby

Ruby is an interpreted object-oriented programming language. This means you have classes, objects, instance methods, instance variables, class methods, class variables and so on. Ruby also supports other programming paradigms like functional programming, ad-hoc scripting etc. I will directly jump to features which are unique to Ruby - especially if you are coming from C, C++, Java background.

Everything is an object
Yes, everything is an object. Integers, Floats, Booleans, Strings, Arrays, Hash - everything is an object. Even "Class" and "Module" are objects. You can have code like:

>> 24.to_s + true.to_s
=> "24true"

Classes are open
Classes and Modules in Ruby are not set in stone after loading. Methods can be added, modified or removed from such classes at any point of time in the program execution. For example:

>> s = String.new("hi")
>> puts s.upcase
=> "HI"

#Now let's modify the built-in method dynamically. No restart is needed.


>> class String; def upcase; "abc"; end; end
>> puts s.upcase
=> "abc"

We have modified the method "upcase", which is built in the core Ruby class "String", dynamically. You can do this with any other class. This means that features can be added and removed as you wish. In fact, even the core language features can be improved without ever restarting the program. It gives the developers tremendous flexibility in designing frameworks and applications. If a library has a bug, you can fix it yourself without touching its code base. You can also add features to ruby/library at runtime. 

Syntax is delightful
Ruby does away with a lot of verbal overhead with some syntactic sugar. Consider:


1. Parantheses are optional while calling methods. Instead of 

>> employee.promote("manager")

you can write:

>> employee.promote "manager"

2. Operators like +, -, =, ==, * , /, [] are implemented as regular methods and there is nothing special about them. You can still use them as you are used to. For example:

>> a + b

is equivalent to:

>> a.+(b) # calls the "+" method on object "a" with "b" as the method argument

When you write:

>> obj.name = "hi"

the code that actually gets executed is this:

>> obj.name=("hi")

so "hi" is passed as an argument to a method called "name=" (note the equal sign). 

Encapsulation by default.
Java has a convention of using getter and setter methods like:

String getName() {
  return this.name;
}

and 

void setName(String name) {
  this.name = name;
}

This kind of design is good practice because it hides the internal variable "this.name" from the outside world and protects against misuse. However, the code calling getters and setters is too verbose and painful.

In Ruby, you can do:

def name
  @name
end

def name=(name)
  @name = name
end

And then you can simply use:

>> obj.name
=> "xyz"
>> obj.name = "abc"
>> obj.name
=> "abc"

So you get the best of both worlds. Getters and setters so that data is encapsulated as well as a code syntax which looks like as if you were just using a property variable normally. Instance variables are private by default so encapsulation is enforced.

Still shorter and prevalent way of defining the above two methods is:

attr_accessor :name
# 6 lines of code reduced to one. More importantly, look how readable the code becomes. It's declarative.

We are calling a method "attr_accessor" with a string argument "name". This methods creates the getter and setter methods dynamically which are equivalent to the ones we wrote above. Isn't metaprogramming awesome? Code that writes code for us. :) Note that attr_accessor is a regular method and not a keyword. This means that full power of ruby is available to you even when you are defining classes. No need to worry about compile-time vs runtime. Everything is runtime (almost).


Modules
Multiple-inheritance (having more than one superclass) is a tricky issue in programming. Tricky because it causes ambiguity in method lookups. Lets say class A inherits from class B and class C. Both B and C have a method called "say_hello()". Now see this code:

obj = A.new
obj.say_hello()

Which method should be executed now? The one in class B or class C? C++ had a messy solution for this with virtual functions where as Java simply wiped its hands off by enforcing single-inheritance (single parent per class). But most real-world objects inherit their behaviour from multiple parents. For eg., Car should be the sub-class of both FourWheeler and PetrolVehicle. This kind of modelling becomes difficult in Java.

Ruby brings the concept of Module. Although a class can have only one immediate superclass, it can include as many modules as it needs. Including a module is almost similar to inheriting from it. So we could write our class as:

class Car < Vehicle
  include FourWheeler
  include PetrolVehicle
end

The method lookup ambiguity is resolved with a specific method lookup order. Read more on this topic as this is one of the most fundamental aspects of Ruby.

String interpolation
How often have you seen code like this? :

"my name is " + obj.name() + " and I live in " + obj.city() + " city."

Functional but ugly code. In Ruby you can do the above but there is a cleaner and more preferred method.

"my name is #{obj.name} and I live in #{obj.city}."

Code is data
Ruby supports meta-programming - which means that code can be used, passed around, and manipulated as any form of data. You can write methods which accept a block of code - apart from the regular data variables - as an argument. This make Ruby really powerful. Read more on BlocksProcsYield and Lambdas.

# Standard way of programming.
>> "hi".upcase # returns "HI"

# Dynamic programming
# works same as above but notice that the name of method to call is a string so can be decided at runtime
>> "hi".send("upcase") # returns "HI"

Here, you are sending the string object ("hi") a message called "upcase". If a method exists with this name, it will be executed. So method calling is basically message-passing. Makes it easy to design actor-based systems.

If you have read SICP, you would of course remember the methods map, filter, enumerate. What a revelation they were! They are implemented beautifully in Ruby using blocks.

# An array of students is given. Promote all students who are boys and whose age is greater than 12 to the next class and return an array of their names
>> students.select { |s| s.is_boy? && s.age > 12 }.each { |s| s.promote }.collect(&:name)

That's it. No nested loops, and iterators/enumerators to worry about. The code here is simply the procedural expression of your requirements! You can easily see how easy it is to fix bugs in this code. Abstraction and hiding details is a good thing and Ruby provides techniques to do it really well. It is also a great vehicle for developing higher-level domain-specific languages.

Meta-programming is my favorite aspect of Ruby. All the power of Lisp. And what pretty syntax it has! :)

Cool ? :)

I hope this gets you excited about this language. There are tons of really nice features that we have come to love, but you can discover them on your own. Feel free to ask any questions or doubts you have. And remember, the underlying philosophy of Ruby design was: "Programmer's happiness". :)

 

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/YS9rJnwFTvH Nilesh Trivedi contemplation Nilesh Trivedi
Mon, 12 Jul 2010 12:00:00 -0700 Monsoon Treks In Maharashtra http://www.nileshtrivedi.com/monsoon-treks-in-maharashtra http://www.nileshtrivedi.com/monsoon-treks-in-maharashtra

Monsoons bring an amazing display of natural beauty to Maharashtra's western ghats. A number of forts, hills and lakes adorn this region. I have been trekking to some of these destinations on weekends. Here are some snapshots from few of my trips.

Visapur and Lohagad Forts

How to reach: From Lonavala, go about 8 km on the Old Mumbai - Pune highway and take right towards Malawali and then Bhaje gaon. Night stay is possible atop Loahagad in caves.

Raigad Fort

How to reach: Reach Mahad by Bus. Mahad to Raigad is about 20km. Buses are not very frequent so you might need to hire an auto-rickshaw. Last returning bus to Mahad is at 6pm and night stay is available at the top in cottages.

Mahuli Waterfall

How to reach: Reach Asangaon by the local train. Base village is about 8km and you can get an auto-rickshaw for about 150 bucks but a walk would be much better.

Bhandardara

How to reach: On Mumbai-Nasik highway, take a right from Ghoti

Lavassa

37 kms from Pune towards Mulshi Dam

Malshej Ghat

3 hours drive from Kalyan towards Ahmednagar

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/YS9rJnwFTvH Nilesh Trivedi contemplation Nilesh Trivedi
Fri, 11 Jun 2010 13:29:00 -0700 Ubuntu 10.04 (Lucid Lynx) on Dell Vostro 1520 http://www.nileshtrivedi.com/ubuntu-1004-lucid-lynx-on-dell-vostro-1520 http://www.nileshtrivedi.com/ubuntu-1004-lucid-lynx-on-dell-vostro-1520

Dell's Vostro 1520 is a solid notebook for work because of its sturdy build, non-glossy 4:3 screen and performance/price. Ubuntu's latest release on this would be a perfect setup for programmers. However, there are a few quirks here and there with hardware support. Here's what I did to fix them.

Download the desktop ISO for i386 platform and install normally. I chose to mount /home and /stuff on separate partitions so that I always have the option of chosing upgrade or fresh install when the next release comes around. Dual booting with Windows XP/Vista is no more necessary because of VirtualBox.

Remember to stay connected to the Internet during the install. This makes some restricted drivers, like for broadcom wireless card, available to you automatically.

Once the install is complete, restart your notebook. Connect to the net using ethernet and install all available updates using System->Administration->Update Manager.

First problem is that wireless card does not work. NetworkManager menu shows that "wireless is disabled". Go to System->Administration->Hardware Drivers and activate the Broadcom STA wireless drivers. Restart the computer. However, wireless will still not work. To fix, do the following:

sudo rmmod dell_laptop

At this point, wireless indicator will light up and after a while, you'll be able to connect to the available wi-fi access points. However, the dell_laptop kernel module will get loaded again on bootup and hence, the fix is not permanent. Let's make it so:

echo 'blacklist dell_laptop' | sudo tee /etc/modprobe.d/blacklist-custom

Wireless should be working fine from now on.

Next, let's make your Tata Photon+ wireless broadband card work. The modemmanager package shipped with Lucid is buggy. Hardik has created a patched version which solves this problem. Here are the instructions.

After verifying that bluetooth, webcam, memorycard, touchpad and sound are working fine, it's now time to install a few additional packages. First, let's get multimedia support with audio and video codecs, flash and Java plugins, MS fonts:

sudo apt-get install ubuntu-restricted-extras vlc

Some basic utilities:

sudo apt-get install pidgin liferea chmsee inkscape wine cheese gthumb

Now let's make the system programmer-friendly:

sudo apt-get install openvpn network-manager-openvpn ssh virtualbox meld

You might face difficulties in using VPN with NetworkManager. Apply this patch to fix this problem.

More goodies:

sudo apt-get install build-essential subversion git-core gitk git-gui

Do not forget to install these Firefox extensions:

  • Firebug
  • Web Developer Toolbar
  • Screengrab
  • YSlow
  • AdBlock Plus

 

Install Google Chrome. It's a great browser for daily usage and you will also be able to test your websites with WebKit.

And finally, a web developer's toolbox:

sudo apt-get install apache2 mysql-server ruby-full sun-java6-jdk

Enjoy!

 

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/YS9rJnwFTvH Nilesh Trivedi contemplation Nilesh Trivedi