Linux, programming, computers and life

September 26, 2007

commenting code

Filed under: programming

I think i found out how to decide whether the code is well commented. I even know how to make it so. The recipe is simple - finish some task, do not touch and/or think about it for a week or two (you better do something else in the meanwhile - otherwise you’ll be probably fired ;) ). Now read the code (i assume you forgot it a little at least) and add comments anywhere you need to think “what’s going on here???”… Also remove comments which are absolutely redundant, but be careful here - you can still remember the code and it’s you who wrote it in the first place.

Technorati Tags: , , ,

September 25, 2007

I hate MSWord

Filed under: life

Why, why must i see “print preview” before printing even if i know the document is ok. I just wasted paper because i got empty tables and no text instead of the document. Damn!

Technorati Tags: , ,

September 12, 2007

delete first and last lines from a file using sed

Filed under: CLI, programming, awk

I tried do do it using awk, but i did not find an easy way to determine the last line in file. So sed did the trick:

cat myFile | sed '1 {d}; $ {d}' > myNewFile

Technorati Tags: , , ,

September 9, 2007

smplayer - great mplayer GUI

Filed under: GUI, linux

mplayer is very nice audio, video and generally all-you-name-it player. The one aspect i did not like about it was it’s UI, it’s pretty minimal and you have a lot of keyboard shortcuts to remember. I had to do “man mplayer” from time to time to remind myself of those.
smplayer is a great discovery. It’s great looking and very powerful GUI. I do not know whether all the aspects of mplayer can be controlled… but a LOT can. Currently, it’s (more than) enough for me. If you are looking for media player for linux - i’d suggest trying smplayer

Technorati Tags: , , ,

more awk examples

Filed under: CLI, programming, awk

As i already mentioned, awk is great. More examples in this post.
Print every n’th line (n=15):
seq 1 100 | awk 'NR%15==0 {print $0}'
Print only n’th line (n = 10):
seq 1 100 | awk 'NR==10 {print $0}'
Print average value:
seq 1 10 | awk '{sum+=$1} END {print sum/NR}'

Feel free to try this at ~ :)

Technorati Tags: , , ,

Get free blog up and running in minutes with Blogsome
Theme designed by Gary Rogers