Java classpath usage

We will create following classes: firstClass \___ abc.java secondClass \___ xyz.java Create a class with package name as p1.p2.p3 at firstClass directory and compile it using following command: javac abc.java -d . lets add another class that uses abc class at secondClass directory and following command is used to compile it: javac -classpath ../firstClass/ xyz.java…

callgraph generator

sudo apt-get install -y kcachegrind valgrind gcc main.c valgrind –tool=callgrind ./a.out # Generates a callgrind.out.<PID> file. kcachegrind callgrind.out.1234 # Opens a GUI to visualize callgrind data…

auto_ptr and reference counting

http://www.codeproject.com/Articles/15351/Implementing-a-simple-smart-pointer-in-c   A smart pointer is a class that wraps a ‘raw’ (or ‘bare’) C++ pointer, to manage the lifetime of the object being pointed to. There is no single smart pointer type, but all of them try to abstract a raw pointer in a practical way. Smart pointers should be preferred over raw pointers…

How to inter process communication

https://en.wikipedia.org/wiki/Inter-process_communication File A record stored on disk, or a record synthesized on demand by a file server, which can be accessed by multiple processes. Most operating systems Signal A system message sent from one process to another, not usually used to transfer data but instead used to remotely command the partnered process. Most operating systems…

Start a Simple HTTP Server in Any Folder

If you’re needing to quickly test some HTML that you’re working on, start a simple web server within any folder on your Mac. Navigate to the folder to use and enter: 1 $ python -m SimpleHTTPServer 8000 The number at the end is the port to use, open your browser and visit http://localhost:8000 You can use the default of…

Macs instantly maximize windows

To speed up execute following command: defaults write -g NSWindowResizeTime -float 0.003 Quit and relaunch all apps for the change to take effect, including Finder To undo: defaults delete -g NSWindowResizeTime Some others: # opening and closing windows and popovers defaults write -g NSAutomaticWindowAnimationsEnabled -bool false # smooth scrolling defaults write -g NSScrollAnimationEnabled -bool false…

Recursive Makefile Example

I wanted to come up with generic way using only make (no autoconf/automake/etc) to solve the following problem: Given a source directory with several subdirectories, have it so that running make in the top directory runs the make in all the subdirectories, potentially with dependencies so that things are built in the correct order. This…