Debarshi's den - দেবর্ষির ডেড়া

Debarshi's posts with tag: hacks

What are tags? You can give your posts a "tag", which is like a keyword. Tags help you find content which has something in common. You can assign as many tags as you wish to each post.
View posts by people in your network with tag hacks
Blog EntryComments?Sep 18, '07 6:57 AM
for everyone

Here is my attempt at writing a program to detect whether a compiler supports nested comments or not. The basic requirement is to have it cleanly compile irrespective how the compiler handles comments.

Till now I have tried it on GCC 4.1.1's C and C++ compilers and SUN's proprietary CC compiler, which do not support seem to nested comments. If any one can try it out on a compiler that supports nested comments, please let me know if it worked as expected or not.


LinkGoogle Summer of Code 2007: A summaryMay 26, '07 10:29 AM
for everyone
Link: http://etherboot.org/gsoc/gsoc2007summary.html

A summary of all the participants and their proposals in Google Summer of Code 2007. This was obtained by parsing the contents of http://code.google.com/soc using http://etherboot.org/gsoc/mksum.cpp by Marty Connor.

Blog EntryThanks.May 24, '07 10:10 PM
for everyone
Last night sometime around 00:00 IST, thanks to Seth Vidal I learnt how to use the YUM API to download a list of packages from the repositories.

Blog EntryAC_PYTHON_MODULEApr 8, '07 5:47 AM
for everyone
On January 2, 2007 I had sent a patch to the AC_PYTHON_MODULE M4 macro, used by Autoconf. I had mailed the patch to the author-- Andrew Collier at the email address mentioned on the web-site. I never got a reply.

Yesterday night, I was suprised to see that the upstream code has been patched by the modifications that I had sent. So why did the fellow never reply?

Here is my copy of the same code.

Blog EntryRead-a-lineMar 3, '07 1:17 AM
for everyone

Today at around 02:15 hours I learnt to use GNU Readline in C programs. No particular reason for me to do so, except that the recent changes in build infrastructure of GNU Parted initiated by Jim Meyering had suddenly caused the 'configure' script from detecting my system's Readline libraries. After my sleep-deprived eyes had failed to detect any particular bug in configure.ac, I landed up at the GNU Readline manual.

I must say I have not yet solved the Parted problem, but managed to scrible an elementary program with ample help from the manual. Find it here.

Dependencies:a. readlineb. readline-develc. termcapd. libtermcape. libtermcap-devel

Compilation instructions:$ gcc readline1.c -lreadline -ltermcap


Blog EntryHurd in (sig)action!Feb 26, '07 5:54 PM
for everyone
I just found out that the GNU Hurd does not provide the 'SA_SIGINFO' constant, although it supplies the 'sigaction' function. There is nothing in the manual of sigaction ($ man sigaction) to indicate this. In fact the manual explains the usage of 'sigaction' with 'SA_SIGINFO'.

Apparently 'SA_SIGINFO' is a POSIX XSI extension and one should check its availability at compile time.

Thanks to the #hurd folks, especially Richard Braun (nick: syn) and Guillem Jover (nick: braindmg) for their help.

Blog EntryAutoconf hacks: part 1Jan 8, '07 5:20 PM
for everyone
Here is my modified version of the AC_PYTHON_MODULE GNU Autoconf M4 macro published at http://autoconf-archive.cryp.to/ac_python_module.html.

The original version of the macro was unable to take care of multiple versions of Python installed on a system. For example I have Python 2.3.5 and Python 2.4.3 on my system, and if I need to check whether a certain module 'foo' is installed for Python 2.4.3 the macro would not work correctly. This was because of the fact that the macro was ignoring the environment variable PYTHON and directly invoking 'python'. Hence clear demarcation between the two versions was not possible.

Blog EntryDeprecating a C function.Dec 22, '06 5:35 PM
for everyone
Here is a nice way to mark a particular C function as deprecated. It might come in handy if you are in the process of developing an API or library and intend to phase out a particular component of it. The Linux kernel developers also use this method.

Here is what you get on compiling and running it:
[rishi@Sunflower devel]$ gcc -ansi -pedantic foo.c -o foo
foo.c: In function ‘main’:
foo.c:8: warning: ‘foo’ is deprecated (declared at foo.c:5)
[rishi@Sunflower devel]$ ./foo
I am foo.
[rishi@Sunflower devel]$


Blog EntryPython hacks: part 2Sep 10, '06 1:04 AM
for everyone
An improved version of the PYTHONSTARTUP file I posted in the previous 'Python hacks' article. As usual it needs the Readline module to work.

New features include saving of the previous session history (in ~/.python_history), and using Esc to do the tab-completion so that the Tab key can still be used for indentation.

try:
import readline
except ImportError:
print "Module readline not available."

else:
import atexit
import os
import rlcompleter

historyPath = os.path.expanduser("~/.python_history")

def save_history(historyPath=historyPath):
import readline
readline.write_history_file(historyPath)

if os.path.exists(historyPath):
readline.read_history_file(historyPath)

atexit.register(save_history)
del os, atexit, readline, rlcompleter, save_history, historyPath

NB: Much of the above material was taken from the Python Tutorial written by Guido van Rossum (http://docs.python.org/tut/tut.html).

Blog EntryPython hacks: part 1Aug 14, '06 12:40 PM
for everyone
To turn on tab-completion in Python, one needs to put the following in the PYTHONSTARTUP file. The Readline module needs to be installed for this feature to work.

try:
import readline
except ImportError:
print "Module readline not available."
else:
import rlcompleter
readline.parse_and_bind("tab: complete")


Blog EntryCVS tweaks: part 1Aug 13, '06 1:56 PM
for everyone
Set the value of $CVSEDITOR or $EDITOR to denote which text-editor to use to write the log while committing.

[rishi@Sunflower ~]$ export CVSEDITOR="emacs -nw"

Adding the above line (the part after the $) to ~/.bash_profile or /etc/profile would also be enough, depending whether you want to make system-wide changes or user-wise changes.

Blog EntryAcceleration anxieties...Apr 20, '06 11:33 AM
for everyone
I compiled Wine 0.9.10 from source a month back and put it into my Fedora Core 5 system, and in no time Counter Strike 1.6, Counter Strike Condition Zero and Max Payne were running. The only problem I had was with the frame-rate, and I still have it. It is funny since Arjun is having an amazing frame-rate on his Ubuntu system and although his 855GME motherboard allows him 333MHz RAM, while I am limited to 266MHz on my 855GM the difference in frame rates is a bit too much in my opinion. Moreover the problem is not limited to Wine only. I notice the difference when laying TORCS and Qauke III: Arena (native port) too.

I am continuing my search for a solution to this problem and have already recompiled my kernel half a dozen times as a result of it. At the cost of sounding stupid, but I must say I have been recompiling my kernel atleast once a day to try out the various configurations of the Intel graphics drivers given in the 2.6.16 vanilla kernel.

In the meantime if anyone has any tit bits of information to help, it would be highly appreciated.

© 2008 Multiply, Inc.    About · Blog · Terms · Privacy · Corp Info · Contact Us · Help