When I compile a very simple source file with gcc I don’t have to specify the path to standard include files such as stdio or stdlib. How does GCC know how to find these files? Does it have the /usr/include path hardwired inside, or it will get the paths from other OS components? Answer In order to figu…
Tag: linux
JAR Dependency Resolution from Within /usr/share/java
Can someone please explain how JAR files and the Java class loader make use of /usr/share/java? Is this a special directory that the JVM will perform automatic JAR loading and class lookups in, but no other? For example, if I have x.jar that depends on y.jar. If both jars are in/usr/share/java the dependency,…
using C code to get same info as ifconfig
Is there a way in Linux, using C code, to get the same information that “ifconfig eth0” would return? I’m interested in things like IP address, link status, and MAC address. Here’s sample output from ifconfig: Answer Yes, ifconfig itself is written in C. 🙂 See: http://cvsweb.netbsd.org…
Why are designated initializers not implemented in g++
Is there any specific reason why has support for designated initializers not been added to g++? Is the reason that C99 standards came late and g++ was developed earlier and later people didn’t care about this issue, or there is some inherent difficulty in implementing designated initializers in the gram…
How do I get out of ‘screen’ without typing ‘exit’?
I screen -r’d into a Django server that’s running and I can’t simply Ctrl + C and exit out of it. Are there any alternative ways to get out of screen? Currently, I manually close the tab on my local PC and ssh back in, but that’s becoming tiresome. Answer Ctrl-a d or Ctrl-a Ctrl-d. See…
scraping website for info when the URL has product id’s instead of true values
Im guessing its php cURL, but Whats the best way to make a loop to scrape the DOM for info from a webpage that uses id’s in the URL Query like (?ProductId=103) There is about 1200 pages. I need to find the innerHTML of the 9th span on each page. This info will just get stored in a mySQL table
Bash script to delete all but N files when sorted alphabetically
It’s hard to explain in the title. I have a bash script that runs daily to backup one folder into a zip file. The zip files are named worldYYYYMMDD.zip with YYYYMMDD being the date of backup. What I want to do is delete all but the 5 most recent backups. Sorting the files alphabetically will list the ol…
What is the difference between “source script.sh” and “./script.sh”?
What is the difference between source <script> and ./<script>? Answer source script.sh runs the script within the current process, thus all variable assignments are preserved as variables even after the script finishes (and don’t have to be explicitly export’d). ./script.sh just runs t…
Simplest way to script slowly sending data through a socket connection
I need to periodically connect to a server from a Linux client and send some commands, so I wrote this script: The problem is that I need to wait between commands. This script sends the commands and disconnects too quickly, which the server detects, and drops the commands. It works if I open the connection fr…
How do you set your pythonpath in an already-created virtualenv?
What file do I edit, and how? I created a virtual environment. Answer The most elegant solution to this problem is here. Original answer remains, but this is a messy solution: If you want to change the PYTHONPATH used in a virtualenv, you can add the following line to your virtualenv’s bin/activate file…