Saturday, July 17, 2010

More than the sum of it's singles

Listened to a couple of whole albums on the 2 hour trip back from my parents' place tonight. Was listening to Live's "The distance to here" and thought to myself "There's scarcely even a sniff of filler on this disc". It an actual album that works end-to-end, in fact probably more so than as a bunch of individual tracks.

So do (m)any young-uns buys or listen to albums these days, or has the 99c track on iTunes destroyed this experience for future generations?

Here endeth the old-guy-back-in-my-day rant. Feel free to go all internet-music-critic if you must, but the particular album isn't really the point. Get off my lawn.

Monday, April 12, 2010

Little LEDs and Spaceships

I was recently asked by a friend about helping to dress up some models for table top gaming. Putting small electronic bits'n'bobs'n'batteries inside various objects is something I'm not unfamiliar with, but I hadn't attempted this particular operation before.


The models aren't truly tiny, so I could use 3mm diameter LEDs for the undercarriage lights, and 5 diameter mm ones for the engine lights.


Overall, it think it turned out not too badly, although I haven't yet had any feedback as to how he went in the painting/decorating section yet. If nothing else, he should definitely be in the running for the "most liberal use of hot melt glue" category.

I've put a few more detailed pics below for those that care to get up close and personal. The top two are a little blurry as I turned off the flash to better show the LED's, but was too lazy to set up the tripod. The detail shots are all sharper.











Not shown are the battery packs. I used a 6V battery a little thinner than a AAA and about a third the length (9.5 mm diameter by 15 mm). I used heat shrink hold on the leads to make it into a flying-lead version so as to connect to the mini terminal blocks, for a solder-less battery swap for the end user.

Sunday, March 7, 2010

Image Processing with Python

I needed to turn this:



into this:



Why? Well, my wife wanted to paste smiley faces onto some triangles, rectangles and other shapes. The set with the outline is great, but she wanted to put faces onto triangles, rectangle's and some other shapes too. (She's a teacher, the shapes were warring, harmnony day is approachng and, and ..... it's complicated, trust me). Anyway, the borders looked a little odd.

As there were 60 of them to do (15 expressions in 4 different colours), I started thinking I'd figure out how to do some python scripting from inside GIMP, but after half an hour of futzing about, I decided that was too messy, and just decided to process the images directly. This is pretty easy actually. One of python's included batteries is the "Image" library.

I decided to tackle it thusly; modify any pixels within a specified annulus to transparent. I originally intended to check that the pixel was black before modifying it, but I forgot, and in this case, it worked just fine anyway.

Here's the code I used:

# RemoveAnnulus_01.py
# Removes a dark circle from smiley faces
# Replaces black pixels in a specified annulus with transparency
# Doesn't do anti-aliasing

import os
import sys
import Image
import math

# Parameters to modify pixels in an annulus
xMid=53 # Centre position
yMid=53 # (origin)
rInner=45.0 # Inner radius
rOuter=54.0 # Outer radius
xMax=106 # (Image size)-1
yMax=106

inputFile=sys.argv[1] # Input image file
outputFile=sys.argv[2] # Output file, will be overwritten if it exists

thisImage = Image.open(inputFile)
pixelArray=thisImage.load() # Use load method for pixel addresing mode

try:
reportMessage="OK"
for thisX in range(0,xMax):
for thisY in range(0,yMax):
dX=float(xMid-thisX)
dY=float(yMid-thisY)
thisRad = math.sqrt((dX*dX + dY*dY))
if ( (thisRad>rInner ) and (thisRad
pixelArray[thisX,thisY]=(0,0,0,0)

except IOError:
reportMessage="Failed"

thisImage.save(outputFile, "PNG")

print "%s:Processing [%s] to [%s]" % ( reportMessage,inputFile,outputFile )


I've not shown the script for iterating through the 60 different files, but that's not really the point of this post. This code works with two command line arguments, the input file, and the destination file.

BTW, none of this is meant as a slight on the GIMP's scripting capabilities, I just have little experience with them, and decided to go with something more familiar.

Monday, March 1, 2010

A Cyberspace Independence Declaration

The "This Week in Google" podcast I just listened to mentioned the "Cyberspace Independence Declaration", written by John Perry Barlow. Leo read some excerpts and I thought a link to an audio version I enjoyed would be in order.

Link to MP3 audio, ~5 MB.

The reading is by Jan Ruback, and included as a bonus chapter at the end of his reading of Cory Doctorow's collectedion, Content. (Highly recommended, BTW) It's available a variety of audio formats on this internet archive page, the second bonus item after the numbered chapters. You can also play it directly from the embedded player on the page if you're so inclined (It's chapter 32 in the player).

The full text version is available, with a little background on the eff site. Here's the obligatory wikipedia article.





Friday, June 26, 2009

NFS Shares

Modifying both mine and my wife's ubuntu Desktop machines (both running 9.04 at the time of this writing) to mount our music folder (on the MythTV box on the lounge room) locally.

The music is on the media box (called mythty) in the lounge room, at /media/ourmusic

Using NFS, to mount manually it's:

sudo mount mythty:/media/ourmusic /media/ourmusic

(That's servername:serverpath localpath)

Edited /etc/fstab to add:

mythty:/media/ourmusic /media/ourmusic nfs rw rsize=8192,wsize=8192

Sunday, April 19, 2009

Using True Type Fonts with Ubuntu

My wife does a fair bit of crafty stuff, and often finds weird and wonderful fonts to use with her creations. Often they're Windows TTF font files, which aren't linux native.

I simply get her to copy the fonts into a particular directory, and then run the following script.

sudo cp *.ttf /usr/share/fonts/truetype/username/
sudo cp *.TTF /usr/share/fonts/truetype/username/
mv *.ttf /home/username/Fonts/installed/
mv *.TTF /home/username/Fonts/installed/
sudo fc-cache -f -v
You can get all the bacground and other information you'll need in this article on the Ubuntu Wiki, which is where I got a lot of the info for this post.

It simply copies the files into a folder I created to hold installed TTF fonts, (/usr/share/fonts/truetype/username/) which will work for everyone, and then move the filed from the "todo" folder into a backup folder for reference. ( /home/username/Fonts/installed/ )

You'll have to restart any apps (Such as open office) to see the new fonts, but there's no need to log out or reboot.

Note, I commented on this issue a while back, here's the previous post.

Wednesday, February 18, 2009

Ubiquity

I've been playing around with Mozilla labs ubiquity plug in in recent weeks. It's still in beta, and far from fully featured, but even so it's quite impressive.

Tonight I was reading comments on a boing boing post where a few of the commenters had used ROT13 to obscure spoilers. There are plenty of good sites to do the conversion for you (I'm too old/lazy to do that sort of thing in my head these days) but I thought to myself that this would be a perfect for for a ubiquity command.

I know the world isn't really crying out for a ROT13 utility, but I thought it would be a good way for me to test the waters in writing some browser code. My javascript-fu is far from strong, but it was surprisingly easy. I spent far more time futzing about with publishing it than I did writing the code itself.

You can check out my notes here. Even if you've no interest in my almost embarrassingly trivial utility, check out ubiquity for it's own sake. If you're a power web-user, you won't regret it.