Tuesday, June 7, 2022

vispy segfault

You never remember the difference between computers. Vispy wasn't working.

degs:vispi% python line-draw.py
zsh: segmentation fault  python line-draw.py

This doesn't give you much to go on. After diving into the debugger, I found that I had a bad binding from Python into the Qt5 library. I fixed it with:
sudo port install Qt5
pip install PyQt5 

Friday, October 29, 2021

debian didn't have the correct locale

This was one of those frustrating things.
root@mxg:~# update-locale
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_All = "C.UTF-8",
	LANG = "en_GB.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
I fixed it with this:
export LANGUAGE=en_US.UTF-8; export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8; locale-gen en_US.UTF-8
After that, reconfigure dpkg
root@mxg:~# dpkg-reconfigure locales
Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.

Sunday, January 24, 2021

Typescript setup on MacOS.

I finally updated my laptop from a 2013 MacBook Pro to a 2020 MacBook Pro. I treat my computers like an applicance, so I do not generally upgrade or change anything. Having said that, things change over 7 years. I use MacPorts. I am using visual studio code for typescript development.
I will assume that macports is already installed.

The first thing we need to do is install the javascript package manager, npm.
sudo port install npm6

There's a note of interest if you every want to no longer use npm.
  npm6 has the following notes:
    It is not recommended to install packages globally. But if you do so please
    be aware that they won't get cleaned up when you deactivate or uninstall
    npm6. Globally installed packages will remain in
    /opt/local/lib/node_modules/ until you manually delete them.

Now it's time to install the typescript compiler.
 sudo npm install -g typescript

Here's the notes on where it installed things:
/opt/local/bin/tsc -> /opt/local/lib/node_modules/typescript/bin/tsc
/opt/local/bin/tsserver -> /opt/local/lib/node_modules/typescript/bin/tsserver
+ typescript@4.1.3

Now try it. Let's see if we can see the tcs typescript compiler.
% tcs
zsh: command not found: tcs

Okay, so this means that either 1) we didn't actually install it or 2) it's not in the path. The first thing to try is the "rehash" command.
rehash

Now on to try tsc again.
% tsc  --version
Version 4.1.3

And that means success.

Tuesday, January 19, 2021

SSH with no password

I always forget how to do this. If you have to do it more than thrice, write a script. The script below will allow for login to a remote server without a password.
 
#!/bin/bash
#Before anything else, set the PATH_SCRIPT variable
 pushd `dirname $0` > /dev/null; PATH_SCRIPT=`pwd -P`; popd > /dev/null
 PROGNAME=${0##*/}; PROGVERSION=0.1.0 

printf '\nWarning!\nThis script creates the ssh key pair so that one does not need\n
to type a password to login more than once.  If you know that you\n
need to do this, you probably can check this scripts source\n
to see what is being done.\n\n'

read -r -p "Are you sure you want to continue? [y/N] " response
case "$response" in
    [yY][eE][sS]|[yY]) 
        ;;
    *)
        exit 1
        ;;
esac
printf "This script will put public key on the remove server\n
and now it will ask for your USERNAME and the REMOTESERVER\n"
printf "USERNAME [ENTER]:"
read USERNAME
printf "REMOTESERVER [ENTER]:"
read REMOTESERVER

echo "Will send pair to $USERNAME@$REMOTESERVER"

if [ -f "$HOME/.ssh/id_rsa.pub" ]; then
   echo "$HOME/.ssh/id_rsa.pub exists, skipping rsa key generation"
else
   #create the key pair
   echo "ssh-keygen -t rsa"
   ssh-keygen -t rsa
fi

#create the remote directory if it doesn't exist and change the mode
echo "ssh $USERNAME@$REMOTESERVER 'mkdir -p .ssh && chmod 700 .ssh'"
ssh $USERNAME@$REMOTESERVER 'mkdir -p .ssh && chmod 700 .ssh'

echo "cat .ssh/id_rsa.pub | ssh $USERNAME@$REMOTESERVER 'cat >> .ssh/authorized_keys'"
cat $HOME/.ssh/id_rsa.pub | ssh $USERNAME@$REMOTESERVER 'cat >> .ssh/authorized_keys'

Friday, October 23, 2020

libngspice does not get built by default on macports

If you want to use PySpice, you first must have the library bindings installed. The Macports Portfile for ngspice does not build the libraries by default. Here's the symptom:
OSError: cannot load library 'libngspice.dylib': dlopen(libngspice.dylib, 2) : image not found. Additionally, ctypes.util.find_library() did not manage to locate a library called 'libngspice.dylib'
Basically, this means that there's just not a library. I couldn't find it anywhere, and then I realized that macports did not build the library by default.
Find where the portfile is:
sudo port file ngspice
Next, you have to edit it to add --with-ngshared:
    configure.args      --enable-cider \
                        --enable-xspice \
                        --enable-pss \
                        --with-editline \
                        --with-x \
                        --enable-debug=no \
                        --with-ngshared
Finally, you can build the port. If you have already installed it, you need to upgrade it:
sudo port -sn upgrade --force ngspice
I wish that there was some way to append a configuration argument via the command line, but I just cannot seem to make it work, even though there's a facility for it.

freehdl doesn't work as-is on macports

I had to add the following to the portfile:
configure.cxx_stdlib	libstdc++