Skip to content

Blog#

Using Pageant with VSCode Remote SSH

While Putty and Pageant are widely used tools for SSH connections, you can also integrate Pageant with VSCode to establish remote SSH connections without administrative privileges. While the default ssh-agent service offers similar functionality, it's disabled by default and requires administrative access to start if disabled, making Pageant a more flexible alternative. Here's how you can set it up:

Installing Ollama without root

Inspired by the official guide, here is my method for installing (or updating) Ollama without root access.

mkdir -p ~/src
cd ~/src
curl -L https://ollama.com/download/ollama-linux-amd64.tgz -o ollama-linux-amd64.tgz
mkdir -p ~/opt/ollama
tar -C ~/opt/ollama -xzf ollama-linux-amd64.tgz

Add Ollama to $PATH:

echo 'export PATH=$PATH:~/opt/ollama' >> ~/.bashrc
. ~/.bashrc

Then you can run ollama in your terminal:

nohup ollama serve &

ollama -v
ollama list

# Pull the embeddings model for AnythingLLM RAG
ollama pull nomic-embed-text

# Run the smallest deepseek model
ollama run deepseek-r1:5b

To stop the Ollama server:

killall ollama

# or
killall -u $USER ollama

Databricks Connect

Databricks Connect allows you to connect your favorite IDE (PyCharm, VSCode, etc.) and other custom applications to Databricks compute and run Spark (or non-Spark) code.

This post is not a comprehensive guide on Databricks Connect; rather, it consists of side notes from the Azure Databricks docs. Most of the notes also apply to Databricks on AWS and GCP.

Generating Azure OAuth2 Access Token By Python

There are two modern ways to generate an Azure OAuth2 access token using Python: one is by using the MSAL library, and the other is by using the Azure Identity library, which is based on the former.

There're also other ways to get the token, like using the requests or aiohttp libraries etc. to send a POST request to the Azure OAuth2 token endpoint, but it's not recommended. As the MSAL and Azure Identity libraries are the official libraries provided by Microsoft, they are more secure and easier to use. For e.g. they handle token caching, token refreshing, and token expiration automatically. Furthermore, some of the credential types are difficult (too many code) to be implemented by raw requests or aiohttp.

Python thread safe operations

Quick example from the official Python documentation about thread safety in Python:

Thread safe operations
L.append(x)
L1.extend(L2)
x = L[i]
x = L.pop()
L1[i:j] = L2
L.sort()
x = y
x.field = y
D[x] = y
D1.update(D2)
D.keys()
Not thread safe operations
1
2
3
4
i = i+1
L.append(L[-1])
L[i] = L[j]
D[x] = D[x] + 1

It's important to understand that Python, due to its Global Interpreter Lock (GIL), can only switch between threads between bytecode instructions. The frequency of these switches can be adjusted using sys.setswitchinterval(). This ensures that within a single bytecode instruction, Python will not switch threads, making the operation atomic (thread-safe). For a deeper dive into this topic, you can read this discussion on atomic and thread-safe operations in Python.