The Lumber Room

"Consign them to dust and damp by way of preserving them"

Archive for March 2008

Zsh/Bash startup files loading order (.bashrc, .zshrc etc.)

with 15 comments

If you have ever put something in a file like .bashrc and had it not work, or are confused by why there are so many different files — .bashrc, .bash_profile, .bash_login, .profile etc. — and what they do, this is for you.

The issue is that Bash sources from a different file based on what kind of shell it thinks it is in. For an “interactive non-login shell”, it reads .bashrc, but for an “interactive login shell” it reads from the first of .bash_profile, .bash_login and .profile (only). There is no sane reason why this should be so; it’s just historical. Follows in more detail.

For Bash, they work as follows. Read down the appropriate column. Executes A, then B, then C, etc. The B1, B2, B3 means it executes only the first of those files found.

+----------------+-----------+-----------+------+
|                |Interactive|Interactive|Script|
|                |login      |non-login  |      |
+----------------+-----------+-----------+------+
|/etc/profile    |   A       |           |      |
+----------------+-----------+-----------+------+
|/etc/bash.bashrc|           |    A      |      |
+----------------+-----------+-----------+------+
|~/.bashrc       |           |    B      |      |
+----------------+-----------+-----------+------+
|~/.bash_profile |   B1      |           |      |
+----------------+-----------+-----------+------+
|~/.bash_login   |   B2      |           |      |
+----------------+-----------+-----------+------+
|~/.profile      |   B3      |           |      |
+----------------+-----------+-----------+------+
|BASH_ENV        |           |           |  A   |
+----------------+-----------+-----------+------+
|                |           |           |      |
+----------------+-----------+-----------+------+
|                |           |           |      |
+----------------+-----------+-----------+------+
|~/.bash_logout  |    C      |           |      |
+----------------+-----------+-----------+------+

In more detail is this excellent flowchart from http://www.solipsys.co.uk/new/BashInitialisationFiles.html :

Typically, most users will encounter a login shell only if either:
* they logged in from a tty, not through a GUI
* they logged in remotely, such as through ssh.
If the shell was started any other way, such as through GNOME’s gnome-terminal or KDE’s konsole, then it is typically not a login shell — the login shell was what started GNOME or KDE behind your back when you logged in; things started anew are not login shells. New terminals or new screen windows you open are not login shells either. (Starting a new window in OS X’s Terminal.app seems to count as a login shell, though.)

So typically (or sooner or later), what you will encounter are non-login shells. So this case is what you should write your config files for. This means Read the rest of this entry »

Written by S

Sun, 2008-03-30 at 19:43:56 +05:30

Posted in compknow

Tagged with , , ,

African Institute of Mathematical Sciences

with 2 comments

TED talk by Neil Turok.

Neil Turok is a mathematician/physicist at Cambridge University.

He has founded an institute in Africa from which students have graduated to go on to great places, including for instance a student who is now pursuing a PhD at Cambridge under Stephen Hawking. They now want to start (a few) similar institutions in other sciences, and hope to replicate these successes.

Other notable highlights from the talk:

Maps from World Mapper. Maps in which countries’ areas correspond to a certain characteristic. Along with Gapminder, wonderfully illustrative visualisation tools.

“All known physics” equation:

Written by S

Sun, 2008-03-30 at 14:44:10 +05:30

Posted in Uncategorized

Tagged with , , ,

A history of Microsoft Word, and an insight into the Microsoft outlook

with 2 comments

(Ok, couldn’t resist adding the accidental pun to the title.)

Fascinating article from 2004, from a Microsoft employee.

I plan to revisit this post and clean it up (as always?), but here are some interesting quotes:

After a year of distrusting the company somewhat, I began to gain an appreciation of how Microsoft worked, and to see it for what it was – a machine that was focused on building products that people wanted, as quickly and as well as they could. Note the “quickly” – this was what distinguished MS from Apple in the end – a focus on moving quickly, and beating the competition. Details like great design were simply not critical to most (business) customers, so that sort of thing didn’t really make it into most products, except where it mattered to the target customer. It’s hard to fault this logic really – it is pure efficiency from a business perspective…

