Wednesday, October 29, 2008

More on Latex tables

More issues with latex tables. I don't always agree with the placement algorithm that latex is using for my document. As a result, my tables are often placed away from related content. This is despite me using h! as a specifier. Any options?

Technorati Tags:

Tuesday, October 28, 2008

Latex Tables

Latex makes things easy if you are working on a large document. Plus, since everything is plain text, I can easily diff, merge, patch etc.. In general, I prefer latex to any WYSIWYG word processor, even though I end up running pdflatex quick often on the source.

However,  there is one item that's a real sour point. Tables. Its just not inituitive enough with Latex. Getting a nice spreadsheet view of things is a real plus point with word processors but with latex that just doesn't fly. You can use table and tabular environments, but they are still quick clumsy.

Assuming that you writing your document with emacs, the ideal scenario would be for a combination of org-tbl-mode and auctex. org-tbl-mode is really cool for tabular representation of data but just does not work with tex.

Technorati Tags:

Sunday, October 26, 2008

Uclibc vs. Glibc

I'm not sure about the differences. Lots of embedded linux products seem to use uclibc. The way I understand it, uclibc serves a particular market - embedded linux by cutting down on features that are not required. The question then is what do we lose?

We had to support both glibc and uclibc in a project sometime back. The project is still ongoing, but I seem to have forgotten what were the changes we had to make and test for.

If I have a threaded application, will it compile against uclibc? It will, but I don't know about all the differences. Will keep updating this post with differences as I come across them.

Saturday, October 25, 2008

A Stack in Erlang

I have been playing around with Erlang for a couple of weeks now. Its a really cool language and here's my first attempt at implementing a stack in it.

The basic design is to have process that gets different commands as messages, and updates the stack accordingly. Erlang being a functional language, implies that we cannot use an imperative approach. So, here's what the process looks like.

stack(S) ->
io:format("Stack:~p~n", [S]),
receive
{push, PID, Data} ->
PID ! success,
stack([Data|S]);
{pop, PID} ->
if
S == [] ->
PID ! failed,
stack(S);
true ->
[H|T] = S,
PID ! {success, H},
stack(T)
end

end.

Its pretty simple actually, but I did have a lot a trouble with push. Each push would create a list within a list, which meant that there could be only 2 pops. However, if we spawn stack with [] as that input parameter, then it works fine.

Next steps -> Get some more stack operations going. I'm going to implement a couple of functions - dup, swap, rot.

Technorati Tags:

A whole new world

This blog is about my thoughts on software, programming, project management etc.. In short, anything that related to my professional interests. What are my interests? I like different programming languages, productivity tools, documentation tools, and in general just coding. Who am I? I'm a software architect in India and this is my blog on technically, anything.

Monday, May 14, 2007

Ubuntu for me

Eva's laptop has been acting up for sometime now. I finally decided to get right of windows, and install Ubuntu. Well... Not quite, I still have windows. Err.. Not yet.
I have left a 40 GB partition open for windows and I'll probably reinstall WinXP on that partition.

Anyways, I downloaded Ubuntu. It took me 9 hours! Nope I'm not joking. I lost 2 hours of download when the connection to a mirror at Singapore was lost. So, the download had to be restarted with a mirror in Oz and that took 7 hours.

I finally burnt it on a CD and got started. Everything was done with the greatest of ease. 30 mins later, I had the laptop up and running. But sadly, I couldn't connect to Gooze's Wireless connection. I tried using Ubuntu's inbuilt wireless configuration tool but that didn't work.

So, I tried to configure it manually by using iwconfig. That too didn't get wireless up and finally I had to do a bit of googling. It turned out that I need to use wpa_supplicant as the router was configured with WPA and not WEP.

I just followed the HOWTO and voila! its time for another blog entry.

Other than the WPA part, everything else was really smooth and cool. Its the fastest Linux install I have ever done. My first one was a Slackware installation over an UMSDOS partition and that just screwed up entire Win98 installation. So, it was a RH5.0 that I installed and cleaned out my Win98. After a few years, I reinstalled Windows in a separate partitions. Here I am, 10 years later, with just Linux on my m/c and no WinXP. A full circle!

Saturday, April 21, 2007

Wednesday, April 18, 2007

A story of VNC and RDP

I have a laptop and a PC at work. The laptop has a docking station that allows me to have a dual monitor setup. So, I connected the Monitor from my PC to the docking station and started using a dual monitor setup.



As expected, the productivity gains by having a dual monitor setup is great, but my PC lost out.



