Working through a book on modding Minecraft with the kiddo. It knows its target audience: the first few lessons are all about explosions!
It’s written for 1.8, which is a problem because a lot of the structure has changed between then and 1.12, but a decent IDE with auto complete and a sense of common naming schemes has made it relatively easy to adapt the simple lessons so far. We’ll see how well that works as they get more complicated.
Back when I was comparing social media archives, I considered resurrecting my old LOLspam project as a Mastodon bot. I never quite got around to it, partly because I was able to do most of what I wanted to automate using IFTTT, so I stopped investigating that last 5%.
Last night, I threw together a quick and dirty bot to post a random item from a text file in about 20 minutes.
Then I spent three hours going through the Twitter archive for @LOL_Spam, pulling out jokes that are too dated or cringeworthy. (I hope I didn’t miss any. It was midnight by the time I finished, and I was really tired!)
This morning I modified the script to take a second file as a queue for new items.
- I can add new items to the queue file as I find them.
- It’ll post from the queue on a schedule (using cron).
- When it uses up the queue, it returns to posting random posts from the archive.
If you’re interested in funny/odd spam subjects (and you’re OK with swearing and occasional lewdness), check out @LOLspam@BotsIn.Space. You can follow from any Mastodon or other Fediverse account.
The script itself is called fedbotrandom. I wrote it in Perl, using text files, so I could just put it in cron on any *nix box instead of worrying about language/database support or installing a runtime or DB engine. I’ve made it really simple on purpose, and while I do plan on writing some better error handling when I have time, It’s already more complex than I wanted it to be!
You can find me on Mastodon at @KelsonV@Wandering.shop.
Kiddo’s been wanting to learn programming, with the ultimate goal of modding Minecraft. We’ve done some Ruby, but he’s impatient, so last night I we started Java with a simple program that repeats a
println X times.
He wanted to pass it the integer limit.
After a few minutes, I suggested we watch a movie and check back later.
After dinner, he decided to stop it and we timed some shorter runs.
I think he has a better understanding of scale now!
Every once in a while I encounter a problem with something so blindingly simple that
- I can’t imagine I haven’t tried it before, and
- I can’t believe no one else has documented the problem either.
ColdFusion 9 and later has a tag called <cfspreadsheet> which makes it dead simple to read, update, or create an Excel file. Want to plug the results of a query into a spreadsheet? Literally one tag with just three parameters.
There’s also function GetTempFile() that will create a guaranteed unique file on the server that you can then manipulate.
The obvious solution if you want to create a spreadsheet to download is to create a temp file, write to it with cfspreadsheet, then serve it up.
<cfset filename=GetTempFile(GetTempDirectory()) >
<cfspreadsheet action="write" overwrite="true" filename="#filename#" query="myquery">
<cfheader name="Content-disposition" value="attachment;filename=MyFile.xls">
<cfcontent type="application/msexcel" file="#filename#">
<cffile action="delete" file="#filename#">
It turns out this won’t work. You’ll get a Null Pointer Exception in the logs. Not because of anything you’d expect, though…it turns out that cfspreadsheet is relying on the file extension, and since GetTempFile() gives you a file ending in .tmp instead of .xls, it isn’t sure what to do with the file.
Solution: Find some other way to name your temporary file, and give it an .xls extension.
There’s nothing like finding an edge case for a program you’ve written, thinking “Oh no, I didn’t take that into account!”…then checking the code and realizing that you already did.