February 2009 Archives
I found this tutorial to be very helpful for improving my understanding of how to work with static and shared libraries in C (within a *nix context):
http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html.
http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html.
The source code for MinMenu 0.8.0 is available at http://indicium.us/cgi-bin/pages/get?view=minmenu.
Noteworthy improvements since version 0.7.0:
Noteworthy improvements since version 0.7.0:
- Implemented UP/DOWN arrow-key navigation.
- User may now specify alternative config file through a command-line switch.
- User may switch the color theme temporarily during run-time.
- Banner text is center-aligned.
- Implemented a "beat" animation.
http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html
There is a very easy to understand example here of a simple multi thread program, and a lot of other helpful info for programming with the pthread lib.
There is a very easy to understand example here of a simple multi thread program, and a lot of other helpful info for programming with the pthread lib.
This is a UserFriendly comic from 1998. Enjoy!
http://www.userfriendly.org/cartoons/archives/98nov/uf000017.gif
http://www.userfriendly.org/cartoons/archives/98nov/uf000017.gif
http://www.computerjokes.net/186.asp
I think I'm going to inscribe this deep truth on one of my apartment walls:
"No one but their creator understands their internal logic."
I think I'm going to inscribe this deep truth on one of my apartment walls:
"No one but their creator understands their internal logic."
I have started a new personal blog. It is called "theologia", and is available at http://theologia.indicium.us. The subject matter of the new blog is Christian theology.
The new blog will not replace this one, which will continue to focus on programming, Linux, and other technical subjects.
The new blog will not replace this one, which will continue to focus on programming, Linux, and other technical subjects.
Can any one verify what this blog is reporting?
http://blog.linuxtoday.com/blog/2008/12/just-say-yes-to.html
A real military wouldn't actually run a nuclear submarine on... Microsoft Windows!?
Nah.
http://blog.linuxtoday.com/blog/2008/12/just-say-yes-to.html
A real military wouldn't actually run a nuclear submarine on... Microsoft Windows!?
Nah.
GDB is the GNU Project Debugger. Here is a very basic tutorial to using it with gcc.
First, compile your code with gcc. Use the -ggdb flag, which means the the compiler will put in as much debugging info as possible for use with GDB:
If you have used "start" you may use the command "n" (for next) or "s" (for step). Each line that you step through will be displayed by GDB, along with errors/signals. The difference between "n" and "s" is "n" steps over function calls, while "s" descends into them. That means that if a call is made to function "my_func()", using "n" will make the function call and then move to the line after the function call, while "s" will begin stepping through every line inside of the function "my_func()."
At any time, you may use the command "p" followed by the name of a variable:
You may also set a breakpoint with the command "b" followed by the name of a function:
Two helpful tricks: Using some commands, followed by a number, will cause the command to be repeated that number of times:
Also, if you press enter without entering a command, the last command given will be repeated. (Very convenient when stepping through a lot of lines of code.)
GDB REFERENCE CARD
Here is a must-have link if you are going to use GDB: http://users.ece.utexas.edu/~adnan/gdb-refcard.pdf.
USING GDB WITH EMACS
Using GDB can be more fun in Emacs, as you can see the code you are running in its context. I will not describe that here, but I will provide a link to an Emacs-GDB tutorial: http://tedlab.mit.edu/~dr/gdbintro.html.
First, compile your code with gcc. Use the -ggdb flag, which means the the compiler will put in as much debugging info as possible for use with GDB:
gcc -ggdb -o example example.cStart gdb and pass the name of the binary to it:
gdb exampleOnce gdb has started, you may use the command "run", and gdb will run the binary, stopping if there is an error. Alternatively, you may use the command "start" to "step through" each line of code in the program.
If you have used "start" you may use the command "n" (for next) or "s" (for step). Each line that you step through will be displayed by GDB, along with errors/signals. The difference between "n" and "s" is "n" steps over function calls, while "s" descends into them. That means that if a call is made to function "my_func()", using "n" will make the function call and then move to the line after the function call, while "s" will begin stepping through every line inside of the function "my_func()."
At any time, you may use the command "p" followed by the name of a variable:
p my_varAnd then GDB will tell you the value of that variable. GDB allows auto-completion, so you may type the first few letters, press tab, and it will finish the rest of the variable name. If you don't put in the variable name, and press tab, it will show all variables that you have access to.
You may also set a breakpoint with the command "b" followed by the name of a function:
b my_func()If you then using the command "c" (for continue), GDB will resume execution of your program, stopping as soon as it gets to a line where that function is called.
Two helpful tricks: Using some commands, followed by a number, will cause the command to be repeated that number of times:
n 10This will cause "next" to be executed ten times.
Also, if you press enter without entering a command, the last command given will be repeated. (Very convenient when stepping through a lot of lines of code.)
GDB REFERENCE CARD
Here is a must-have link if you are going to use GDB: http://users.ece.utexas.edu/~adnan/gdb-refcard.pdf.
USING GDB WITH EMACS
Using GDB can be more fun in Emacs, as you can see the code you are running in its context. I will not describe that here, but I will provide a link to an Emacs-GDB tutorial: http://tedlab.mit.edu/~dr/gdbintro.html.
The source code for MinMenu 0.7.0 is available at http://indicium.us/cgi-bin/pages/get?view=minmenu.
Some notable changes since 0.6.0:
Some notable changes since 0.6.0:
- Implemented more dynamic memory allocation
- Cursor doesn't blink annoyingly now
- Displays the application version and the user's host name in the menu frame
- Completed a massive restructuring of the code, in order to help with future improvements
- User can now have a multiple-line banner
I just discovered this tiny program called GDB that really made my week. Imagine me beating my head against a wall because there is a segfault in my C program, and I know it occurs when I call a certain libc function, but that libc function is called about 30 times in various places in the program. BLAH!
So I find out that there is a program called GDB (The GNU Project Debugger). And if you compile your C program with a debugging flag, you can run the C program inside GDB, and it will tell you exactly where the program received the seg fault signal.
And further more, I can use GDB to step through my program line-by-line. And further more, at any point in the program I can request to see the value of any variable in that context.
That's cool. I think in my next post I'll write a brief intro to GDB.
So I find out that there is a program called GDB (The GNU Project Debugger). And if you compile your C program with a debugging flag, you can run the C program inside GDB, and it will tell you exactly where the program received the seg fault signal.
And further more, I can use GDB to step through my program line-by-line. And further more, at any point in the program I can request to see the value of any variable in that context.
That's cool. I think in my next post I'll write a brief intro to GDB.
Who says you can't have a cool looking desktop with a minimalistic windows manager? Here's my Fluxbox desktop:
screen_shot_20090203b.png
I modified a Fluxbox style I found on the web (forgot where I got it) to get the green and white text theme.
The terminal on the background layer is xterm, running "top".
screen_shot_20090203b.png
I modified a Fluxbox style I found on the web (forgot where I got it) to get the green and white text theme.
The terminal on the background layer is xterm, running "top".
I strive for three specific ideals for my e-mail in-box: 1) All the e-mail headers in my in-box should fit on one 24x80 terminal screen, 2) All the e-mail in my in-box should be deserving of my attention, 3) I should have to do very little repetitive, time-consuming work to maintain my in-box. Alpine e-mail filters helped me achieve almost completely all three of these ideals (in conjunction with e-mail sub-folders).
I'm not going to go into much detail on setting up filters (it is pretty easy in Alpine). I just want to show two cool applications. But to get to filters from the main screen, enter S -> R -> F. The press A to add a new filter.
Super Cool Filter #1: Archive Old Mail
Say you want all mail that is over two weeks old to go to a folder called "archive". Set the Filter Action Value to "Move" and the folder "Archive." Then, under "FILTERED MESSAGE CONDITIONS" set the "Age interval" value to "14, INF". "14" means "14 days", so set it to, say, "31, INF" if you wanted the mail to be archived after 31 days.
For added coolness, set the "Message is Important?" value to "No" and "Message is New (Unseen)?" value to "No." This means that the message will not be filtered to the "archive" folder if it is marked "important", or if you have not yet had a chance to read it.
If you have any other e-mail filters that involve message age, I suggest you make this age to be a bigger number than all those other filter's ages. This will ensure that more specific filters get "first dibs" on filtering the e-mail before it gets sent to a generic archive.
Super Cool Filter #2: Filter E-mail After it is Read
Say you get automated e-mails from your on-line banking, or thread updates from your Linux forum. These are the sort of things that you want a chance to read, but then you want them go away forever as soon as you've read them.
Under "ACTIONS BEGIN HERE", set the "Filter Action" value to "Delete". Under "FILTERED MESSAGE CONDITIONS" enter patterns that uniquely identify these e-mails (some text in the subject line, for example). Then, set the "Message is New (Unseen)" value to "No".
What if you want those e-mails to be deleted after you've read them, but don't want them to go away /immediately/? Simply set the "Age interval" value to "2, INF". This means they will not be deleted until after they are at least two days old.
I'm not going to go into much detail on setting up filters (it is pretty easy in Alpine). I just want to show two cool applications. But to get to filters from the main screen, enter S -> R -> F. The press A to add a new filter.
Super Cool Filter #1: Archive Old Mail
Say you want all mail that is over two weeks old to go to a folder called "archive". Set the Filter Action Value to "Move" and the folder "Archive." Then, under "FILTERED MESSAGE CONDITIONS" set the "Age interval" value to "14, INF". "14" means "14 days", so set it to, say, "31, INF" if you wanted the mail to be archived after 31 days.
For added coolness, set the "Message is Important?" value to "No" and "Message is New (Unseen)?" value to "No." This means that the message will not be filtered to the "archive" folder if it is marked "important", or if you have not yet had a chance to read it.
If you have any other e-mail filters that involve message age, I suggest you make this age to be a bigger number than all those other filter's ages. This will ensure that more specific filters get "first dibs" on filtering the e-mail before it gets sent to a generic archive.
Super Cool Filter #2: Filter E-mail After it is Read
Say you get automated e-mails from your on-line banking, or thread updates from your Linux forum. These are the sort of things that you want a chance to read, but then you want them go away forever as soon as you've read them.
Under "ACTIONS BEGIN HERE", set the "Filter Action" value to "Delete". Under "FILTERED MESSAGE CONDITIONS" enter patterns that uniquely identify these e-mails (some text in the subject line, for example). Then, set the "Message is New (Unseen)" value to "No".
What if you want those e-mails to be deleted after you've read them, but don't want them to go away /immediately/? Simply set the "Age interval" value to "2, INF". This means they will not be deleted until after they are at least two days old.

The content of this blog is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License. See my copyleft page for more details.
