Mon, 29 Jan 2018

When purchased iTunes songs get removed.

— SjG @ 10:08 am

It was Sunday night, and I was passing the time by making a playlist in iTunes.

Due to the famous user-centric Apple user interface as exemplified by iTunes, the contextual menu that appears for a given song has “Remove Download” right next to the “Add to Playlist” submenu. Naturally, since deletion is something that you’ll want to do in a super streamlined fashion, there’s no confirmation if you accidentally mis-mouse onto the remove option.

Which is what happened to me last night as I tried to add Elmerlee Thomas’ amazing rendition of “All the Pretty Little Horses” to a playlist.

Boom. Track is gone! Hey, no problem, simply re-download, right? Ha. No such luck. I get the highly useful “Unable to access at this time, try again later” error message “err = 2059”. So I try again the next day. No good.

So no worries. I’m obsessive about backups. I restore the .m4a file from backups.

Sadly, iTunes happily ignores it, and says “nope, gotta download this file.” Trying to download, of course, gives the same annoying error.

The web suggests I look in my iTunes purchase history via the account tab, and re-download from there. Some believe there is a special magic that causes that download link to work differently than the one in the track listing area. Although I chanted the sacred “by the blessed ghost of Steve please work” mantra, this was also unsuccessful — but not for the reason I expected. The reason this was unsuccessful was due to the album not even showing up in my purchase history. Within iTunes, I viewed information from the other tracks to confirm that it was an iTunes purchase.

That’s when I get into a chat session with Apple Support. After reiterating details, the Apple Support person reported they could not find the track in question. Did I say I’m obsessive about backups? I’m obsessive to packrattish levels. I found the original email receipt from when I purchased the album, lo these many years ago. I recited Order ID and Document Number to Apple Support.

“Upon reviewing my resources, I found that content provider has removed the album from the iTunes Store. Hence you are unable to re-download it from past purchases,” quoth support.

“How can I restore from backups?” I asked. I’m obsessive about backups!

The instructions given were the ones that had failed earlier. After suggesting I repurchase the album (which we had just resolved was no longer available), Support basically told me I was out of luck.

But behold, I found a solution, which I hereby share with the world! The key is in how you restore a track. If you just restore it into the directory where it had previously been, iTunes doesn’t update the metadata and still thinks it’s been removed. Instead, restore the .m4a file to some other location like your desktop, then drag it into iTunes. That will update the metadata, and — glory be — your track will be restored.

So, lessons learned:

  • Be careful with your mousing, because iTunes hates you and wants to hurt you deeply.
  • Have no faith in the re-download-ability of anything ever.
  • Trust not in the clouds of others, for they are fickle and subject to the whims of record labels./li>
  • Support will tell you to spend more money if it will get you to go away.
  • Backups. Obsess over them.
Filed in:

Mon, 1 Jan 2018

Projector Stand, v.1.0. Status: failure.

— SjG @ 10:55 am

We have a ViewSonic short-throw projector hooked up to an old Mac Mini and a DVD player, which we use to watch videos and YouTube. We project the shows on the living room wall, or sometimes, to be easier on our backs, upward to create “ceiling cinema.”

After taking a class on OnShape given at Crash Space, I thought an adjustable projector stand would be a good project to really teach me the software.

I’ve used a half dozen modeling / CAD programs over the past few years, and each one has a different learning curve. I should probably write up what I like and dislike about all of them. For now, I’ll just say that OnShape is a JavaScript modeler that runs in your browser1, and is developed by the team behind SolidWorks. It has all manner of professional design capabilities, materials planning, and so on — far, far more than I’m capable of using at this point.

My design was based on the plan to use the Crash Space laser cutter and 5mm birch plywood to build the final stand. It would be adjustable on one axis to swing from wall to ceiling modes, would have a simple locking mechanism, and would be stable enough to old the projector steady.

After far longer than I thought was reasonable, I had a design done in OnShape. For joining the edges with nice interleaving tabs, I used the Laser Joint add-in. The rest was based on measuring the physical objects and thinking about what I wanted. One nice thing in OnShape is that you can set motion constraints and simulate solids. This way, I could paste in a stand-in for my projector, and see that the range of motion would be correct.

