Category Archives: Applications

SSHFS

Most developers often need to perform some work on remote systems which are accessible via SSH. For performing minor changes it is fine to SSH into the system and edit the files directly, but for more complex changes that involve a larger set of files the comfort of an IDE would be nice to have. For such situations the SSHFS filesystem client comes to rescue.

Using an SSHFS client we can mount a remote system as a local drive/folder. This allows us to perform any operation on mounted files with the tools we are used to. For example, we can open a remote project in our favorite IDE or process the remote data with local specific tools.

The only server requirement for getting SSHFS to work is to have SSH enabled. The clients usually support both password and private key logins.

The process of installing and using the SSHFS client on different Linux flavors is outlined here in great detail, with examples.

For Windows, the win-sshfs client can be used. The original project was hosted on Google Code but several forks have been created from it. A very detailed post outlines the installation and usage of win-sshfs on Windows 10 and recommends the usage of the dimov-cz fork. However, the latest version of that fork did not work with the .Net version on my work Windows 7 machine and as I didn’t want to upgrade it I reverted to the original win-sshfs, version 0.0.1.5, which can be downloaded from the Google Code archive. This works just fine for me.

Note that all versions of win-sshfs require that Dokan is installed, which is a user mode file system on top of which win-sshfs was developed.

Once the win-sshfs client is installed, configuring and mounting a remote system is straightforward.

Display Note Dates in NoteCase Pro

NoteCase Pro is my choice when it comes to note keeping applications. This is a powerful cross-platform application that contains an impressive set of built-in features, but also provides a mechanism for extending the functionality via plugins and user scripts in the Lua scripting language.

While reading or working on a note I often need to be aware of the date when the note was first created or last modified. NoteCase Pro keeps this information in the notes database and the UI can be configured to present these dates in the note tree, but I wanted a solution that doesn’t clutter the interface. So I wrote a short Lua script that displays these dates in the status bar.

The script makes a few calls to the NoteCase API and formats the output in the desired way:


-- get IDs for the current document and note and store as variables
nDocID = Nc_Doc_ID_GetCur()
strNoteID = Nc_Note_ID_GetCur(nDocID)

-- get the dates
strDateCreated = Nc_Note_DateCreated_Get(nDocID, strNoteID)
strDateModified = Nc_Note_DateModified_Get(nDocID, strNoteID)

-- Format the output string

-- The string below would use the default timestamp format: yyyy.mm.dd hh:mm:ss
-- strOut = "Created: " .. strDateCreated .. ", Last Modified: " .. strDateModified

-- Let's convert to a more readable format
-- First parse the captured timestamps
pattern = "(%d+).(%d+).(%d+) (%d+):(%d+):(%d+)"
crtYear, crtMonth, crtDay, crtHour, crtMinute, crtSeconds = strDateCreated:match(pattern)
modYear, modMonth, modDay, modHour, modMinute, modSeconds = strDateModified:match(pattern)
-- Then form the output string
strOut = "Created: " .. crtDay .. "/" .. crtMonth .. "/" .. crtYear .. " ..... Last Modified: " .. modDay .. "/" .. modMonth .. "/" .. modYear

-- Finally, show status bar message in black text
Nc_GUI_StatusBarMessage(strOut)

We save the script in a text file somewhere in the file system. The script gets registered by the application in the Script Manager dialog (Add-ons -> Script Manager).

Scripts can be mapped to Script Events, which would get them invoked by the application on specific events. My initial idea was to assign my script to the ‘After note focused’ event so that the dates would get printed on the status bar whenever a new note is displayed, but alas, NoteCase overwrites the status bar with some information after this event.

So instead of mapping my script to an event, I assigned it a shortcut key in the Shortcut Settings dialog (Tools -> Shortcut settings). This way, whenever I want to inspect the note creation and last modification date of the presented note I press the shortcut combination and the dates get shown in the status bar.

It is also possible to add a button to the toolbar through the Toolbar Settings dialog (Tools -> Toolbar Settings) by copying the corresponding ‘Lua script’ entry from the ‘Available actions’ list to the ‘Toolbar layout’ list.