Make SVN working copy into a branch after the fact.
When I realize the changes I am making in the trunk need to go into a branch, I simply create a new SVN branch and SVN switch my working copy to this new branch. Thats’ it. All my local changes remain in tact after the “switch”. SVN switch command allows you to create a branch after the fact, and to switch the working copy to the new branch. It is a superset of update command. You don’t lose your local changes during the switch. That is the beauty of the command. Scenario and solution explained further.
- Start making changes to the trunk
- Oops! realize that all these changes should go into a branch
- Create a branch – svn copy full/path/to/trunk full/path/to/branch (remember to give the fully qualified SVN path)
- Switch your working copy to the new branch you just created. svn switch full/path/to/branch
- All your local changes are still in tact. You can verify this with svn status, svn diff. Keep making changes
- Commit changes – svn commit
- All changes go into the branch
- Merge changes in the branch with trunk in the future
More detailed explanation can be found at svn book
Set executable bit in SVN
A few times in the past I ended up adding and committing executables into SVN without setting the executable bit. I used to delete/re-add the files with the right permissions (stupid, I know) to fix it later. The better way to do it is by changing the properties of the resource. See below
svn propset svn:executable ON filename
Show hidden files in Finder on Mac OSX
Run the following in the terminal.
defaults write com.apple.Finder AppleShowAllFiles YES
and relaunch Finder (by pressing option key + right clicking on the Finder icon).
Manage Clipboard history in Mac OS X Lion
Found this really useful app called Clipmenu. In my opinion, every OS should provide support for this feature as an option for the sake of power users! Feature could be disabled by default; to not overwhelm the average user. Just realized that there is a paid app for $4.99 called Clipboard History in the App Store, and a free app called rePasta to manage Clipboard history. Sticking with Clipmenu for now.
Prevent Spotlight from indexing your external hard-drive
By using the following trick.
Create an empty file named .metadata_never_index at the top level in the directory structure of your hdd. Stoplight won’t index the entire drive. If you don’t want to index select folders, then create this file in each of those directories.
Mount remote directories locally over SSH on Mac OS X
If you are familiar with the FUSE project (File System in User Space), then I don’t have to explain what MacFUSE is. MacFUSE has this really awesome extension called sshfs which allows you to simply mount remote directories locally (just like you NFS mount directories) over SSH. I had to revert to this mechanism to mount remote filesystems when the company I was working for decided that it will disallow NFS mounting of directories due to security concerns.
sshfs extension is super powerful, and makes working on remote files brain dead simple. Files mounted through sshfs appear on the local file system as local files. All edits/changes to files locally are automatically applied on the remote machine transparent to the applications working on the local files. The following are the usage instructions from sshfs documentation
To use the command line sshfs program, you can do something like:
# Mounting the SSH file system $ mkdir /some/mount/point # or use one that already exists $ sshfs user@host:/some/directory /some/mount/point -oauto_cache,reconnect,volname=<volname>
<volname> should be a string you wish to use as the name of the newly mounted volume. If everything went fine, you should see the volume on your Desktop and in the Finder (unless you have disabled remote volumes from showing up in these places).
Once you are done using sshfs, you can unmount the volume either using the eject icon in the Finder or other common user-interface means of ejecting. Alternatively, you can do the following from the command line:
$ umount /some/mount/point
Mount NFS through an SSH Tunnel.
Note: This only works for NFSv4
I usually NFS mount my files securely through an SSH tunnel. This is super easy, convenient, and most importantly secure. Things you need to do this
First thing to do is to set up the tunnel on the NFS client:
# ssh -fN -L "3049:servername:2049" NFSServer
This sets up the ssh tunnel from client’s local port at 3049 to NFSServer on port 2049 (the default NFS server port). To refresh how SSH port-forwarding works, all traffic to localhost:3049 now gets securely tunneled to NFSServer:2049. Now connecting to localhost:3049 is same a connecting to NFSServer on 2049 securely.
Remember that the server sshd needs to be configured to allow for port forwarding. If the server is not configured already, update /etc/ssh/sshd_config to ensure that the config file looks like this for the port forwarding entry:
# Port forwarding AllowTcpForwarding yes
#Restart the SSH server daemon. On Redhat/ubuntu run the following
/etc/init.d/ssh restart
Once the tunnel is in place, NFS mount syntax looks like this:
# mount -o port=3049 nfs://localhost/serverpath /localpath
This will mount the path /serverpath on NFSSserver to /localpath, and you can securely edit your files now 🙂
Mac OS X Terminal shortcuts for text editing and cursor navigation
I posted this answer on stackoverflow here. Adding it to blog for completeness.
On Mac OS X – the following keyboard shortcuts work by default. Note that you have to make option key act like meta in Terminal preferences (under keyboard tab)
- Meta-f to jump forward by a word
- Meta-b to jump backward by a word
I have observed that default emacs key-bindings for simple text navigation seem to work on bash shells. You can use
- Meta-d to delete a word starting from the current cursor position
- Ctrl-a to jump to start of the line
- Ctrl-e to jump to end of the line
- Ctrl-k to kill the line starting from the cursor position
- Ctrl-y to paste text from the kill buffer
- Ctrl-r to reverse search for commands you typed in the past from your history
- Ctrl-s to forward search (works in zsh for me but not bash)
- Ctrl-f to move forward by a char
- Ctrl-b to move backward by a char
OS X terminal default terminal shell is bash. The full manual for bash terminal shortcuts is here
Curl POST request
curl -d "param1=value1¶m2=value2" http://example.com/resource.cgi
or
GNU Screen
Cannot image working in a terminal without screen. Way better than mouse and makes me 3x faster when it comes managing sessions, jumping between them, toggling, and maintaining persistent connections with servers, keeping me always logged in, and giving me the power of detaching, and re-attaching to my previous workscreens/sessions in a jiffy. Things I find myself doing very often in my screen sessions. I have remapped Ctrl-A to Ctrl-P as I am a heavy emacs user. I have configured most of them through my screenrc file.
- C-p c:- create new shell
- f7/f8 – prev/next window
- C-p {some key} : combinations to start shells to do something. I use them to open shells to servers.
- C-p [0-9]: jump to a window number
- C-p k – kill session
- C-p C-p: toggle
- C-p A – rename
- C-p ” – all windows list
- C-p ? – help
- C-p [ – scroll Vim bindings will work here C-u/C-f and C-b /C-d to page up/page downs