Skip to main content

Posts

Tic Tac Toe in python - Just for fun

The other day, I was looking for some GNU/Linux administration reference, I ended up viewing a "tic tac toe" program in Ruby at a Linux admin's blog. He wrote that in ruby and took him 90mins. That was written using class. But "Zen of Python in mind", I wrote my own version without class. I prefer this way (sparse is better than dense), and I enjoy Python more when, I think of my Java days.  I haven't read ruby code before hand so, I did not wrote a clone of ruby code. And this took me around 40min. Because, I realized some missing features only when I played it several times. Then only I added those. Specifically, drawing complete board after someone wins and stopping the game when all fields are filled out. I'll not say, the program is beautiful and very readable. However, it's good enough for playing with it.

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...

My Desktop setup

  Here goes my desktop. Operating System : GNU/Linux Flavour : Ubuntu (Debian Derivative) Version : 10.10 (kept up to date) Kernel : 2.6.35-28-generic-pae 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 Theme :  Fenza Dark.  (see link for ppa) Dock : Avant (trunk)  Menu : Cardapio Menu (using ppa)  it even have awn applet.  Conky : for configuration look here Dock theme : Divergence-IV A New Hope 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,breadcru...

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: Kernel version Uptime System time Network interface information Memory and swap usage Hostname Machine, i686 for example System name, Linux for exampl...

AJAX File Upload with Web2py

It was not that long, since I experienced a problem while trying to upload a file using an ajax  trapped form. I thought, it must be me doing something wrong. I was using web2py  to embed another page into a page via ajax. That is better known to web2py folk as LOADing a component. It's just happened that one of such component contains a file upload form. It was my first time using LOAD function provided by web2py. Basically it make use of jQuery to load the page via ajax into a target div and traps input of any form in that page, so that page doesn't reload. Oh, I forgot to say that web2py is bundled with jQuery. It's always boring and tedious to understand a problem without experiencing it. So, Let's play with an example, (PS: I"m using web2py a full stack python framework, but you can use any language at server side and this problem will be there because, it's a problem with ajax) My mod...

Rich Internet Application & GWT : Angel of Java Programmers

We all are hearing the buzz about Rich Internet Applications (RIA) about a year or so. But, what the heck is that beast ? You may ask. For the user's perspective, it's the desktop like experience delivered over web. Yes, you feel like you are using a real desktop application (well, at least sort of). The richness of desktop controls is transferred to web. How RIA is build? Arise another question. These all started with that amazing kid called AJAX (Asynchronous JavaScript And XML). Then more and more tools become available, like Java FX , Adobe Air , Adobe Flex (and Adobe Flash ), Microsoft Silverlight . But these tools, though it gives rapid and organized web application development, required some kind of plug-ins to be installed on your browser. There is the importance of AJAX based RIAs, because JavaScript is enabled in almost all browsers in use today. However, It's not a fool proof solution, because there are people who switch off JavaScript for some reason, lik...

XML: Is it worth

  [ Source is from http://harmful.cat-v.org/software/xml/ ] Yes, I confess, I don't like XML at all. Reason, It's way too complication and I personally feels like it's a waste of storage space. Please, don't tell me that storage(be it memory or disk) is so cheap now a days. I still care. May be because, I started my programming (Computer Science) education with mighty "C". I always prefer to squeeze memory and make my programs as small as possible, (reason, why I changed from C++ to Java, then to Python: not to mention rapid development.) . Why use XML at all. There are good old RDBMS. Well if you find buzz about ODBMS, use them. Or use simple JSON . Or better, go for Google's ProtocolBuffers. Web programming in Java, now days become full of xml configuration files.And it'll go on, getting multiplied as your system gets bigger, web services included and so on. So much work, if some one ask me about it! Thanks to web2py , I can make the same applicat...