Archive for the ‘Tips’ Category

GIT Tip: Saving current changes to a patch

Wednesday, September 7th, 2011

If you use GIT for revision management, you might run into situations where you need to save your current changes without committing them.  While you can use the “git stash” command, the stash command applies to your entire working directory.  Sometimes it is useful to save changes from a particular sub-directory or project.

You can create a patch from your local changes:

git diff -p . > filename.patch

Note that the “.” can be any file specification (including wild-cards).

To apply the patch:

git apply filename.patch

Searching the web from n2

Monday, October 19th, 2009

You can add a tool that launches a web search on the currently selected word.  This can be useful to quickly lookup documentation for functions that you use in your code.

To add the custom tool, follow these steps:

  1. Click on Tools->Customize->Add
  2. Enter the following information:
    1. Title: &Help
    2. Command: c:\program files\Internet Explorer\iexplore http://bing.com/results.aspx?q=%SEL%&mkt=en-us&FORM=LVCP
    3. Hot Key: F1 (click in the field and press F1)

You can now select a word while in n2 and press F1 to launch Internet Explorer on the selection.  If the selection is empty, n2 will automatically use the word under the insertion point.

You can modify the URL from step 2.2 to specify a specific site or additional restrictions.  For example using the following: c:\program files\Internet Explorer\iexplore http://bing.com/results.aspx?q=%SEL%%20(Windows)&mkt=en-us&FORM=LVCP will append “(Windows)” to your search string.

Needless to say, you can customize the commands to use your favorite browser and search engine.

Binary file editing with n2

Sunday, October 18th, 2009

There are 2 ways to open a binary file with n2:

  1. On the command line: n2 /b filename
  2. Using the command window (Alt+C): eb filename

You can edit very large binary files with n2 since it only loads a small portion of the file into memory at any one time.  If the binary file you open is currently in use, n2 will open the file for read-only access.  This allows you to still view and search in the file.

When editing binary files, n2 supports multi-level undo and copy / paste.  To make it easy to spot changes, bytes that have been modified since the last time you saved are displayed in red (by default).  You can change the color for modified bytes using Tools->Options->Colors->Modified Binary.

n2_binedit