Monday, March 31, 2025

Clearing up the AI programming myth.

 They are great for writing simple programs in Python or other languages that automatically share new entries from an RSS feed to my Mastodon account. However, this isn't the type of task you’d typically hire someone for. It simply saves those who need this tool the hassle of seeking out alternatives or trying to piece together a solution from the many non-functional examples scattered online.


Let’s say it can successfully generate a realistic CRUD app or website complete with standard features for managing data—Create, Read, Update, and Delete pages. That’s still relatively straightforward, as many generators already exist to fulfill this need. I’ve even created a few custom ones to speed up my projects. Now, let’s think about updating this app with something simple, like adding a new column to one of the tables in the database. How would you instruct the AI to do that? If you're not familiar with programming concepts, you might find it tough to express your needs clearly to the AI. It’s like asking it to build a new app and transfer the data seamlessly.


Even if an AI advances enough to handle the tasks mentioned effectively, the core of what we, as developers, do boils down to two main types of instructions:


1. Features: For example, "Page [insert name here] doesn’t look quite right; fix it, move something between pages, or add or remove an element."

2. Bugs: A customer runs into an error while using the application, and it might be as vague as that. The challenge lies in identifying the cause and fixing it. Realistically, we will need experienced programmers until we reach a point where AGI can analyze an existing codebase and truly understand it to manage feature requests. If it generates code with bugs, I struggle to see how it could resolve those issues. 

Programmers will probably replace project managers, necessitating a skill set that includes a strong understanding of database management, back-end, front-end, and even CSS. This kind of versatility has been rare in my 30 years of developing websites and applications. As projects have become more complex, specialization has often taken precedence. This trend will raise the bar for job standards, especially for entry-level positions.

Monday, November 21, 2022

Mastodon gateway on Linux

Install toot

As root (or add sudo to commands) install Python 3.X if you have not already with

yum install python3

then run

pip3 install toot

toot login

Answer instance with your instance hostname, then get code from browser. Note I had an issue (see pic) when I tried this again for a second server which appears to be and server customization issue. Fortunately I was able to copy the config file from the first server to the second. This would indicate the info is not client host of user linked.

Once the config file is set up for the user you can test with something simple like

toot post "toot test"

Note the double quotes. See the usage docs for more complicated posts.

Toot when server starts

We need to create some files with:

vi /root/tootUp.sh

#!/bin/sh

toot post "$HOSTNAME is back up" 

chmod 744 /root/tootUp.sh

The 2>&1 | tee -a /var/log/toots.log bit is only if you want to log the toots.

vi /etc/systemd/system/toot.service

[Unit]

Description=Toots that the system is back up

After=network.target


[Service]

Type=simple

ExecStart=/root/tootUp.sh

TimeoutStartSec=0


[Install]

WantedBy=default.target

Now enable it, try it and check it with:

systemctl enable toot.service

systemctl start toot.service

status -l toot.service

If everything is working then you should see something like this:

# systemctl status -l toot.service

● toot.service - Toots that the system is back up

   Loaded: loaded (/etc/systemd/system/toot.service; enabled; vendor preset: disabled)

   Active: inactive (dead) since Mon 2022-11-21 14:24:52 EST; 19s ago

  Process: 2622 ExecStart=/root/tootUp.sh (code=exited, status=0/SUCCESS)

 Main PID: 2622 (code=exited, status=0/SUCCESS)


Nov 21 14:24:51 server.dea42.org systemd[1]: Started Toots that the system is back up.

Nov 21 14:24:52 server.dea42.org tootUp.sh[2622]: Toot posted: https://techhub.social/@avatar42/109383430460374213

ssh gateway

To be safer you should really create a toot user. As root run

adduser toot

passwd toot

mkdir -p ~toot/.config/toot

chown -R toot.toot ~toot/.config

chmod -R 700 ~toot/.config

cp /root/.config/toot/config.json ~toot/.config/toot

chown -R toot.toot ~toot/.config/toot/config.json

chmod 600 ~toot/.config/toot/config.json

su - toot

Note you are now acting as user toot. 

Create a simple post script. This example is as basic as it gets you can be way more fancy.

vi tootPost.sh

#!/bin/sh

toot post "$*" 2>&1 | tee -a /var/log/toots.log

chmod 755 tootPost.sh

You might want a quick test like

~toot/tootPost.sh ssh gateway test

Note no double quotes. The script deals with that which we will need for the next bit.

Using the ssh gateway.

For the examples below I'm using the gateway IP address of 10.10.2.200. Replace it with yours.

Login to the PC you want to "toot" from.

Open a command / terminal window and change to the folder you want the toot files in.

Generate a key with

ssh-keygen -q -f toot_rsa

Take defaults / just press ENTER at each prompt.

Note this is creating a private key file we can use separately from default so it does not need a password on it.

Now we want to give the server the public copy so in future they will know it is us. It creates the .ssh folder if need be.

cat toot_rsa.pub | ssh toot@10.10.2.200 -o StrictHostKeyChecking=no "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys" || exit 1

It will ask you for the password to connect but you will not need to again. You can test this with

ssh -o StrictHostKeyChecking=no -i ./toot_rsa toot@10.10.2.200

or if you just want to go for it

ssh -o StrictHostKeyChecking=no -i ./toot_rsa toot@10.10.2.200 ./tootPost.sh ssh gateway test from client

toot and RSS feed

Lastly we can use this setup to toot an RSS feed.

Install feedexec back on the gateway server as user toot. 

pip3 install feed2exec

Note you may need to install some dependencies as well. I needed to install these too.

pip3 install sqlite3 sqlite pysqlite

Test with 

feed2exec parse https://www.nasa.gov/rss/dyn/breaking_news.rss --output echo --args '{item.title}'

If that works, create the file ~/.config/feed2exec.ini

vi ~/.config/feed2exec.ini

[SpaceStation]

url = https://www.nasa.gov/rss/dyn/shuttle_station.rss

output = feed2exec.plugins.exec

args = /home/tootPost.sh {item.title}. For details see {item.link}

Just change the RSS URL and message as needed. To then post any new items call
feed2exec fetch
or better yet set up cron with
crontab -e
adding the line
00 * * * * /home/toot/.local/bin/feed2exec fetch
to run it every hour.