Now that I had a design, I needed to export the individual pieces to be laser cut. There are layout add-ins available for OnShape, but none seemed to work for my design (probably because I didn’t take the time to thoroughly read the manual). Instead, I selected the primary face of each piece, and exported it as a DXF drawing.

Initially, I had problems. Nothing recognized the DXF files, even Inkscape, which generally is very good with this sort of thing. Aha! My version of Inskscape was out of date. Upgrading solved the problem. From Inkscape, I could export valid dimensioned PDFs.

From here, I had one other problem. One piece, the base, was larger than the 24″ x 12″ bed of the laser cutter. So I had to figure out a way to design two pieces that would fit together nicely. Taking inspiration from skull or pelvis suture patterns and the more happy shape of butterfly wings, I came up with a design. I imported the PDFs into Affinity Design, and split the base into two similar pieces. Since I already created some nice vector butterfly outlines, I figured I’d embellish the structure as well (I can’t help myself).

I ended up with four PDFs of actual-size designs that I could use on the laser cutter. I later realized that they are not the most efficient designs in terms of minimizing cuts, but I hadn’t been thinking of that when laying them out.

Here are the PDFs:

So those got cut out, and then brought home.

I clamped and glued the base, and misaligned it by a bit, but with some judicious sanding was able to make the relatively subtle mistake into something screamingly obvious. Oh well.

Then, I clamped and glued the sides to the base, and the hinge pieces to the platform piece. After the glue had dried, I sealed the pieces with polyurethane which turns out to be harder to brush on evenly than I expected. I ended up having to sand it away in places so that some of the closer tolerances would still fit.

From there, it was a simple matter to assemble. I added a spring to pull the locking bar up, and mounted the projector.

Hooray, it worked… sort of. There were a few problems that made themselves known right away. The first was dimensional.

In the original design, I measured the size of the projector — which I’d had to do very carefully so the three mounting screws would line up correctly. But what I didn’t take into consideration is that in use, the projector has cables plugged in, and they take up space. As per the photo below, I hadn’t accounted for about an inch and a half of needed clearance. This prevents positioning vertically for a good ceiling tee-vee experience.

Another problem, however, is the one that will require a new design. I anticipated that the combination of the large disc-in-hole hinges and the overall friction would result in fairly low force on the locking teeth against the locking bar. This proved to be true, but also the high friction in the system made it hard to tell when the locking bar was entirely clear when doing position adjustments. This, in turn, made it unfortunately easy to break the teeth.

So there it is. Version 1.0 earned a grade of “Failure.”

Version 1.1 is under consideration. Possible approaches are a pin-and-hole locking mechanism (slower and more difficult to change), or possibly forgoing locking altogether and using a screw-down friction-based brake instead. After all, the projector only weights a few pounds. A switch of materials would also work, but I’m kind of set on wood. I like the look of wood far more than I do the look of the various acrylics that I’d be able to cut with the Epilog. I suppose I could use a service to cut out of metal, but quarter-inch metal would be pretty heavy for the purpose.

1 The fact that you can write this kind of serious software, and that it runs in a web browser on a five-year-old notebook computer is really astonishing to me. Yet, it is indeed true.

Filed in:

Sat, 9 Dec 2017

Laser Menorah

— SjG @ 6:49 pm

You know, this title is misleading. The reality is a whole lot more boring. Maybe next year, I should take inspiration from the title.

This is more of a lazy Saturday afternoon project. I wanted to use some designs that I’ve been kicking around. So I took a sea of hexagons and a tree in Affinity Designer and mucked about for a bit until I had something where I more or less liked the look.

Next, I grabbed a slice of poplar (available in 8″ x 24″ x 0.25″ slabs at Home Deport, as “Hobby Poplar”) and drove over to CRASH Space. While it’s mega-take-apart-day, I scurried over to the laser cutter. I converted the design to PDF, loaded it up in Corel Draw, used the Epilog printer-driver, and sent it to the laser cutter. The poplar cuts very nicely.

Here’s a link to the PDF of the laser-cut portion, if you want to cut a copy yourself.2017-12-09-hexonorah-cut.pdf

I brought the pieces home, sanded lightly, drilled a few holes, and mounted the vertical piece onto the base, carefully mis-aligning it with the major axis of the elliptical base. Ah well.

