Emacs tramp mode is really awesome. From windows if we use plink then everything just works, include things like vc-mode, make etc..
Thursday, October 29, 2009
Wednesday, October 28, 2009
git-changelog
I like to use git tag to keep track of revision versions in my code. When I do deliver my code, its usually as a prebuilt binary with code, generated documentation and most importantly a CHANGELOG file. What does happen is that the entire .git tree is not shipped. (Hey, if you need the git tree, just pull off it. You don't need a release).
I tried git-log to generate a CHANGELOG but it does not give me a mapping to tags. So, here's a bash script that does that.
Works like a charm!
I tried git-log to generate a CHANGELOG but it does not give me a mapping to tags. So, here's a bash script that does that.
# Generate a nice changelog from git
PREV=
for I in `git tag`; do
echo " ";
git log --pretty=format:" %s" $PREV..$I;
echo " ";
echo $I;
PREV=$I;
done | tac > CHANGELOG
Works like a charm!
The difference between FILE* and FD
Obviously using fopen, fwrite etc... is a little bit easier especially since you don't have to keep track of the location in the stream, using plain old open, write etc.. also have their uses.
Consider this.. I want to write a test case which writes to a file over and over again. The idea is to write x bytes to the file, seek to 0, and repeat.
Problem is that this will not work when you use FILE pointers. It will work most times, except when the file itself has to be created. In which case, using seek to 0 does nothing, because every fwrite will automatically seek to the end of the file. So, fopen a new file will always open it in append mode.
Consider this.. I want to write a test case which writes to a file over and over again. The idea is to write x bytes to the file, seek to 0, and repeat.
Problem is that this will not work when you use FILE pointers. It will work most times, except when the file itself has to be created. In which case, using seek to 0 does nothing, because every fwrite will automatically seek to the end of the file. So, fopen a new file will always open it in append mode.
Thursday, October 08, 2009
Its my baby
Started implementing my own stack based language. I have played a bit with factor and liked it, so I decided to base some things from it. I also have started to read a little more on forth and have now understood how some basic constructs can be created. Especially useful is jonesforth. The code is a must read!
So, the design goals I have in mind are as follows.
- Must be in embeddable in C. My main goal here is to be like Lua. A small library that you can call from C. The main users of this language would be hardcode C programmers esp. on embedded linux and embedded linux system testers.
- Must be written in ANSI C. Factor implementation has moved to C++ and also has a lot work going on in creating a fast and optimizing VM. I don't have that goal, as I want to be able to port my language very quickly to different hardware. The easiest way to port? Just recompile. Obviously, you lose out on some performance, but that's ok. The target audience will code most of the fast bits in C anyways.
- Must be simple. System testers should be able to use this language very quickly to write small tests. The main part of the test application itself would be written in C, but the scripting part would be in this language.
- Support for quotations, sequences. Ideas from Factor (and lisp) and good ones too!
- Reader macros would primarily be from C.
So far, I have the basic language working. It supports numbers, strings and quotations. You can define your own "words" and run them. There is a "if" control structure and a "loop" control structure. The implementation is still very buggy though.
Will keep posting as I progress.
Tuesday, September 22, 2009
Factor and Unicode
I'm just starting with Factor. More for fun rather than anything else. Selling it at work will be a real task!
Anyways, I was curious about unicode support.
So, I tried to reverse a kannada word! Here's what I got.
( scratchpad ) "ಕನ್ನಧ"--- Data stack:"ಕನ್ನಧ"( scratchpad ) dup--- Data stack:"ಕನ್ನಧ""ಕನ್ನಧ"( scratchpad ) reverse dup reverse--- Data stack:"ಕನ್ನಧ""ಧನ್ನಕ""ಕನ್ನಧ"( scratchpad ) drop--- Data stack:"ಕನ್ನಧ""ಧನ್ನಕ"
So far so good. But lets change the vowels!
( scratchpad ) "ಸಿದ್ದಾರ್ಥ"--- Data stack:"ಸಿದ್ದಾರ್ಥ"( scratchpad ) dup reverse--- Data stack:"ಸಿದ್ದಾರ್ಥ""ಥ್ರಾದ್ದಿಸ"( scratchpad )
Now, we have a problem! This is part of the FAQ.
Quoting -
Does Factor support Unicode?There is no one meaning to the phrase "Unicode support", but there are a few things that a modern programming language is expected to support in its library: UTF-8/UTF-16 input and output, Unicode collation, Unicode-appropriate casing operations, normalization, strings can hold any Unicode code point, and support for Unicode text rendering in the UI. Of these, Factor supports all but Unicode font rendering, which should be finished before 1.0 comes out.How do I convert a character to upper or lower case in Unicode?This isn't a well-defined operation. For example, the ß character becomes SS in upper case. Some letters have context-dependent case mappings. So if you need to change the case of something, use strings, not individual characters. The Factor Unicode library doesn't implement character mapping, because the behavior could only be incorrect. If what you're converting is just ASCII, then there are character conversion routines defined just for that. For case-insensitive comparison, partial collation keys might be appropriate.
Friday, March 13, 2009
Lua is a god send
I have been spending some time integrating Lua with some code. Its really good. Adding Lua scriptability is almost trivial and the payoffs are just amazing.
Worth checking out. Lua homepage.

Worth checking out. Lua homepage.
Saturday, March 07, 2009
Friday, March 06, 2009
YASnippet mode - The biggest time saver
If you haven't tried YASnippet with Emacs yet, then do it ASAP. Its awesome.
Its a clone of textmate's snippets feature, but I don't have Mac and haven't seen/used it. YASnippet by itself is awesome!

Its a clone of textmate's snippets feature, but I don't have Mac and haven't seen/used it. YASnippet by itself is awesome!
Monday, December 01, 2008
Clojure concurrency
Long but good post on Clojure - http://bc.tech.coop/blog/081201.html
Technorati Tags: clojure, erlang
Technorati Tags: clojure, erlang
Monday, November 03, 2008
Trouble with Logs
Interesting Post (via reddit) on logging and difference between logs and traces. Also, if you look below, there is a comment on logging in YAML. Now that really caught my eye. Because if it were JSON (which is essentially a YAML subset), we should be able to parse the log directly using Javascript. Taking it a bit further, if I have a log that is in JSON, then we should be able to create a live-update pretty easily.
Hmmm.. We are looking at some specific formats for logging in our applications. This maybe a good idea.
Technorati Tags: YAML, JSON, Logging
Hmmm.. We are looking at some specific formats for logging in our applications. This maybe a good idea.
Technorati Tags: YAML, JSON, Logging
Sunday, November 02, 2008
The power of clojure is growing
Clojure is a great idea. Take lisp, apply it to the JVM, add functional programming sauces and voila!, you can now do QT programming!
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: latex
Technorati Tags: latex
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: latex
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: latex
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.
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.
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: erlang
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: erlang
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!
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
A Simple Motor, Super Fun
A cool motor using just a copper wire, a battery and a magnet. link (via).
Myopic view of cool, electrical, motor
Myopic view of cool, electrical, motor
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 vnc, rdp
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 vnc, rdp
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
Myopic view of lua
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
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.
#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;
}
Myopic view of lua
Subscribe to:
Posts (Atom)