Adobe Acrobat: Extract Pages of PDF


Sometimes you may want to extract certain pages of a PDF file and save those pages as a separate PDF file.


This is easy to do with Adobe Acrobat. Open the PDF file in Acrobat and choose DocumentExtract Pages. In the Extract Pages dialog, choose the pages you wish to extract and press OK. A new instance of Acrobat opens with the pages you specified. Choose FileSave to save these pages as a new PDF File.

Tried with: Adobe Acrobat 8

About these ads

CUDA on Tesla over Remote Desktop


Typically, CUDA programs cannot be executed over a Remote Desktop session. (For more on this problem, see here.) However, if the CUDA device is a Tesla and if it does not need to be the primary graphics device, then you are in luck! A typical setup for Tesla is to have another Quadro device handle the desktop graphics, while the Tesla device handles the computation. In such setups, CUDA programs can be executed on the Tesla device over Remote Desktop! :-)


To be able to successfully execute CUDA programs on a Tesla device, you need to use a Tesla Compute Cluster (TCC) driver and set the Tesla device to TCC mode.

1. Install TCC Driver

CUDA programs can execute on Tesla devices with the CUDA developer driver you might have downloaded off the CUDA webpage. However, the developer driver is not the same as the device specific driver. (For more on the difference, see here.) To be able to use the TCC mode of the Tesla device, the TCC driver specific to the Tesla device is needed.

To get the Tesla driver, use the NVIDIA Drivers webpage and choose the driver for your Tesla device. This is its TCC driver. Install it.

2. Switch to TCC Mode

By default, the Tesla device will be working in a Windows Display Driver Model (WDDM) mode. This is the mode used by most CUDA devices, since they might need to support desktop graphics. If the Tesla device is in the WDDM mode, then it will not be able to execute CUDA programs over Remote Desktop.

To switch the Tesla device to TCC mode, we can use the NVIDIA System Management Interface (SMI) tool. On Windows, this is provided as an executable file named nvidia-smi.exe. On my system, this was found in the C:\Program Files\NVIDIA Corporation\NVSMI directory. Open a Windows command prompt with elevated (Administrator) privileges and change to this directory. (One way to open an Administrator command prompt is described here.)

To list the available NVIDIA devices use the command:

nvidia-smi -q

To view the details of a specific device use the command:

nvidia-smi -q -i 0

The -i specifies the ID of the device. Device IDs begin from 0 upwards.

Finally, to flip the driver model of a device from WDDM to TCC mode:

nvidia-smi -dm 1 -i 0

The -dm parameter takes two values: 0 for WDDM and 1 for TCC.

Changing the driver model mode of the Tesla requires a restart of the system. After the restart, you should be able to execute CUDA programs remotely on the Tesla computer! :-)

Tried with: Tesla C2050 and Quadro 4000

PowerShell: Command History

The Windows command prompt (cmd.exe) has simple command history. You can press the Up/Down arrow keys to cycle through the previous commands. If you want a visual display of previous commands, you can press F7 and use the Up/Down keys to navigate the list and Enter to execute a command.

PowerShell has powerful command history features. To see the list of all available commands from history:

PS> Get-History

To cycle through previous commands from history, press # followed by Tab key presses. Each press of the Tab key, displays one older command from the history stack.

PS> #[Tab]

To switch to a specific command from the stack displayed by Get-History, press #, the number of that command in the stack and Tab. For example, to get the command numbered 9 in the Get-History stack:

PS> #9[Tab]

PowerShell can also find a previous command if you can provide the starting few letters. For example, this will bring up all the commands where I invoked vim:

PS> #vim[Tab]

PowerShell can also understand the * wildcard. For example, this will bring up all the commands where I edited a log file using vim:

PS> #vim log*.txt[Tab]
PS> #vim log*[Tab]

The module that will hook you to command history is PowerTab. Install it (for instructions see here) and press # and Tab to get a visual list of all commands in the history stack! :-) Note that PowerTab does not provide a few of the above features like the wildcards for example.

Tried with: PowerShell 2 and PowerTab 0.99.6

PowerShell: Error on Modifying Shortcut Properties


PowerShell appears in a console with a blue background by default. If you try to change any of the console properties like fonts, colors or size and try to save it, it throws the following error:

Error Updating Shortcut
Unable to modify the shortcut:
Check to make sure it has not been deleted or renamed.


The shortcut has neither been deleted or renamed since we opened the PowerShell console, so this error message is useless. To be able to modify the PowerShell console properties, make a copy of its shortcut and place it anywhere in the Start menu folder. You might want to rename it to My-PowerShell or something different. Open PowerShell using this new shortcut and you will be able to modify and save its properties.

Tried with: PowerShell 2 and Windows 7

Xplorer2 Lite: TortoiseHg Icon Overlays and Menus Missing


Xplorer2 Lite is the free version of the Xplorer2 file manager. On your computer, you might find that the TortoiseHg icon overlays and right-click menus are missing in Xplorer2 Lite.


This problem happens with 64-bit Windows and 64-bit TortoiseHg. 64-bit shell extensions will not work with 32-bit applications. Now, Xplorer2 Lite ships only as a 32-bit executable and thus TortoiseHg (which is a shell extension) icon overlays and menus will not appear with the 32-bit Xplorer2 Lite.

However, the 64-bit TortoiseHg installer does include a 32-bit extension. Download the latest 64-bit TortoiseHg and during installation choose the x86 option (it is unchecked by default) along with the 64-bit extension and both will be installed. Now, both 32-bit programs (like Xplorer2 Lite) and 64-bit programs (like Windows Explorer) will display the TortoiseHg icon overlays and menus.

Tried with: Xplorer2 Lite and TortoiseHg 2.1.2

Console2: Change Text Color

Console2 is a Windows utility that can be used to host the Windows command shell (cmd.exe), PowerShell, Cygwin shells or any other shell. By default, it displays a black background and the text is displayed in a dull gray color.

The Settings dialog of Console2 does not really indicate where this text color comes from or how to change it. To change the default text color to pure white or any other color, open EditSettings dialog. In the Console Colors Map section, locate the gray color square (marked in the screenshot above) and change it to any color you want. The console text will be displayed in your chosen color.

Tried with: Console2 2.00.147

C++: Print Current Date and Time

The easiest way to obtain the date and time string in C++ is to use time, localtime_s and asctime_s. The output string is of the form Tue Aug 02 15:11:23 2011.

Here is the self-explanatory code:

#include <ctime>

time_t curTime;
struct tm locTime;
const int TimeStrLen = 26;
char timeStr[ TimeStrLen ];

if (    ( -1 != time( &curTime ) )                          // Seconds since 01-01-1970
    &&  ( 0 == localtime_s( &locTime, &curTime ) )          // Convert to local time
    &&  ( 0 == asctime_s( timeStr, TimeStrLen, &locTime ) ) // Convert to string
    cout << "Date-time is: " << timeStr;
    cerr << "Error calculating date-time!" << endl;
    exit( 1 );