Friday, 17 January 2025

Note to self - Firefox and local connections

 Whilst trying to hit my NAS from Firefox on my Mac, I kept seeing errors such as:-

Unable to connect

Firefox can’t establish a connection to the server at 192.168.1.23:5000.

    The site could be temporarily unavailable or too busy. Try again in a few moments.
    If you are unable to load any pages, check your computer’s network connection.
    If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the web.
    If you are trying to load a local network page, please check that Firefox has been granted Local Network permissions in the macOS Privacy & Security settings.

The same page worked in Safari, and I was able to SSH into the NAS, so knew that the network was not a notwork :-)

There's a clue in the last sentence of the error, which is nice ( and, I suspect, may have been added recently ) : -

If you are trying to load a local network page, please check that Firefox has been granted Local Network permissions in the macOS Privacy & Security settings.

Yes, you've guessed it...


Once I checked the box for Firefox, I was off to the races ...



Monday, 9 December 2024

Reminder - installing podman and skopeo on Ubuntu 22.04

This follows on from: -

Lest I forget - how to install pip on Ubuntu

I had reason to install podman and skopeo on an Ubuntu box: -

lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.5 LTS
Release: 22.04
Codename: jammy

having updated Ubuntu: -

apt-get update && apt-get upgrade -y

but both: -

apt-get install -y podman

and: -

apt-get install -y skopeo

gave me sadness responses: -

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package podman

and: -

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package skopeo

respectively.

And then I remembered ...

As for pip I needed to enable the universe ...

by updating /etc/apt/sources.list to include: -

deb http://us.archive.ubuntu.com/ubuntu jammy universe
deb http://us.archive.ubuntu.com/ubuntu jammy-updates universe

Once I did this, and re-ran apt-get update I was off to the races ...

Now, will I remember this tomorrow ? :-) 

Tuesday, 25 June 2024

Note to self - use kubectl to query images in a pod or deployment

In both cases, we use JSON ...

For a deployment, we can do this: -

kubectl get deployment foobar --namespace snafu --output jsonpath="{..image}"

which returns the image name(s) on the same line

Or we can do this: -

kubectl get deployment foobar --namespace snafu --output JSON | jq -r '.spec.template.spec.containers[].image'

which does much the same, although with each image on a separate line 'cos formatting

Alternatively, we can examine the pod: -

kubectl get pods --namespace snafu --selector app=foobar --output jsonpath="{..image}"

which, again, returns the image(s) on the same line, but for each pod in the deployment - which perhaps leads to duplication

For me, kubectl get deployment is simpler ...

Friday, 14 June 2024

Lest I forget - how to install pip on Ubuntu

 I seem to forget to remember this almost monthly, every time I spin up a new Ubuntu VM

This time around, it's Ubuntu 22.04 and I'm trying to install python3-pip ( aka pip3 or just pip )

apt-get install -y python3-pip

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python3-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python3-pip' has no installation candidate

Ah, of course, it's sources.list as ever ...

cat <<EOF >> /etc/apt/sources.list
deb http://us.archive.ubuntu.com/ubuntu jammy universe
deb http://us.archive.ubuntu.com/ubuntu jammy-updates universe
EOF

and now apt-get install -y python3-pip is happy
 

ls -al $(which pip)

-rwxr-xr-x 1 root root 221 Nov 10  2023 /usr/bin/pip

ls -al $(which pip3)

-rwxr-xr-x 1 root root 221 Nov 10  2023 /usr/bin/pip3

Saturday, 17 February 2024

Visual Studio Code - Wow πŸ™€

Why did I not know that I can merely hit [cmd] [p] to bring up a search box allowing me to search my project e.g. a repo cloned from GitHub etc. for a file name ?



How long have I spent manually navigating the folder structure on the left-hand side ?

πŸ™€πŸ™€πŸ™€

Saturday, 30 December 2023

Getting started with Python in Jupyter Notebooks

So, as we get ready to start a new year, I'm tinkering with a bunch of new ( to me ) tech toys, including wrangling Python dependencies.

Having spent much of of the past year or so using pip and pyenv to manage Python dependencies, more recently, I've been looking at an alternate solution, Anaconda.

