IdeaMonk

thoughts, ideas, code and other things...

Saturday, May 15, 2010

Yay! Freebies arrive :D



Just got back home from WebApps 2010 to find these two awesome books from Linux Format magazine kept on my chair. Thanks to Graham Morrison for the initiative. Love the color print in the one from Yahoo Press.
Met a good designer from Shrishti college Chennai, had great time discussing the borderline between a developer's and a designer's perspective. Interesting day by chance, otherwise apart from a few talks from rediff.com VP, and Mr. Satyadeep Vusuthy of Yahoo India R&D and @hsivaram of Adobe, the others were a little boring. Had to be like that, for the geekiness quotient was low in the masses.

Linux++

Labels: , ,

Sunday, December 20, 2009

Easiest way to reset mysql server password.

I was almost going to give up on resetting mysql password, even the ones mentioned on mysql page did not work due to security policies and mysqld_safe would just not start working :/ bleh! Until I found the other way round :) thanks to some Debian goodness -
sudo dpkg-reconfigure mysql-server-5.0


That's all :)

Labels: , ,

Saturday, September 05, 2009

ILUG-B meetup #2

Well, it was a pleasant Saturday with 50-cent playing on the auto in which I sped towards TW office - for ilug-b meet. This one was a total gyan session and even though there was even more OHP than last time, I'm glad that I pulled up till the end. After all I can definitely say BeleniX and ZFS are the next two things on my tryout list. Ram's presentation was awesome and in the end we got to see some seriously cool stuff people made through Virtualization and Crossbow on Solaris. Hats off to the $350 magic box guys!
And, oh the discussion over GPG finally ended I suppose! Finally when things were light under beer, I could observe some less OHP... 4chan, LOLcat, Mitnick, first-time-on-linux and what not. I guess I've had my usual amount of beer that invites me for a nice sleep. Even mom has guessed it as she puts it "ette der katte lagalao? daru peeke elhi yay ki...?" damn! How do I respond to that :P

Afterthoughts -
  • Linux is more about loving the OS, than just being an enthusiastic user...
  • Determination is even more important as pg puts it.

Labels: , , ,

Sunday, August 16, 2009

Gwibbiquity a theme for Gwibber

I've been using Gwibber for accessing twitter and syncing my facebook status with twitter. Earlier I was disappointed with Adobe AIR based clients for AIR itself didn't run well on amd64 :/ . Gwibber's default theme looks quite disappointing and the best you can get is Brave by Ginkyo. Gwibber 2.0's prototype looks awesome, but before we get there, I would like to add up one more theme to the project - Gwibbiquity - another theme based on Brave and inspired by the gradients of Lounge.
It didn't take more than an hour to come up with it. Thanks to Gerry Ilagan's tutorial on how to create one :) Here's how it looks -


To install the new gwibber theme:

1. Download the new theme from github
2. Decompress it to ~/.local/share/gwibber/ui/themes/
You should end up with a folder called gwibbiquity with a few files inside it.
Make that path if it not present
3. In Gwibber, open Preferences (Gwibber->Preferences or Ctrl+P).
Pull down the theme chooser and choose ‘gwibbiquity’.
4. On my system, it took Gwibber a few seconds to apply the new theme.
Be patient, and things should shape up.

* thanks to Jake Tolbert for easy installation instructions

Labels: , , , ,

Saturday, August 15, 2009

GDB, Why didn't I use you all this time.... ?!

My first introduction to gdb was through "Hacking - The art of exploitation", a book on writing exploits and many other basics of network/application security by Jon Erickson. During those days, I neither ran linux on my machine, nor did I care to go deep into tools explained in the book. Installing Gentoo, which was used to write examples of the book was a painful experience. And I did not know of the wonderful offsprings of mother Debian like Ubuntu!
Anyways coming to the point, I seriously wonder why don't they teach gdb at our colleges. I just realised that just two weeks back we had network simulation lab, one boy said "Ma'am I got segmentaton fault! I'll do it next time..." and the teacher too, aware of the mysteries of segmentation fault, let him go. Forget mysteries, everyone in my college knows debugging as a painful task that involves putting printfs everywhere in your code. And, that's not all, it alone doesn't assure where the hell things went wrong, then you start printing the values too, its more of a guesswork! Now think about this - they wrote the linux kernel in C right ? did they debug their way to every new releases by putting a printf before every damn line ?! And before the release, did they spend sleepless nights just removing those printf patches left out here n there! Nopes, not at all.
Anyways lol, coming back to the point, let me show you some nice things about gdb, the GNU Debugger that I just found out right now reading 'Developing with Gnome'
Consider this code -
#include <stdio.h>