This is illustrative of the Microsoft outlook on doing business: great design is a “detail”; the main goal is to beat the competition and gain market share.

Both Microsoft and Apple have very smart people as employees. The goal at Microsoft is to grab as much share as possible, even at the cost of shoddily designed software if necessary. The goal at Apple is to design software that is simple yet powerful, and a pleasure to use. And both have been phenomenally successful at what they want to do.

The Microsoft approach is to get a release out of the door, see what the main reasons people have for not using it (not necessarily what people most complain about), throw patches (or wizards!) to get those issues across the level of acceptability, add new things, move on, keep moving — the appropriate scenario is not software design, it is war: it is all Fire And Motion.

So, that in a nutshell is the Microsoft method. Understand the market, and the customers, and then go pedal to the metal, with release after release focused on what the customers need, incorporating their feedback. That puts the competition into reaction mode. And of course it helps if they also make a strategic error because they are under so much pressure.

And how successful they have been. Even creating markets where there none.

“I think there is a world market for maybe five computers”
– Misattributed to Thomas J Watson, IBM president, 1943.

No one can disagree that Microsoft has had a bigger role in bringing computers to the masses than anyone else. Perhaps it would have been better if they hadn’t.

Another point is that it shows (again!) (twice!) that it is a really stupid idea to throw away all your code and start over.

Written by S

Sat, 2008-03-29 at 04:18:26 +05:30

Posted in Uncategorized

Tagged with , ,

Nostalgia

leave a comment »

It isn’t how I remember it at all!

At one time, this was what Sunday meant.

Written by S

Sat, 2008-03-29 at 03:10:40 +05:30

Posted in Uncategorized

Tagged with

WordPress theme that defies description

leave a comment »

and my understanding:

Here: CLI theme.

Now someone explain how this works :)

Written by S

Fri, 2008-03-28 at 05:45:24 +05:30

Posted in Uncategorized

Tagged with , ,

Poor man’s random number generators in C++

with 3 comments

There are random number libraries, Boost for example, but ugh. It needs you to create an abstract “generator” (representing a source of randomness), a “distribution” (like “uniform”, or “exponential”), a function that samples according to that distribution using that random source, and finally a call to that function.

Meanwhile, here are poor-man implementations, with sucky randomness etc, but shorter by far. (ll is long long, ld is long double)

//uniform in [a,b)
int runiform_int(int a, int b) {return a + ((b-a)*ll(rand()))/(ll(RAND_MAX)+1);}
ld runiform(ld a, ld b) { return a + (b-a)*rand()/ld(RAND_MAX+1.0); }
ld rexp(ld lambda) { return -logl(runiform(0,1))/lambda; } //Mean: 1/λ
ld rnormal(ld mean, ld std) { //Using the Box-Muller transform
  return mean + std*sqrtl(-2*logl(runiform(0,1)))*sinl(2*M_PI*runiform(0,1));
}

Written by S

Thu, 2008-03-13 at 05:58:17 +05:30

Posted in compknow

Tagged with , , ,

Lessig’s last Free Culture lecture

with 2 comments

That he gave at Stanford about a month ago.

It is a bit over 50 minutes long, but please watch it. (When you have the time and patience.)
It is an excellent overview of the entire copyright/culture issue. Near the end, he also outlines his plans for the Change Congress movement.

It is unfortunate that the video sometimes goes out of sync, has low sound etc. Headphones help a bit.

Link: http://blip.tv/file/680741/
Trying to embed: (But click on link above instead; that can be made full screen etc.)

Shorter videos: At TED (19 min)
From Good Copy, Bad Copy (7 min)

Written by S

Fri, 2008-03-07 at 15:37:54 +05:30

Posted in Uncategorized

Tagged with ,

Follow

Get every new post delivered to your Inbox.

Join 70 other followers