playing with chatgpt

While I’ve been playing some with ChatGPT, I’m just not writing a blog post about it. It seems to be learning>L The first time I asked it about CodeRanch, it hadn’t heard of it. I tried again and got an answer. In this blog post, I show three different styles of questions.

Joke

I provided the prompt “tell me a joke about java lambdas” and got:

Sure! Here’s a joke about Java lambdas:

Why was the Java lambda feeling depressed?

Because it was an anonymous function without a name!

I hope you found that joke amusing. Do you have any other questions about Java or something else?

This joke amused me so mission accomplished.

Bio

When providing the prompt “who is jeanne boyarsky”, I got:

Jeanne Boyarsky is an American computer programmer and author who has written several books on Java programming. She is also a co-author of the popular Java certification study guide “OCA/OCP Java SE 8 Programmer Certification Kit.” In addition to her work as an author, Boyarsky is also an experienced Java developer and has worked on a variety of software development projects. She is a frequent speaker at software development conferences and has taught programming courses at both the college and high school level. Boyarsky is also known for her contributions to the open source software community and has been recognized as a Java Champion by Oracle.

A lot of this my bios, but not all of it. Taking it apart:

  • Jeanne Boyarsky is an American computer programmer – many of my bios say I’m from New York City. ChatGPT generalized that to the country.
  • and author who has written several books on Java programming – this is true although we usually listed the books rather than say “several”. But counting and generalizing is reasonable.
  • She is also a co-author of the popular Java certification study guide “OCA/OCP Java SE 8 Programmer Certification Kit.” – This language is in my conference bios. Scott actually wrote it this sentence and I copied it into my bio. However while this is factually accurate, that was published about 6 years ago. We’ve written Java 11 and 17 books since. A human would have highlight the more recent additions.
  • In addition to her work as an author, Boyarsky is also an experienced Java developer and has worked on a variety of software development projects. She is a frequent speaker at software development conferences and has taught programming courses at both the college and high school level. Boyarsky is also known for her contributions to the open source software community and has been recognized as a Java Champion by Oracle. – The rest of this is also paraphrased from various conference bios. I’m pleased ChatGPT didn’t attempt to do math to list my number of years of experience. I’ve read that arithmetic is not ChatGPT’s strong suit.

Coding

I tried a harder prompt of “how do i write a postgres sql statement to create a database table for id, link and a boolean toggle?” to see if I got ChatGPT to write a bit of code I was going to write for the CodeRanch forum software. I got

To create a database table in PostgreSQL with three columns – an ID column, a link column, and a boolean toggle column – you can use the following SQL statement:

Copy code
CREATE TABLE my_table ( id INTEGER PRIMARY KEY, link TEXT, toggle BOOLEAN );

This statement creates a table called my_table with three columns:

  • id: an integer column that is set as the primary key for the table. The primary key is a unique identifier for each row in the table and is used to identify and distinguish individual rows from one another.
  • link: a text column that will store a string value.
  • toggle: a boolean column that will store a true or false value.

Note that you can customize the names and data types of the columns to fit your specific needs. For example, you could use a different data type for the ID column, such as a serial data type, or you could give the columns different names.

I hope this helps! Let me know if you have any other questions.

The code was syntax highlighted and had a copy option. The explanation was detailed and ChatGPT inferred my key and types. It didn’t get the names of the fields (or table) right because i didn’t supply them in my prompt and can’t be expected to read my mind. And it was almost what I wanted. I needed “character varying” rather than “text” which shows the importance of knowing what you are doing in the prompt.

scheduling toots on mastodon

Last week, I wrote about my first month of Mastodon. This post is about three options for scheduling a Mastodon toot.

Option 1 – scheduler

The scheduler is easy to find. To use it, you go to your mastodon profile and choose “Development”. This lets you get an API key which you use to login and post. However, it doesn’t support images. (My use case involves an image in each toot.) It also didn’t work in Safari, but did in CHhome for me.

Option 2 – write your own

I started doing this. The REST APIs are well documented. There’s a variety of API wrappers for different languages. The Java one hadn’t been updated in four years and the Python one appears to want your password (not just access key), so I decided to stick with REST APIs. I created a GitHub action. First I used curl to test getting the token from a secret and calling a URL Then I played at the command line on uploading files.

name: JeanneTest

