I’m using GPtrArray structure to hold pointers to chunks of dynamically allocated memory. As I need as simple as possible and correct freeing of memory I set callback g_ptr_array_new_with_free_func () which will free one element of pointer array. Thus when I call g_ptr_array_free() for all elements of a…
How to make my Python module available system wide on Linux?
I made myself a little module which I happen to use quite a lot. Whenever I need it I simply copy it to the folder in which I want to use it. Since I am lazy I wanted to install it so that I can call it from anywhere, even the interactive prompt. So I read a bit about installing
Linux C – implementing the ability that a program can update itself
I am writing a program in C on Linux environment (Debian-Lenny) and would like the program to be updated when an update is available (the program gets notified when a new update is available). I am looking for a way that the program can update itself. What I am thinking is that the main program invokes a new …
Simple socket forwarding in linux
The scenario is pretty simple: Using TCP/IP I have a client which connects to me (server) I want to forward the data the socket sends me to another socket which I opened and the data I received from that socket backwards.Just like a proxy. Right now I have 1 thread one who listens from incoming connection and…
Adding content to middle of file..without reading it till the end
I have read various questions/answers here on unix.stackexchange on how to add or remove lines to/from a file without needing to create a temporary file. https://unix.stackexchange.com/questions/11067/is-there-a-way-to-modify-a-file-in-place?lq=1 It appears all these answers need one to atleast read till end …
How can I programmatically open the default browser and pass a URL in C/Linux?
Is there a convenient library call that allows me to open the default browser that I can use from C? I poked around in glib and didn’t see anything. There is xdg-open, and I can just system that I guess. Any better ideas? Answer If it is installed then xdg-open would work.
Best way to install MySQL 5.6 on Centos 6.4
I just installed Centos 6.4, and installed MySQL using the version that came with the Centos distribution. To my dismay, it is MySQL 5.1.69 versus the current 5.6.12. As stated on http://dev.mysql.com/doc/refman/5.5/en/linux-installation-native.html, “the MySQL version will often be some way behind the …
Take nth column in a text file
I have a text file: I want to take the 2nd and 4th word of every line like this: I’m using this code: It works, but it is very complicated and takes a long time to process long text files. Is there a simpler way to do this? Answer iirc : or, as mentioned in the comments :
Create a hard link from a file handle on Unix?
If I’ve got a handle to an open file, is it possible to create a hard link to that file after all references to it have been removed from the filesystem? For example, something like this: Specifically, I’d like to do this so that I can safely write to large data files, then move them into place at…
One to one mapping of Java Thread to Linux thread (LWP)
Is there a one to one mapping between Java Thread objects and OS threads (Lightweight processes). That is, if I have a Thread object, can I always identify precisely one associated OS thread, and will I always have the same associated OS thread? In general this is OS and JVM dependent, so I’ll restrict …