Having downloaded and installed the Mac version of Anaconda - and allowed it to install itself into ~/.zshrc ( as I use Z Shell rather than, say, Bash ), when I start a new Terminal window ( I'm using iTerm 3.4.23 on macOS 14.2.1 ), I automatically open up in a virtual environment called base 

conda env list

# conda environments:
#
base                  *  /Users/hayd/anaconda3

type conda

conda is a shell function from /Users/hayd/.zshrc


This also gives me access to Jupyter : -

type jupyter

jupyter is /Users/hayd/anaconda3/bin/jupyter

jupyter notebook

  _   _          _      _
 | | | |_ __  __| |__ _| |_ ___
 | |_| | '_ \/ _` / _` |  _/ -_)
  \___/| .__/\__,_\__,_|\__\___|
       |_|

Read the migration plan to Notebook 7 to learn about the new features and the actions to take if you are using extensions.

https://jupyter-notebook.readthedocs.io/en/latest/migrate_to_notebook7.html

Please note that updating to Notebook 7 might break some of your extensions.

[W 15:06:56.602 NotebookApp] Loading JupyterLab as a classic notebook (v6) extension.
[I 2023-12-29 15:06:56.605 LabApp] JupyterLab extension loaded from /Users/hayd/anaconda3/lib/python3.11/site-packages/jupyterlab
[I 2023-12-29 15:06:56.605 LabApp] JupyterLab application directory is /Users/hayd/anaconda3/share/jupyter/lab
[I 15:06:57.709 NotebookApp] Serving notebooks from local directory: /Users/hayd
[I 15:06:57.709 NotebookApp] Jupyter Notebook 6.5.4 is running at:
[I 15:06:57.709 NotebookApp] http://localhost:8888/?token=707355ee0dd1f8fd9bf4e7124b83d1126a024cc4606eade0
[I 15:06:57.709 NotebookApp]  or http://127.0.0.1:8888/?token=707355ee0dd1f8fd9bf4e7124b83d1126a024cc4606eade0
[I 15:06:57.709 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 15:06:57.711 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///Users/hayd/Library/Jupyter/runtime/nbserver-33550-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=707355ee0dd1f8fd9bf4e7124b83d1126a024cc4606eade0
     or http://127.0.0.1:8888/?token=707355ee0dd1f8fd9bf4e7124b83d1126a024cc4606eade0
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.


which automatically opens up a browser tab: -


jupyter notebook list

Currently running servers:
http://localhost:8888/?token=707355ee0dd1f8fd9bf4e7124b8ad1126a024cc4606eade0 :: /Users/hayd


shows me the running notebook, plus it's port AND authentication token :-)

With the Jupyter server running, I quickly created a new Python3 ( pykernel ) notebook: -



and am off to the races: -



For reference, I'm working on watsonx.ai as a coder at present, and am running through some of the Python-based prompt engineering tutorials, and wanted a place to test the generated Python code

This was of use, in terms of getting me started: -



Saturday, 4 November 2023

More on macOS SMB sharing

As a follow-up to an earlier post: -


I hit this problem again and referred back to my post, and also to Dan's post: -


digging further into the firewall settings on my Mac mini

Having noticed that smbd did NOT appear in the list returned by 

/usr/libexec/ApplicationFirewall/socketfilterfw —listapps

I looked again at the firewall settings: -


and explicitly added smbd via it's path: -

/usr/sbin/smbd

and also enabled smbd via 

 /usr/libexec/ApplicationFirewall/socketfilterfw --unblockapp /usr/sbin/smbd

Incoming connection to the application is permitted

Now it looks better: -

/usr/libexec/ApplicationFirewall/socketfilterfw --listapps

ALF: total number of apps = 4

1 :  /System/Library/CoreServices/ControlCenter.app
  ( Allow incoming connections )

2 :  /Applications/Firefox.app/Contents/MacOS/updater.app
  ( Allow incoming connections )

3 :  /usr/sbin/smbd
  ( Allow incoming connections )

4 :  /System/Library/CoreServices/UniversalControl.app
  ( Allow incoming connections )

and, even better, I can access the Mac Mini via SMB from other Macs without issues

Nice !

Note to self - Firefox and local connections

 Whilst trying to hit my NAS from Firefox on my Mac, I kept seeing errors such as:- Unable to connect Firefox can’t establish a connection t...