int total;

foo(){
// calls bar() 5 times
int i=5;
while (i--)
bar();
}

bar(){
// calls baz() 2 times
int i=2;
while (i--)
baz();
}

baz(){
total++;
}

int main (){
// just calls up other funcs that do something on total
total = 0;

foo();
bar();

printf ("%d\n",total);

return 0;
}
As you can see, it increments a global integer total 5X2 times using foo() and then 2 times more by a call to bar() in main(), final output being 12. Simple enough! I've just nested the functions to stress on the fact that bigger programs can be tough to debug.

ideamonk@sacea:~$ gcc segfault.c
ideamonk@sacea:~$ ./a.out
12
ideamonk@sacea:~$

Now I'll add some weird lines to the code and try to get a segmentation fault.
Let's modify foo() as this -
foo(){
// calles bar() 5 times
int i=5;

char c1='a',*c=&c1;
while (i--){
printf ("%c ", *c);
c+=0xdeadbeef;
*c++;
bar();
}
}

What it tried to do is, have a pointer to a character, shift that pointer in insanely far that it exceeds permissible addressing, and poof! get us a segmentation fault. Here it is -

ideamonk@sacea:~$ gcc segfault.c
ideamonk@sacea:~$ ./a.out
Segmentation fault
ideamonk@sacea:~$

That's it, all I get is a segmentation fault. Now someone right from my computer programming course would go about debugging this by putting printfs before every possible suspect lines :P. But with gdb, you can actually pinpoint the line where it broke, see the source and even find out which functions were called in what order, and even more, we also get to have a look at values of local variables. What more could've anyone wanted. Let me show you how gdb makes debugging easy as a pie -

// we'll ask gcc to turn debugging flags on and optimization flags off by a -g
ideamonk@sacea:~$ gcc -g segfault.c
ideamonk@sacea:~$ gdb a.out
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...
// lets run our code
(gdb) run
Starting program: /home/ideamonk/a.out

Program received signal SIGSEGV, Segmentation fault.
0x000000000040052d in foo () at segfault.c:12
12 printf ("%c ", *c);
// Look at that! there we have it, which line, what was there, we know all :)
// lets seek more
// list would give us codeblock where it occured
(gdb) list
7 int i=5;
8
9 char c1='a',*c=&c1;
10
11 while (i--){
12 printf ("%c ", *c);
13 c+=0xdeadbeef;
14 *c++;
15 bar();
16 }
// we'll take a look at local vars now
(gdb) info locals
i = 3
c1 = 97 'a'
c = 0x8000599580ff

// there you have it :) the pointer c went out of bounds as intended
// as I said we can look at the order of function calls, here it is
(gdb) backtrace
#0 0x000000000040052d in foo () at segfault.c:12
#1 0x00000000004005c4 in main () at segfault.c:34
(gdb) ^D


Now you exactly know what went wrong and where, get back to your editors and you know exactly which line number is the bug you need to squash.
Happy debugging and a Happy Independence day to one and all :)
on #linux-india one guy asked me this when I greeted with the usual "Happy Independence Day!" thingie -
"What are you happy about?", "Why so happy?"
It set me thinking, what for? I could come up with one answer, "I'm happy for the possibility of getting a free jalebi tomorrow.", for I realised that there isn't any answer to "Are we free?", I guess we're not, unless we abandon the common road on which everyone walks and take the road not taken. I would like to take it :)

Labels: , ,

Thursday, September 06, 2007

My first linux ASM code

SECTION .data
msg db "hello world",10
len dw 12

SECTION .text
global start
start:
mov eax,4 ; the 'write' syscall
mov ebx,1 ; on stdout
mov ecx,msg ; the string
mov edx,len ; its length
int 0x80 ; interrupt
mov eax,1 ; exit syscall
mov ebx,0
int 0x80 ;


Wooh!!! soon i will be reversing apps. nhahahaaa

Labels: ,