Category Archives: Troubleshooting

Groovy, null, and ‘null’

Groovy will let you call toString() on a null object. The result is the word ‘null’, which might be what you’re expecting if you know the object is null, but probably isn’t what you’re expecting if you don’t.

So if you’re, say, binding a SQL parameter and you forget to check for nulls like you would in Java, and you forget to use a null-safe operator like you should in Groovy, and you get a null value, what happens? Does groovy…

  1. Throw a NullPointerException like Java?
  2. Set the field to null?

Neither. It sets the field to the string ‘null’.

Make sure to use myVariable?.toString() instead of myVariable.toString() for cases like this!

How to Post to Mastodon From Anything Using IFTTT

I finally managed to hook up IFTTT to Mastodon to auto-post from another site! I use IFTTT as glue for linking several services together including sharing interesting links from Pocket when I’m offline: I can add a tag in the app on my tablet, and then when it syncs that tag up to the cloud, IFTTT will pick it up and create the share post on whichever service I’ve tagged it for.*

My main source was this post by @raucao@kosmos.social. It’s a bit out of date, but it pointed me in the right direction.

1. Set up IFTTT’s Maker WebHooks

On IFTTT, go to maker_webhooks settings. Make sure it’s active.

2. Set up Mastodon to allow IFTTT as an application

Go to Preferences/Development/Your Applications on your Mastodon instance (ex: on mastodon.social it’s here). Click on New Application. Enter the following:

Name: IFTTT
Website: https://maker.ifttt.com/ (at first I thought you needed the full URL from the IFTTT config, but it seems OK without it.
Scopes: read and write should be enough. Actually just write might be fine.

Submit the app.

Now open the new app you’ve created and look up the access token.

3. Create an IFTTT app!

Go back to IFTTT and create a new app. For example, I created an app triggered by Pocket, whenever an item is tagged share-mastodon. You could also set it up to autopost every time you blog with a specific tag, or every new item in an RSS feed, or all kinds of things. Even cross-post from Facebook or “the birdsite” (Twitter).

For the “then that” section, choose a Webhooks action.

URL: https://mastodon.social/api/v1/statuses?access_token=1234567890 (paste your access token here.)
Method: POST
Content Type: application/x-www-form-urlencoded
Body: status=whatever-you-want-to-post

For example, to share a link from Pocket you might want the body to be

status=<<<{{Title}}>>> <<<{{Url}}>>>

Or for posting from WordPress, you might want it to be

status=New blog post: <<<{{PostTitle}}>>>
<<<{{PostUrl}}>>>

Click on Create Action.

Add a title and click on Finish.

4. Test it out!

Go and post something that should trigger the rule, then come back and click “Check Now” on the IFTTT applet. Make sure it comes through the way you want it to. Adjust it as needed.

Update (Feb 2018): This method can’t upload images, because the Mastodon API needs the image to be uploaded before you post the status, and IFTTT apps can only take one action. If you want to cross-post between Twitter and Mastodon, you can use crossposter.masto.donte.com.br, which can handle image uploads. @outside_rs confirmed that you can use Twitter+Crossposter as intermediaries to get images from another service onto Mastadon, as in Instagram→ IFTTT→ Twitter→ Crossposter→ Mastodon. It’s roundabout, but it works! (Not sure when I’ll have time, but I’m thinking about writing a gateway script that you can hit directly from IFTTT that will upload an image and then post to Mastodon with it, removing the dependency on Twitter.)

Update (March 2018): You need to watch out for ampersands and single quotes when doing this, because the API handler treats them as separators. Wrapping the ingredient like this <<<{{Title}}>>> should fix it.

You can follow me on Mastodon at @kelsonv@mastodon.social. If you’re not on Mastodon, but would like to check it out, start at JoinMastodon.org. It’s a quick overview of what Mastodon is, how it’s different from Twitter, how different instances work (think of them as different servers on an MMO game, or different email services), and how to pick an instance that suits you.

*The day after testing the Pocket-to-Mastodon connection with a few links, I discovered something interesting about IFTTT when it re-posted one of those links to Buffer. Apparently IFTTT doesn’t know which tags are new, only which bookmarks have been updated and what the current tags are. My new Pocket-to-Mastodon applet picked up the share-mastodon tag I’d just added, and my Pocket-to-Buffer applet picked up the old share-buffer tag that had been on there since I first shared it last month.