I drilled holes where I would mount the candle holders themselves (after all, poplar is pretty, but not ideal as a holder for things on fire). For the actual sockets, I used some nice quarter-inch brass compression caps (also from Home Depot). I drilled a center hole, pushed through a brad, and then soldered it with a torch.

Next, let things cool, dried off the sockets, and put it all together.

The final result is not as attractive as I had imagined it. It’s a little … I dunno, squat? Perhaps the next iteration will have more dramatic tree-like branches emerging to hold the candles.

OK. Next year, forget the design. We’ll just go with lasers.

Sat, 7 Oct 2017

Simple file monitor

— SjG @ 11:59 am

Say you host a few web sites for various folks, and you give them write access to a directory on your server. Well, then, my friend, you’re as big a fool as I am.

Maybe you want to mitigate this foolhardiness by keeping an eye on what these folks upload. For example, when I see a user uploading SuperBulletinBoardThatIsTotallyNotASpamTool.php or SuperWordPressPasswordSharingPlugin.php, I can call them and explain why I’m deleting it. I can be a slightly-less-bastard operator from heck.

So here’s a quick bash script that I use. It’ll also help to alert you if somehow one of the WordPress sites gets compromised, and rogue php files get installed. It ignores commonly changing files or things we’re not interested in like images. It shouldn’t be considered an intrusion detection system, or a robust security auditing tool — this wouldn’t really help in the case of an actual hacker with any l33t skillz at all. It’s just a quick information source.


rm -f /tmp/fcl.txt

rm -f /tmp/fcld.txt

/usr/bin/find /var/www/ -type f -ctime -1 | /bin/egrep -v "\\.git|\\.svn|(*.jpg$)|(*.gif$)|(*.pdf$)|wp-content\\/cache|files\\/cache\\/zend_cache" > /tmp/fcl.txt

xargs -0 -n 1 ls -l < <(tr \\n \\0 /tmp/fcld.txt

[ -s /tmp/fcld.txt ] && /usr/bin/mail -s "MYDOMAIN.COM FILES UPDATED" < /tmp/fcld.txt

Throw it into a crontab, and there you have it. You'll get an email with a list of files changed in the past day.

Wed, 27 Sep 2017

Seasonal Palettes

— SjG @ 7:43 pm

Over the years, I’ve written various JavaScript mandala-generators. I like giving variety to the color sets used, and in the past, I’ve hand-crafted collections of colors which I’ve given descriptive names like “Earthy,” “Angst,” and “Scorchio.”

For a new project, I wanted seasonal palettes. Being a northern-hemisphere dweller, I think of January as cool colors, May as yellows and greens, August as ambers and oranges, etc. Rather than hand assemble them, I thought this would be a good use for the Interwebs.

So I wrote a bash/php/ImageMagick script that would hit with a seasonal search term to bring back the first twenty-five matching pictures. It then made a composite of the pictures, did a pixelation process, reduced the colors to a minimum set, and built a palette from them.

With excuses of fair use, here’s a visual of that process, using the example where the search terms were “Landscape July”:

1. Images are brought down, each scaled to fit in a 64 x 64 pixel square, and then they’re all combined into a single image.

2. The combined image is pixelated by scaling to 5% of the original size, then scaling back up to a larger size.

3. To get a little more punch and a little less muddy, the pixelated image has its histogram equalized

4. For good measure, the script then reduces the image to 32 colors.

Now, some of this may be redundant. For example, we could easily skip step 2, since we’re reducing colors in step 4. However, this way we sort of reduce the color space before we equalize the histogram. Maybe I should experiment with other paths here.

In any case, the results for my first search term “($month) Landscape” was not very good:

I tried some other search terms for good measure.

Here’s “($month) colors”:

Here’s “($month) thoughts”:

And finally, here’s “($month) skies”:

I have a few conclusions. First, it’s obvious that a hand-created set of palettes would be better. The pictures Flickr returned for each search term didn’t match my expectations very well. Perhaps I’d have done better with season names instead of month names. Lastly finding the best palette from an image is a problem that Google tells me many have worked on. I’m assuming others have probably done better than I.

But it’s a curious question — what are the “characteristic” colors from an image? My approach largely comes down to the number of pixels of a given general color. Are there lots of blues? My approach will have at least some blue. But if an accent color is “important,” whatever that means, my approach will probably lose it.

In any case, it’s probably back to mandalas and hand-crafted palettes for the next project.