4.27.2012

global hgignore for linux

A global hgignore file is useful if you don't want to specify an ignore file for each new repository.

To create one, you need to first create a .hgrc file, if it doesn't already exist. The .hgrc file is one of the main configuration files that is read by mercurial. By default, this file can exist in several locations, including the .hg directory of a repository. It is recommended to place .hgrc in the home directory since this allows to specify system-wide settings at one location. This will be a convenient thing to do, if you have the habit of versioning your dot files in the home directory.

To specify a global hgignore file, modify the .hgrc file as follows:
[ui]
ignore = ~/.hgignore
Now create a .hgignore file in the home directory and use the glob/regexp syntaxes to automatically ignore anything you don't want.
# use glob syntax.
syntax: glob

# PROJECT FOO
*.pyc
venv/*
data/*

4.08.2012

Getting comfortable with Mono

Ever since I began using Linux as my primary OS, I have had nothing but great time. Being a .NET person in the first place, the Mono-Project is a god send for me. I tried using MonoDevelop, the IDE for Mono, on a daily basis, but learning that WCF is still largely unsupported made me drop the idea.

Lately I found myself wanting to continue my .NET practice while I am on my laptop. So I decided to try Mono once again. Instead of going for the IDE, this time I decided to use something lighter. I found two choices that suited my needs:

Geany for lightweight development and CSharpRepl for interactive evaluation.

Let us take a quick look at these two

Geany

Fire up Geany and type the following code in a new file "hello.cs":
class Hello {
    static void Main() {
        System.Console.WriteLine("Hello from Mono!");
    }
}
To compile this, press F8. This will bring up the Compiler message window in Geany with the following message:
gmcs /t:winexe "hello.cs" (in directory: /home/minato/Projects/Practice/mono)
Compilation finished successfully.
To execute it, press F5. A terminal windows opens up with the output of the program:


gmcs is the compiler which implements the complete C# 3.0 specification. The file hello.cs can also be compiled from the command line:
$ gmcs hello.cs
$ ls
hello.cs  hello.exe
To run the file, you can't simply type in hello.exe at the prompt like in Windows. An error will be thrown, if attempted:
$ hello.exe
bash: hello.exe: command not found
The file should be treated as a Linux executable and be preceded with ./, just like how shell scripts would be run:
$ ./hello.exe
Hello from Mono!
The more appropriate way to run the executable would be using the mono command:
$ mono hello.exe
Hello from Mono!
If a truly standalone Linux executable is desired, you can use a mono utility mkbundle to generate:
$ mkbundle -o hello hello.exe --deps
$ ls
hello hello.cs hello.exe

Now you can run it like a Linux executable:
$ ./hello
Hello from Mono!
In this way we can embed programs written in Mono in other programs and shell scripts.

CsharpRepl

In Windows, to test simple pieces of C# code, there are tools like SnippetCompiler and LinqPad. Snippet Compiler is like tiny IDE, which still requires some actions be performed manually. LinqPad is closer to a REPL. You can either evaluate individual statements or a group of statements or entire class files. It is better, but still not as powerful as real REPL.

Luckily Mono provides a built in REPL called CsharpRepl. Wanting to test a snippet of C# code, I decided to give it a shot. It is available in the mono-tools-gui package. There is something similar from Microsoft called Roslyn, but I am not sure how complete it is at the moment and how much of a true REPL it is.


This is what a REPL can do. REPL stands for Read-Eval-Print-Loop. In simple terms REPL is an interactive environment used to evaluate arbitrary snippets of code. Python, Ruby and several functional languages provide a REPL out of the box. Without a REPL, testing smaller pieces of code is difficult.

Thanks to the Mono-Project, I am able to reduce the dependency on my Windows machine for simple tasks.


4.06.2012

Diving into CrunchBang - Setting up development environment


Today I will talk about setting up my development environment on my laptop. I have narrowed down the choice of tools to the following:

Editors
    geany
    vim

Project management and configuration
    mercurial
    trello (web)

Software Design
    blockdiag
    seqdiag
    dia

vim
vim is like that awesome book or movie that you put off consuming until later. That later part almost never comes soon enough. You keep it in your thoughts for a long time, but never have enough momentum to take it forward more than a couple of steps. This happens with great things often. I wish to work on configuration stuff with vim. I know it is dangerous, but sometimes walking on a tightrope does teach you valuable things.

geany
Geany is the default text editor in CrunchBang. It is based on Scintilla. It has basic IDE features and loads quite fast. I have been able to adapt to it easily as it feels quite similar to Notepad++. Out of the box, Geany provides syntax highlighting for C# and Python among other languages, auto completion, build system for compiling and executing source code. Check out Geany.

Here is a screenshot of Geany.

Looking fabulous ain't it?
mercurial
mercurial is my favorite version control tool and is one of the very first things to be installed on any of my computers.

trello
trello is an awesome web based project management tool. Here is how I am using it for Violet:

No cards in the Done basket yet!
Notice the labels on the white cards? Labels can mean multiple things. I implemented the labels for signifying priority as well as the component the card is relevant to.

Red = High Priority.
Green = VioletClient.
Violet = VioletServer

Check out trello. It turns out that trello is from Fog Creek Software.

blockdiag, seqdiag and Dia
Since I am on a path to an all-round development, I figured I would throw in couple of awesome tools for creating simple UML diagrams based of text configuration. These are blockdiag and seqdiag, and are used for creating block diagrams and sequence diagrams respectively. Dia is one tool I had always wanted to try since my Ubuntu days. Dia is a more complete UML tool for Linux.