Friday, 15 April 2011

Structures: C -> Java -> Python -> Erlang

With C we had structures and unions.
I like them, because, I don't always need to embed behaviors with data(class).

So you'll do something like

With Java, I'm forced to use classes, because that's how java is structured.
They are purely object oriented. (eg: in C++)



In python, you can take java's approach; but since Python is not Java ;-) and we
tend to write less,
We'll use dictionaries (or hashes in Perl)


I'm a newbie to earlang (and to functional programming),
I think there's no dictionaries, but tuples.

Here's how we use tuples to achieve same (also applicable to python)


much like json, isn't it?
notice, there are no quotes around someone, that's an atom (this is erlang dude).

This in python:
Well, how do we understand what's what?

hmm, ok, we can tag them with atoms, (this is a programming practice in erlang world)
so our earlier example becomes,

That's it.
You can do this with python too, like as I've shown below;
(but I personally prefer the use of dictionaries, as I've shown before)
    
But don't try to write programs in earlnag way in python, why?
Python got dicts, it's just an overkill to use tuples like this.
Also, in earlang, there're some language specific features that we can make use of.

In Earlang, we extarct values using pattern matching operator,

 2nd line will cause error.

it'll fail with an error. see, how it matches atoms at LHS and RHS.
(in python, we don't have this feature, since '=' is just an assignment operator as every
other object oriented/proceedural programmer think it is.)
we can use this in many interesting ways, for example, to distuinguish different
data structures at runtime and extarct them properly.

Just for the sake of it, I'll show another method to extract values called
"unification", which is useful for selective extarction; here it is...
But differntially from object oriented approch, we no more had a template now.
We'll use functions to create and parse these dictionaries and tuples.
(Pythonists like to write more functions than classes, because, python make it
really unncessary to write classes always, and we have 'Zen of python'.)

Monday, 4 April 2011

My Desktop setup


Here goes my desktop.

Operating System: GNU/Linux
Flavour: Ubuntu (Debian Derivative)
Version: 10.10 (kept up to date)
Hardware(striped down): Intel C2D, 4GB, 320GB. 
Manufacture & Model: Toshiba Satellite Pro.

Desktop Manager: Gnome
Compositing Manager: Compiz
Gnome-panel : set to be hidden always and removed all that I can from the panel. (ie., panel is empty now, but we can't remove last panel completely.)
Icon ThemeFenza Dark. (see link for ppa)
Menu: Cardapio Menu (using ppa) it even have awn applet. 

Other gtk themes in use: Elegent, Equinox, A new hope.
Other Icon theme in use: awoken
Cursor theme: X11-Gear (Sorry, I can't find exact package now, but it's there)
File Manager: nautilus-elementary  (nautilus isn't complete with this, sleek elegant look,breadcrumbs, inbuilt terminal, clutter view) and make use of extra pane and tabs ;)
File Preview: Gloobus preview

My Conky Configuration File

Edit :                        (Aug 17, 2013)
All my configurations including conky's are now hosted at https://github.com/kra3/dot_files



I've been hearing about this conky for a long time.
I think I tried it once in my 5 years of linux experience.
But, I haven't experienced it till last day.

Conky is a system monitor originally based on torsmo! What the heck is this "torsomo"?
Honestly, I don't know. Le me google that for you....

Torsmo is a system monitor that sits in the corner of your desktop. It's very simple, customizable and it renders only text on the desktop (and percentagebars if you want it to ;) and the only lib it uses is Xlib.
Torsmo can show various information about your system and it's peripherals, including:
  1. Kernel version
  2. Uptime
  3. System time
  4. Network interface information
  5. Memory and swap usage
  6. Hostname
  7. Machine, i686 for example
  8. System name, Linux for example
  9. Temperatures from i2c-sensors
  10. Temperature from ACPI
  11. Battery capacity from ACPI/APM
  12. Number of processes running or sleeping
  13. Local mails (unread and all)
  14. Filesystem stats


 Enough, right?
Ok, Now what's conky?

Conky seems to fit in the same reign as of torsmo, but with more awesomeness, customizability and lots of inbuilt variables(almost 300) to access almost all features of system. Even bindings for POP, IMAP, music players like mpd, moc, audacious...
You can use Lua scripts to customize it and use cairo to draw whatever way you wish...

Enough said, I don't need another resource hog, well, you are wrong, conky is designed to be lightweight. 

search gnome-look.org for conky themes various configurations. 

OK, Now goes my custom conky configuration file. I customized it the last day.
You can mix and match it however you like it.
You can see the result here.


Looks nice, how can I try this,

All that's easy, if you are on linux.

See conky documentation on how to install it on your system.

After that install .conkyrc from here

And place, ".conkyrc" on your home directory.

More on readme file.
'