After 2 successful editions of Meet GNU/Linux, which is conducted by
GLUG-T every year for beginners, the third edition of MGL is starting
on 27th July, at NITT.
A few updates about MGL'07 :
1. Guys are planning to release a beginner handbook, which would be
given out to them. The content is being edited in a wiki :
http://glugt-mgl.pbwiki.com/ Go ahead and edit when you are free.
2. This is GNU/Linux for dummies. So, if you have any of your
friend/relative interested in learning about it(in trichy), you can
ask them to contact suren who is co-ordinating
the event.
3. The co-ords are planning to release podcasts of the events, which
will be helpful.
Ideas, suggestion about how to organise the classes are welcome!
Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts
Tuesday, June 12, 2007
Wednesday, May 23, 2007
Coding Style ...
I have never thought much about coding style before i did my NOSIP in Novell. But once i started coding for ldtprecord, according to the coding style suggested to me by nags, i was surprised to see how nice and neat the final code looks.
Some tips/tricks for nice coding skills are,
1. Do spend some time to think about the variable names and the function names. This sometimes might be bit boring, especially when you want to concentrate much on the program logic and performance. But this is Rule 0 for coding conventions. A variable name "k" can imply anything like "kappa, kozhukattai, katthu, kaadhal, kerala, kozhuppu..." to someone who might have to read your code later. This is again mentioned here clearly. Many thanks to emacs, you can always use the auto complete, if your variable name is too long. :-) .
2. The actual coding convention depends much on the language and the standards your team is using already. The following style won't work for someone, whose team is already using a totally different style.
A few examples for C is posted here .
Sample Code 1 :
if (a == 5) {
b = 10;
}else {
b = 20;
}
Things to be noticed in the above snippet are.
1. A space between if and "(" .
2. Space in both the sides of the comparison operator.
3. Space between ")" and "{"
4. Space between both the sides of assignment operator (line 2 & 5) . This is true for almost all the operators.
5. Proper indentation of lines 2 & 5. If you are using emacs or vi, check here for your .emacs or .vimrc file .
Well, your code will compile and run even if you don't give these spaces, but a program coded with a bad coding style is equivalent to an inefficient code.
Sample Code 2
Let us have a function which takes two integers and returns their sum .
The code should be like
int add_numbers (int num1, int num2) {
return (num1 + num2);
}
The function call will be something like,
int sum;
sum = add_numbers (10, 20);
Things to be noticed in the above snippet is
In the first line in the function declaration,
1. The function name should be as clear as possible.
2. A space between the end of function name and "(" .
3. Spaces are given after every "," in the function argument list.
4. A space is given between ")" and "{".
In the second line in the function declaration,
1. A space before "(". [ This rule is almost global. Apply it everywhere whenever you use "(" ] .
2. There is a space on both the sides of the addition operator. This is again almost global. A space between both the sides of operator makes the code look real neat.
3. The indentation about which was mentioned earlier.But yes, if your girl friend is a geek or a nerd or a psycho or a fundoo, then you better go for this. ;-)
#define MAGIC "eilouvy43605321"
#define _(p,o,q) (t o#p[0])?(q)
#define __(p,o,q) _(p,o,t-q)
int main(){int t, i; for(i=8;i>0;i--)printf("%c", MAGIC[(((t=(MAGIC+7)[i-1])=='_')?62:_(.,==,63):_(@,==,64):__(a,>=,'a'+36):__(A,>=,'A'+10):(t-'0'))]);}
Note :: I wont say the coding style i use is the perfect one. It always depends upon what your team was using till now and how easy it is to read, debug and maintain the code.
Useful Links :
Thursday, May 03, 2007
Seg Fault
Wikipedia says,
A segmentation fault (often shortened to segfault) is a particular error condition that can occur during the operation of computer software. A segmentation fault occurs when a program attempts to access a memory location that it is not allowed to access, or attempts to access a memory location in a way that is not allowed (for example, attempting to write to a read-only location, or to overwrite part of the operating system)."
I have seen hundreds and hundreds of seg faults ;-) while coding for record module of LDTP and Spider SMS. But the one i saw yesterday was new, strange and fascinating. I am not sure whether i will be able to reproduce it again. The screenshot says why it is strange and fascinating :-) .

-bash-3.1$ man su
says
AUTHOR
Written by David MacKenzie.
REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>.
Maybe i should consider reporting this :P .
A segmentation fault (often shortened to segfault) is a particular error condition that can occur during the operation of computer software. A segmentation fault occurs when a program attempts to access a memory location that it is not allowed to access, or attempts to access a memory location in a way that is not allowed (for example, attempting to write to a read-only location, or to overwrite part of the operating system)."
I have seen hundreds and hundreds of seg faults ;-) while coding for record module of LDTP and Spider SMS. But the one i saw yesterday was new, strange and fascinating. I am not sure whether i will be able to reproduce it again. The screenshot says why it is strange and fascinating :-) .

-bash-3.1$ man su
says
AUTHOR
Written by David MacKenzie.
REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>.
Maybe i should consider reporting this :P .
Labels:
GNU/Linux,
linux,
programming,
segfault,
technical
Tuesday, January 30, 2007
Forgot mysql root pass ?
Recently forgot mysql root password for one of the servers i maintain . Little bit googling helped me to reset the password .
Just copy pasted the tutorials i saw so that i need not google again .
Just copy pasted the tutorials i saw so that i need not google again .
If you have set a root password, but forgot what it was, you can set a new password with the following procedure:
- Take down the
mysqldserver by sending akill(notkill -9) to themysqldserver. The pid is stored in a `.pid' file, which is normally in the MySQL database directory:shell> kill `cat /mysql-data-directory/hostname.pid`
You must be either the Unixrootuser or the same usermysqldruns as to do this. - Restart
mysqldwith the--skip-grant-tablesoption. - Set a new password with the
mysqladmin passwordcommand:shell> mysqladmin -u root password 'mynewpassword'
- Now you can either stop
mysqldand restart it normally, or just load the privilege tables with:shell> mysqladmin -h hostname flush-privileges
- After this, you should be able to connect using the new password.
mysql client: - Take down and restart
mysqldwith the--skip-grant-tablesoption as described above. - Connect to the
mysqldserver with:shell> mysql -u root mysql
- Issue the following commands in the
mysqlclient:mysql> UPDATE user SET Password=PASSWORD('mynewpassword')
-> WHERE User='root';
mysql> FLUSH PRIVILEGES; - After this, you should be able to connect using the new password.
- You can now stop
mysqldand restart it normally.
Subscribe to:
Posts (Atom)