"main" branch
 #  push:
 #   branches: [ "main" ]
 # pull_request:
 #   branches: [ "main" ]
 
 #schedule:
 #  - cron: "0 2 * * 1-5"

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:

  build:
    runs-on: ubuntu-latest

    steps:
      - name: REST API test
        env:
             MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
           
        run: |
          curl --header "Authorization: Bearer $MASTODON_ACCESS_TOKEN" -sS https://mastodon.social/api/v1/timelines/home

This all worked. My next step would have been to switch to Python or Perl to call the attachment API, parse it’s JSON and publish the toot. Then add some sort of scheduler logic. I didn’t get that far because I learned about option 3.

Option 3 – Fedilabs

Fedilabs has an app for that. To use it, you login to your instance and get an auth code. (Each time you schedule.) Then you schedule your toots.

The only think I didn’t find intuitive was the alt text. (You have to upload your image and then the option appears.) What’s cool is that nothing is stored. The app uses the Mastodon REST APIs right away. You can even see your scheduled toots on top.

While I could have written my own, this one is better. And it already exists. So I put some money in the tip jar and am happily using.

Bonus – asking OpenGPT for help

I was thinking to have OpenGPT help me write this blog post. I asked “how do i schedule a mastodon post“. Alas:

I’m sorry, but I’m not able to browse the internet, so I’m not able to provide specific instructions on how to schedule a post on Mastodon. However, Mastodon is a social networking service, so you may be able to schedule a post by accessing your account and looking for a scheduling or scheduling option in the settings or composing a new post.

I then clicked “try again” and got the following. That’s probably true on some client. It isn’t the web browser nor the official iOS Mastodon app.

To schedule a post on Mastodon, follow these steps:

  1. Open the Mastodon app on your device and log in to your account.
  2. Click on the “+” button in the bottom right corner to create a new post.
  3. Type your post in the text field and add any photos or videos you want to include.
  4. Click on the “Schedule” button in the bottom left corner of the screen.
  5. A calendar will appear, allowing you to choose the date and time you want your post to be published.
  6. Once you have selected the date and time, click on the “Schedule” button to confirm.
  7. Your post will now be scheduled and will automatically be published at the specified time.

My first month on Mastodon

I signed up for Mastodon a month ago. Ok, fine. I month minus two days. It’s been long enough that I’m relying on it now and check it more often than Twitter. This blog shows up my impressions and learnings.

I signed up for three accounts.

Overall

I’m happy with Mastodon overall. With two caveats

  1. A social network is only useful if the people you want to interact with are on there. A good percentage of the people I follow are now on Mastodon (or both Mastodon and Twitter).
  2. It took a while to get settled. Granted Twitter had a learning curve too. But it was a long time ago. (My first post was in 2009). Some of it is forgetting. Apparently, I used to use the TwitterFox browser extension. And some of it is because the unofficial apps are better than the “official app”

Signing up for Mastodon

Signing up for Mastodon isn’t particularly user friendly. First you have to pick a server. Before you know much about the service.

A server is kinda like an email provider. You get a different domain name @gmail.com, @yahoo.com, etc. You can still talk to people on other servers, just like email. But that’s where the comparison ends. You don’t get a different user interface or special email user features. So what is different by server

  1. People can learn something about you from just looking at your name. For example, fosstodon supports free and open source software.
  2. Mastodon has a local timeline to see things other people on the server posted (regardless of whether you follow them).
  3. Different servers have different moderation rules. For example, I wanted one that was ok with non-human accounts for NYJavaSIG and CodeRanch.
  4. Servers are volunteer run and can close up shop. If that happens, you have to move.
  5. Servers can be banned by other servers. (ex: one with terrible moderation)

For my personal account, I chose mastodon.social because it was one of the two main ones and I didn’t know what I was doing. I later learned that people are encouraged to do choose different ones to spread the load. I chose to not to move at this time partially because it is cool to see the big timeline while I’m getting my bearings and partially because new servers keep getting stood up and switching after things stabilize reduces hops.

For NYJavaSig, I was interested in hackyderm.io and fosstodon.org because they are tech in nature. Fosstodon seemed more open to non human accounts. For NYJavaSig, I was able to register immediately. By the time, I got to doing registring for CodeRanch, you had to fill out a form saying why you wanted an account and have someone approve it. That took about a day.

Speaking of switching, you keep your followers/followings. Your toots (like posts) don’t move as far I can tell. That’s not important to me though.

