Tuesday, March 19, 2013

A Note on String, StringBuffer, StringBuilder

When String (an immutable [not modifiable] type) construction or modification involving dynamic values (whose values are not known at compile time) is required by a single thread, the mutable StringBuilder will perform faster than StringBuffer.  The reason for the performance hit is likely that StringBuffer is thread-safe through synchronization.  StringBuilder is also mutable but not thread-safe, hence the faster predicted performance.

Saturday, March 9, 2013

My OS X Mountain Lion How-Tos, Shortcuts, & Notes

This collection of apps, how-tos, and notes is for my own record.  Hopefully someone will find them useful too.

Skipping .DS_store files while copying directories between two USB mounted volumes
rsync -rv --exclude=.DS_Store <source> <destination>
Source: Skipping .DS_Store files when copying between two external drives 

Showing and Hiding Hidden Files
defaults write com.apple.finder AppleShowAllFiles -boolean true
killall Finder

The reverse is
defaults delete com.apple.finder AppleShowAllFiles

killall Finder


Open Minimized Windows Using Command Tab
This is rather long.
1. Command + Tab to the window
2. unpress Tab
3. press and hold Option (alt)
4. unpress Command

For windows with multiple items open, play with the arrow keys

(Custom) Maximize Current Window (vertically)
Ctrl + m

Switching Between Multiple Safari Windows
Command + ~ (tilde)

Safari Tabs
Ctrl + Tab

Installing Tar Files (example)
   [frodo:~] testuser% tar xf fink-0.34.5.tar.gz
   [frodo:~] testuser% cd fink-0.34.5
   [frodo:~/fink-0.34.5] testuser% ./bootstrap

Building and Installing a C project?
./configure
make
sudo make install

or?

$ mkdir build
$ cd build
$ cmake ../
$ make
$ make install

Installing a Python project from tar

* Unpack: tar zxvf sslstrip-0.5.tar.gz
* Install twisted:  sudo apt-get install python-twisted-web
* (Optionally) run 'python setup.py install' as root to install,
 or you can just run it out of the directory.

IP Forwarding on OS X Lion+
It is a known fact that IP Forwarding (port forwarding) does not work on OS X Lion by default.
But there is a fix!
Modify your /Library/Preferences/SystemConfiguration/com.apple.Boot.plist file and a <string></string> tag set
with the following:
net.inet.ip.scopedroute=0

PATH in OS X Mountain Lion
/etc/paths
http://architectryan.com/2012/10/02/add-to-the-path-on-mac-os-x-mountain-lion
http://superuser.com/questions/28344/path-env-variable-on-mac-os-x-and-or-eclipse

Disable or modify mouse acceleration
SmoothMouse

Snap Windows to Corners
BetterTouchTool