NVIDIA on Fedora 27: Bad Resolution & Painful Mouse Lag (Fixed)

I’ve been using an older NVIDIA graphics card in my Fedora Linux workstation for a long time. I finally decided to upgrade to a newer one, which meant uninstalling the legacy drivers, then installing the current NVIDIA drivers.

Using the RPMFusion packages simplified it, because I only had to do the following to uninstall the old nvidia-340xx driver and install the new one:

dnf remove xorg-x11-drv-nvidia\*
dnf install xorg-x11-drv-nvidia akmod-nvidia
reboot

(Of course, I still had to hit ESC during boot, CTRL+ALT+2 to get to a text console, and log in without access to copy/paste or windowing.)

But it didn’t work. Oh, it brought up the GDM login screen, sure, but the mouse cursor and keyboard response were so slow I could barely even click on the form. It would move normally for about a second, then simply stop for five seconds. You can’t use a computer like that. Even if it had let me log in — it didn’t — there wouldn’t have been any point.

Additionally, the resolution was slightly off, with the aspect ratio on everything stretched vertically.

And of course I couldn’t use any of the graphical utilities to adjust settings, because I couldn’t run anything graphical.

I tried all kinds of things to fix it:

  • Creating an xorg.conf file with nvidia-xconfig. (no change)
  • Manually adding an xorg.conf section setting the resolution to the monitor’s native resolution. (no change)
  • Completely reverting to Linux’s built-in nouveau drivers, uninstalling all traces of nvidia and reinstalling Xorg and mesa as suggested at RPMFusion. That made the computer work again, but 3D graphics were slow. Reinstalling the nvidia packages fresh took me back to square one.

Nothing I could find online was remotely helpful. It was all about making sure the drivers were installed correctly, which I’d done, or configuring X.org, which (a) I’d done, and (b) hadn’t made any difference. (Fortunately I had another device I could look this stuff up on!)

Finally, just as I decided to revert to nouveau again just to have a working system and table the question of 3D acceleration until later, I hit upon an idea.

Wayland, the new display framework, isn’t compatible with the official NVIDIA drivers. I hadn’t had any problems with nvidia-340xx, so I figured I’d long since disabled Wayland and forgotten, but just for kicks, I switched over to the text console and tried

ps -ef | grep -i wayland

…and found that Wayland was running!

But Fedora’s GDM is supposed to fall back to X.org when it’s not able to run (the nvidia drivers are mentioned specifically). Maybe it recognized the old driver as incompatible, but thought (wrongly) that the new one could handle it?

Fortunately, that page also offered the solution:

Edit /etc/gdm/custom.conf, and put the following line in the [daemon] section:

WaylandEnable=false

The line’s actually in there already, commented out.

Literally, the solution to the problem that had me tearing my hair out for an hour was to delete a single #.

GDM displayed correctly, mouse and keyboard responded smoothly, and I was able to log in just fine…and 3D was much faster than my old card.

Problem solved!

But only because I finally realized I needed to look for Wayland.

Android Oreo Won’t Stop Vibrating

I finally discovered why my phone has been vibrating on most incoming messages since upgrading to Android Oreo, even when sound is on: It’s now a per-conversation setting, so even though I have Messenger set to sound only, that only applies to new senders. I had to go through my saved text messages and turn vibrate off in every. single. saved. conversation.

Deleting a conversation also makes it use the default setting the next time that person sends a message, so if you don’t want to save the existing texts, deleting them is faster.

Not terribly convenient, Google.

Of course, that only fixes it for Messenger.

Notification settings are per-app now, and it seems Oreo assumes you want it to vibrate along with the ringtone unless the app turns it off. And of course not all of them let you turn off vibration independently from sound. They haven’t needed to until now, after all.

Ironically, this includes Chrome. I’m trying out Mastodon (find me at @kelsonv@mastodon.social for general conversation and @kelsonv@photog.social for photos), and for now I’m using the embedded Chrome app. And I can’t fine-tune the notifications because Google’s own flagship browser doesn’t include the options it needs on the new version of their OS! 🤦