Ultimately, it isn’t that important which server you choose. It is the accounts you follow that matter. Which brings us to….

Finding people to follow

I started out finding people on twitter who posted that they moved to Mastodon. Then I followed people I saw via boosts (like retweets)

After that, I learned that Marc Hoffman created JavaBubble for the Twitter/Mastodon/GitHub handles of Java folks. Non human entities are allowed like the NYJavaSig. He has good quality control. My contribution of CodeRanch to the list got rejected because almost our all tweets are about our free book promos. (Which is fair. We should post more outside of the promo).

I didn’t import the whole list for my personal account because I want my feed to be mostly English. I did add a bunch of people from it though. And it serves as a great lookup table. I did import the whole list for CodeRanch so I can look at the feed from there if I want.

There’s also websites, described by this blog post to help automate finding folks you follow.

Buttons when tooting (posting)

There’s a few interesting buttons when creating a toot.

  • World icon – you can control the access of your posts to public, unlisted (anyone with a link), followers only and visible to only people mentioned. The later being a direct message. More on that in a minute
  • Content warning – Mastodon encourages a content warning for certain topics. Even neutral ones. Like “politics neutral”. The idea is to give people a clue what is inside and let them click if they want to see it. I like this idea. Also could be useful for tv/movie/book spoilers :).

Mac Apps

There’s no official Mac app. The browser approach isn’t bad. I like the notifications view shows you how many there are. However, I have three accounts. Two of which are on the same server. An app would let me have a better experience across the three.

First I tried Mastonaut. Switching between accounts wasn’t bad. You can have multiple columns for different timelines (home/local/federated). I didn’t like that because it auto refreshes. And the local/federated timelines are busy places. The big problem with this app is that it didn’t let me add two sites from fosstodon. So I have my personal account and two of nyjavasig. Between this two problems, I kept researching.

Next I tried Whalebird, which I like. It’s a lot like slack. You have to choose which account you want at a given moment, but it is one click. And like Slack so feels familiar. Like Slack, it has channels, you get choices of: home, notification, mention, direct messages, favourite, bookmark, local timeline (your server), public timeline (local + all accounts someone on your server follows), and search.

Remember I was going back to DMs. The apps to a good job separating them out. So even though they are “just posts”, they feel like a native concept. I’m happy with Whalebird and sticking with it. At least for now.

iOS apps

There is an official app for Mastodon for iOS.It only supports one account so not very useful to me. I then read this comparison of 8 apps. I decided to try Toot! I paid the $4 and learned that I didn’t like it. First, the sign up isn’t intuitive. You sign up as anonymous to the server and login. Ok fine, setup is one time. However, the app doesn’t show how many comments there are on a toot. I really wanted that feature so I tried Metatext.

I’m happy with Metatext so far. It is open source with the code on GitHub. It’s basically maintained by one guy. But it’s free. So I can always switch in the future if another one becomes better for my needs.

To switch between users, you hold the user icon in the top left to get the other choices. There are home/local/federated timelines on top. And search/notifications/messages on the bottom.

Verification Links

In your profile, you can enter up to four links. They give you a URL to include that includes rel=”me”. Resave your profile after adding the link to your page to show you control it and the links show up as green/verified.

You can definitely change the body of the link to something other than “Mastodon.” And I think the link it is a one time check. I deleted one of them a while ago and it is still there. For github, there is a hack to get the verification link to work.

Cross posting

I used this crossposter to have my posts automatically go from Mastodon to Twitter. (It might be closing to new users due toa 300 posts/hour across all users limitation. Details and updates here.

Paying

Mastodon is free. However, the servers are paid for with donations as this is not a for profit endeavor and there are no ads. I signed up for the $10 a month Mastodon plan (which includes mastodon.social) and $5 a month Fosstodon plan.

Both also have $8/month plans now that Twitter has set $8 as the appropriate price for social media. Mastodon’s is called “8 dollars count too” with a description of “People have asked for this tier”. Fosstodon’s is called “Elon Tier” with a description of “Forget Twitter blue and stick it to Elon by supporting Fosstodon instead/”

What don’t I like (or haven’t figured out yet)

With just under a month of experience, I don’t know yet if these are dislikes or not having found a better way yet.

  • I haven’t found a mobile app that notifies me about direct messages
  • I get a number of posts in other languages. There’s a bug on github so this one isn’t just me.