sshfs makes it convenient to mount a directory from a remote Linux computer on a local Linux computer. SSHFS-Win makes it easy to mount a directory from a remote Linux computer on your local Windows computer.
- Install the latest stable installer of WinFSP from here.
Install the latest stable installer of SSHFS-Win from here.
Open File Explorer, right-click on This PC and choose Map network drive. Choose a drive to mount at and in the Folder field enter:
Windows will ask for your password at the remote computer. After that the home directory from your remote computer will be mounted at the Windows drive you chose. I found that I had full read-write access to the files mounted from remote.
Tried with: SSHFS-Win 2.7.17334 and WinFSP 1.2.17346
Visual Studio Code is a great editor for local files. Remote VSCode is an extension that enables editing files on remote systems in your local VSCode. Note that you will need to specify individual files on the remote computer and they will appear in your local VSCode. You cannot open a remote folder and expect all of the code there to be indexed for code browsing with this method.
- Install rmate on the remote computer. rmate has been ported from its original Ruby implementation to Python, Bash and other languages. I like to use rmate-python. Installing it is easy:
$ sudo pip3 install rmate
//-------- Remote VSCode configuration --------
// Port number to use for connection.
// Launch the server on start up.
// Address to listen on.
// If set to true, error for remote.port already in use won't be shown anymore.
$ ssh -R 52698:127.0.0.1:52698 yourlogin@remotecomputer
- Once you are SSHed into the remote computer, run this command there:
$ rmate -p 52698 file/you/want/to/edit
The file will appear in your local VSCode for editing. The remote file will be updated with any changes you make locally after you save the file.
Tried with: Visual Studio Code 1.22.2 and Remote VSCode 1.1.0
Cygwin uses Unix paths. It can be sometimes confusing to figure out where in the Windows filesystem a Cygwin path is actually referring to. This is precisely why Cygwin ships with the cygpath tool.
- To print the Windows path of a Cygwin Unix path:
$ cygwin -w /some/unix/path
- To print the Windows path of a Cygwin Unix path in a DOS-compatible path format:
$ cygwin -d /some/unix/path
- To find out how a Windows path can be accessed inside Cygwin as an Unix path:
$ cygwin -u "C:\Windows"
In C and C++ code, I sometimes need to specify the number of bits in a byte. For example, when creating a bitset object. In old architectures, the number of bits that make a byte has varied, from 1 to 48 bits. But for all practical purposes today, 8 bits make a byte. However, I am not comfortable using the magic number 8 in my code or creating a new constant variable with that value whenever I need it.
Thankfully, the C and C++ standards have a constant for that:
CHAR_BIT. It is defined in limits.h and climits. It is guaranteed to be set to the number of bits in a byte on the architecture you are running on.
Visual Studio Code has a decent Vim extension. I use it by default and sometimes wish I could yank to and paste from the system clipboard. Thankfully, this feature is available in the Vim extension, but turned off by default.
To turn on this feature, set the vim.useSytemClipboard setting to true. You may need to restart VSCode for it to take effect.
Note that you can yank text to the clipboard of your OS and also paste from it into VSCode using Vim.
Tried with: Vim extension for Visual Studio Code 0.11.5 and Visual Studio Code 1.22.2
In big projects that use Make, it can be hard to examine how a make build is working and to diagnose a build problem. Imagine my joy when I finally discovered ReMake. This is a debugger, you heard it right, built off a version of GNU Make. It essentially allows you to step through a make build just like you would step through a program using GDB and examine state at any point in time.
- Installing remake is easy on Ubuntu:
$ sudo apt install remake
- Using remake is as easy as replacing your make command with it:
$ remake some_target
- If you want a verbose output of what is happening with your build use
$ remake -x
- To actually debug a build with its debugger:
$ remake -X
The debugger jumps and waits at the line with the target that it needs to execute first. Use the help command to get a list of commands that you can use. They are all similar to GDB: step to step into, next to execute next line, print to print values of make variables (this is a lifesaver!) and so on.
Tried with: remake 3.82 and Ubuntu 16.04
Many programs fail or behave mysteriously because they are looking for or reading environment variables that you may not be aware of. It would be very useful if you could see what environment variables they are probing for.
If the program is using the getenv standard library call, then you can list all those calls, the environment variable requested for and what value was returned using ltrace:
$ ltrace -e getenv ./your_program
You will be surprised how many environment variables you had no idea about are probed by common programs that you use. I find this usage to be immensely useful in increasing my understanding of any program I use.
ltrace is an immensely useful tool to know what a program is doing. It displays the library calls made by a program that you execute. Just like strace, it will display the function called, list its input arguments and also display the return value from the function. Note that only calls made to dynamically linked libraries are reported. Not those to libraries that have been statically linked into the executable.
- Installing ltrace is easy:
$ sudo apt install ltrace
- Provide a program as argument when you invoke it:
$ ltrace ./foobar
$ ltrace touch
Note that it writes its output to stderr.
- To redirect output of ltrace to a file:
$ ltrace -o foobar.log ./foobar
- To filter and display only calls to a certain library function:
$ ltrace -e foobar_function_name ./foobar
$ ltrace -e malloc ./foobar
Note that you need to specify the exact name of the function. You can also use some method name and library name globs and regular expressions. For more info, please see the manual.
Tried with: ltrace 0.7.3
When you double-click text in Firefox, what is selected depends on the punctuation characters that are inside or around the text. By default, punctuation characters like dashes are not part of the word. So, you might find that a word-like-this is not fully selected on double-click.
This selection behavior is controlled by the preference layout.word_select.stop_at_punctuation. You can go to about:config and change it if you would prefer that punctuation characters be ignored.
I wanted to check out the Practical Deep Learning for Coders course by FastAI. However, I noticed that the course provided configuration instructions mainly for cloud GPU instance providers like Paperspace. I have a notebook and a desktop computer with powerful NVIDIA GPUs and wanted to try the course on my local machines. The course material is also provided in the form of Jupyter notebooks, while I intended to turn those into Python programs to run locally.
Here are the steps I followed to get my local computer setup for the FastAI course:
- The local computer was running Ubuntu 16.04 and NVIDIA drivers were already installed on it and working.
- CUDA 9.0 was installed using the online instructions from NVIDIA.
- The latest release of CuDNN was installed as described here.
- Conda was installed and configured as described here. You should be able to run
conda info from the shell. I wanted to try the course without resorting to Anaconda, but that seems unnecessarily complicated.
- Clone the fastai Github repo:
$ git clone email@example.com:fastai/fastai.git
- In the fastai directory, use this command to create a Conda environment named
fastai and install all the required Python packages (including PyTorch) under that:
$ conda env update
- Activate the
$ conda activate fastai
>>> import torch
- Open a Python interpreter and check if you can import the fastai package:
$ from fastai.imports import *
You are now ready to execute any of the code shown in the course at a Python interpreter or inside Python scripts. Note that you will still need to download any additional datasets needed by the course. You will find these instructions in the Jupyter notebooks or course material.