For a couple of months, I stopped using my PC and started using my Laptop for nearly everything. But its not an ideal situation. Builds, large downloads etc. are best on a PC because I can just lock the PC and let it run in the background. Whereas on a laptop, I usually hibernate the laptop when I go home and so, any builds or downloads will stall.



I decided to setup VNC between the two today. I used TightVNC. However, I found that the refresh rate pretty much sucks. Given that the two are just a few feet apart, and on the same network, I expected it to be nearly realtime.



A colleague suggested that I use RDP instead. I tried it out. Its amazing! The refresh rate is realtime and it looks like I'm using the PC itself. Plus, it allows me to run it on my second monitor. So, I can have applications from both my PC and my laptop on the second monitor and there is really no way to figure out if they are from the PC or the laptop.



VNC is pretty bad when it comes to running on a second monitor. If you go "full screen", the server display disappears and you are back to the extended desktop from the laptop.



All said and done, for this kind of setup, RDP is really cool. VNC has its uses especially if for multiple connections, heterogeneous environments etc. Coding Horror has an excellent comparision of the two here.



Myopic view of ,

Sunday, April 15, 2007

Lua: Hello Mundo

The C API in Programming in Lua does not have a Hello World program. In addition, if you try to follow the example, and compile your code, the program crashes and displays the following
PANIC: unprotected error in call to Lua API (no calling environment)
So, I went to the Lua Users Wiki and found some tutorials but still no "hello world" program. So, here it is below

#include <stdio.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>

int main(int argc, char* argv[])
{
char buff[] = "print(\"hello world\")";
int error;
lua_State *L = lua_open();

luaL_openlibs(L);

error = luaL_loadbuffer(L, buff, strlen(buff), "line") ||
lua_pcall(L, 0, 0, 0);

if(error)
{
printf("ERROR: %s", lua_tostring(L, -1));
lua_pop(L, 1);
}

lua_close(L);

return 0;
}
The code itself is self explanatory and the API interface is very interesting. A stack based approach to pass information to/from C from/to lua.

Myopic view of

Saturday, April 14, 2007

Excellent article on Chicken Scheme

This is really a great article on Scheme. Have a look at the linked articles, they are equally good. I need to give Chicken Scheme a try soon!



Myopic view of

Monday, April 09, 2007

Great site about vim

I use VIM a lot and its almost down to me being unable to code without VIM. This list is really cool! Plenty of tips that will help both rookies and veterans.



I particularly liked the tip about writing to a shell using :w !sh (or in the case of winxp :w !cmd). Its a really cool way of renaming files!



Myopic view of

Tuesday, April 03, 2007

Parameter Passing in C

A favorite question that a friend asks in interviews is related to the usage of a stack in C. His question to the poor sod on the other side is - if a function does not return, what could be some of the reasons?



Naturally, some of the answers are

1. There's an infinite while loop inside

2. The function is recursive and does not have a base result

but the answer that my friend looks for is

3. The return address on the stack has been corrupted.



The funny thing is - the C99 Standard does not even mention the word "stack" anywhere.

I asked a question about parameter passing on comp.lang.c and everyone agrees.



Its time to correct my friend!



Myopic view of ,

Thursday, January 25, 2007

A subtle difference

Consider the the following
(define (power-n x)
(define power-x
(lambda (n)
(if (= n 0)
(list 1)
(cons (power x n) (power-x (- n 1))))))
power-x)
The above definition basically defines a generator function. A slightly different definition using a named let is

(define (power-n x)
(lambda (n)
(let power-x ((n n))
(if (= n 0)
(list 1)
(cons (power x n) (power-x (- n 1)))))))
In the first case, we define power-x and then explicitly return it. In the second version, we create an anonymous function and return that automatically.

In both cases, we can create generators such as power-two as
(define (power-two n)
((power-n 2) n))
Thanks to a thread on comp.lang.scheme for fixing things!

Myopic view of

Saturday, January 20, 2007

Scheme48 + Cygwin + Xemacs

I had installed MIT Scheme to use as my base for learning Scheme. I created a nice little phone book language that would operate on a database of phone book entries. However, there was no way to use the little language other than by first starting MIT Scheme and then loading the file. This was cumbersome, but it was still a toy project.

I recently installed XEmacs. I'm basically a VIM guy but I wanted to try out the *other* editor philosophy :-). All said and done, it was still configured to use VIPER! I knew that emacs and friends use a lisp dialect and so it would be fun to see what its like to have an integrated enviroment.

After a quick search, I found a package for XEmacs that allows it to run an inferior scheme process i.e as a child. However running MIT Scheme screwed things up. On Windows, the parent-child I/O model is quite different from what XEmacs wanted and as a result it was not going to work.

