Category Archives: Troubleshooting

Firefox Thinks It’s Running an Older Version Than Last Time (But Isn’t!)

I finally upgraded to Fedora 30 today, and when I launched Firefox for the first time, it complained that I was running an older version than the last time I’d used it, and needed to create a new profile.

Using an older version of Firefox can corrupt bookmarks and browsing history already saved to an existing Firefox profile. To protect your information, create a new profile for this installation of Firefox.

Wait, what?

OK, Firefox did release two emergency updates yesterday. Maybe Fedora 29 got 67.0.4 and Fedora 30 got 67.0.3, and DNF decided it was important to downgrade to the Fedora 30-provided version?

No, both were still on 67.0.3. So what could be going on?

A quick search turmed up a Reddit thread on the problem that pointed me to the solution: Look for the compatibility.ini file in my Firefox profile, and delete the LastVersion line.

It worked! Firefox launched happily, with all my settings and everything.

I made a note of the version that was in there before, and the version that got placed when I launched it, and that cleared up what had caused the confusion.

Apparently, Fedora built the F30 package earlier in the day than the F29 package! 🤦‍♂️

Fedora 29: 67.0.3_20190619204842/20190619204842
Fedora 30: 67.0.3_20190619113000/20190619113000

So it was technically “older” … just not in any meaningful sense.

How to get Grails to use a reserved word with Microsoft SQL

If you’re building a Grails application using a Microsoft SQL database, and you want to have a property on an object that’s a reserved word in MSSQL, like RULE, you’ll probably end up with a SQL syntax error because Grails, Gorm and Hibernate don’t know what words are reserved in MSSQL.

You can just use another name. Does the property need to be called MyObject.rule? You might want to call it something more specific anyway. Problem avoided!

But if you want to keep the name, or if you can’t change it in the DB (say, because you’re connecting to a legacy database), you can get it to work!

Use a custom mapping. Grails lets you map a domain object’s properties to a column that doesn’t fit the usual camelCase → snake_case pattern, and you can use the same mechanism to add the delimiters that MSSQL needs to use the reserved word as a column name. Problem solved!

static mapping = {
    rule column: '[rule]'
}

Now Gorm/Hibernate will use the right delimiters on the back-end, and you can keep accessing myObject.rule, MyObject.findByRule() and so on.

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.* I also use it to post from RSS and WordPress to publish new blog posts to services that aren’t available in Jetpack.

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).

(Update: If you’re hooking up something that’s totally automatic, rather than something triggered by your own actions on another site, especially if you don’t plan on posting to the same account manually, I’d recommend looking for a bot-friendly Mastodon instance like BotsIn.Space. That’s where I set up @SpeedForce@BotsIn.Space to post every time there’s a new blog entry on Speed Force.)

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

URL: https://mastodon.example.com/api/v1/statuses?access_token=1234567890 (replace the host with your server and 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}}>>>

Update (August 2018): Be sure to include the status= at the beginning! You can also add optional parameters for the Statuses method of the Mastodon API to add spoiler text, mark it as sensitive content, change the visibility (public, followers-only, etc), and so on. So to post an excerpt in a CW that doesn’t show up in local/federated timelines or hashtag searches, you would do something like this:

spoiler_text=Link: <<<{{Title}}>>>&visibility=unlisted&status=<<<{{Url}}>>> <<<{{Excerpt}}>>>

Update: The “ingredients” available (Title/PostTitle/etc.) will depend on the source you’re using, and you can get them from the IFTTT user interface. RSS feeds will have Title, Url, etc., WordPress will have PostTitle and PostUrl, and so on.

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 @kelsonv@wandering.shop**. 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.

**After juggling several accounts for a few months, including the one at Mastodon.Social I was using at the time I wrote this article, I settled on Wandering Shop as my primary Mastodon home in July 2018.