So, I installed Scheme48. Installed is not quite the right term, because there is a native windows application available. Instead, I downloaded the source and built it on top of cygwin. That's when all the problems that are associated with a 'minimalist' language like scheme hit. MIT scheme has its own library of useful utilities and its own functions for things like File I/O. I spent an hour or so cleaning up and moving to Scheme48.

The end result? Much happier. XEmacs run scheme48 as an inferior process quite nicely. Plus, I getting a hang of some of the XEmacs commands that run on the inferior process or for that matter even a shell. So, I now have my phone book application and I don't have to leave XEmacs. Perhaps, there is something to this *different* philosophy after all :-)

Myopic view of , ,

Thursday, September 07, 2006

A Review of Puppy Linux

I have an interesting problem. I want to run linux at work, but don't want to lose the space on my laptop. The solution? Use a live-cd linux distro. At the same time, I'm not looking for too much and so a full blown live-cd distro like knoppix would be overkill.

So, it was going to be a small distro. What's also nice about small distros are that they are extremely easy to use. They aren't bloated (Hey! how much can you fit into 50 MB) and they still seem to have the necessary bits plugged in. I found a few and had shortlisted it down to DSL and Puppy Linux. I gave DSL a try before switching over to Puppy Linux. Don't get me wrong, I liked DSL quite a bit but I found some of the features on Puppy Linux quite a bit better.

Some of the things I really liked about Puppy Linux was its support for the 2.6 Kernel and thereby pretty decent support for hardware. Since I have a laptop, WLAN connectivity is a must and that's what I wanted from Puppy Linux. I gave a good RTFM before actually trying it out and expected Wifi to work out of the box. It didn't. It took me a *lot* of time and effort before I realized that I need to download and install an additional package which patches the Wifi connectivity for my laptop. This wasn't as bad as it seems because of a really cool feature that the distro has - multi session live CD. Basically, this feature allows for software to be installed on top of the same cd and not just that, it allows file modifications to be saved as well. This really is a superb solution, because it gives the illusion of a read/write filesystem on what is actually a read only media. Naturally, this doesn't come for free and the more you save, the longer it takes to boot.

There are a lot more features than just this. Puppy Linux runs off a ramdisk, and so you can remove the Live-CD once it boots. This frees up the CD ROM drive. Plus, this distro makes replication really really easy. All you need to do, is pop in a different CD, and save and it gives a new CD with all the software. This is still a bit unstable though, and I had some problems when I used it, but I does work.

On the whole, I really liked Puppy Linux. Its easy to use and some of its features are seriously cool. No doubt I would be spending more time on it trying to customize it to my liking and yet try to keep things as simple as possible.

Tuesday, June 27, 2006

Some free ebooks from oreilly

Its not a comprehensive list, but oreilly has decided to open out some of their books. link.

Perhaps a book was outdated enough to be put out of print, yet some
people still needed the information it covered. Or the author or
subject of a book felt strongly that it should be published under a
particular open copyright. Maybe the book was written collectively by a
particular community, as in the case of our Community Press books.

On the whole I think this is a good idea. There are books I definitely want to read
1. Linux Device Drivers (both 2nd and 3rd editions)
2. Unix Text Processing
and to a lesser extent
3. Version Control using Subversion

Monday, June 26, 2006

Setting up a blog using Sharepoint

Sharepoint is great. It makes collaboration within and across teams really easy. I use it all the time at work. It takes a bit of effort to create a personal page on sharepoint though. Here's what I did.
1. Created a new site with my name
2. Modified the main page with only announcements and a contacts widget.
3. I added only myself to the contacts in the site and changed the display to Newspaper type.
4. The announcements widget automatically act like a blog!!!

Friday, June 16, 2006

Now that BillG ....

.... is leaving out come the ancedotes. Joel has a great one where he talks about his experience as a Program Manager of Excel. Apparently he was responsible for Visual Basic integration with Excel and had to go through a review with Bill Gates. link.

Thursday, June 15, 2006

Webdav and box.net

Systems Boy has an excellent post on publishing ical calendars on the net using box.net. link.

Going further, I tried to find some tools that use webdav. One option is to use tcl vfs. However, this is pretty useless if one is behind a corporate firewall. Next I found a tool called cadaver. Again this doesn't have proxy support.

In the end hunting around, I found that IE itself supports webdav. The only thing is that they don't call it webdav. Instead they call it webfolders! Believe it or not this info comes from mozilla.

So here is what to do if you want to have a 1 GB of storage space on the net.
1. signup with box.net
2. start IE and do file->open "http://www.box.net/dav". Check the option for webfolders
3. Voila!! Now you can store/retrieve files from box.net!!