Saturday, June 27, 2015

Mac Backups With Rsync to Encrypted Flash Media

Backup Woes

The main advantage of using a Mac is that it defaults to idiot mode and the main annoyance with a Mac is that it defaults to idiot mode, but underneath it all there is BSD...

The Mac Time Machine backup utility is one such idiot application which is probably fine for a large number of people,  but which doesn't fit my usage scenario.  Coupled with the Disk Utility which makes it hard to format a Flash Memory Device properly, it is even worse.

I want to make backups to USB and SD memory devices, since they are small, solid state and convenient.  However, to make a proper backup, the device should be formatted with HFS+ and it must be Encrypted.  The Disk Utility defaults to the prehistoric FAT in order to support file exchange with legacy Windows machines and FAT doesn't support proper file ownership and permissions.

Also, it is rather self defeating if your HDD is encrypted, while your backups are in plain text on a FAT disk.

Format a Removable Disk with HFS+

  • Run Disk Utility
  • Select ‘1 Partition’ from the Volume Scheme menu.
  • Enter a name eg MACBACKUP1
  • Select Mac OS X Case Sensitive Extended (Journaled) from the Format menu.
  • Click the ‘Options’ button and select ‘GUID Partition Table’ 

 Enable File Ownership Data

  • Right click the flash drive and select ‘Get Info’.
  • Click the lock icon in the bottom right corner.
  • Remove the check mark from ‘Ignore ownership on this volume.

Encrypt the Flash Disk

  • Right click the disk icon and select Encrypt.

Backup with Rsync

Now finally, the media is ready to be used for a secure backup.  Time Machine works if the media is formatted this way, but it defaults to backing up everything and a Flash Disk is usually too small to backup everything.  Also, there is no point in backing up the whole system, since one can download a new system from Apple.  I only need to backup my Documents folder - everything else is expendable.

Make a file called called /Volumes/MACBACKUP1/sync
Make a directory called /Volumes/MACBACKUP1/bak

Edit the sync script with vi:

#! /bin/bash
rsync -avz --progress --delete --max-delete=10 --max-size=20M ~/Documents /Volumes/MACBACKUP1/bak

Make it executable with chmod +x sync

By selecting a max-size of 20 Megabytes, I exclude things like large archives and ISO images.  Deletions are limited to ten files, in order to prevent a possible disastrous delete of the whole backup set, following a local delete disaster.  The result is a 51 GB backup set, which fits on a 64 GB memory schtick - nice.

Now, you can insert the backup device and click the sync script to backup whatever should be backed up to that device and thereby backup Documents to a USB schtick and backup Pictures to a SD card for example, while having it all secure and encrypted, in case the flash thingy gets lost or stolen or copied by the NSA/CSIS/GCHQ/FSB...

La voila!


Friday, June 26, 2015

An Angel Dancing On a Pin Head

Magic Eye Indicators

As a little child, I found the green angel wings indicator on my parent's Philips radiogram fascinating.  I sat and watched and wondered how it worked each time we played a record.

So, let's add a little dancing angel to my 20 Watt audio guitar amplifier:

Why the blazes does it take three obscure keys (Cmd, Shift, 4) to do a screen grab on a Mac?  
Whoever thought that up needs to get three lashes with a wet noodle.

You can get your own dancing angel from Tubes Store in Chelyabinsk:

Basically, it is a miniature cathode ray tube with a curved zinc sulphide fluorescent screen.  The electron beam is deflected by an electrostatic target in front of the screen, powered by a built-in triode amplifier, so everything you need (minus the PSU) comes in one convenient glass package.  Some indicators are viewed end on making a cat's eye circle, others from the side, like this one.  If you already have a thermionic valve amplifier, then hooking a volume indicator up is easy.

As always with any electronic device, the biggest problem is finding the pin-out.  It has the usual triode valve elements: Heater, Cathode, Anode and Gate, but with an additional Screen, behind a Target (deflector).  So you can use the triode part as an amplifier to power the target, which controls the size of the shadow and width of the wings, thus making quivering angel wings on the screen.

The 6E1P / EM80 is super simple, since the Target and Anode are connected together internally, so you don't have to:
  • Pin 1: Gate
  • Pin 2: Cathode
  • Pins 4, 5: Heater
  • Pin 7: Anode
  • Pin 9: Screen 
Viewed from the bottom pin side, the pins are numbered clock wise, starting at the gap on the right.
These devices used to be manufactured in Martin in Slovakia and in Moskow in Russia and were licensed copies of the Philips tubes from the Netherlands.  Contrary to Old Skool American propaganda about the 'iron curtain', there was a lot of co-operation and trade between Western Europe, Central Europe and the Soviets - same as today.  My father in law was a Slovakian truck driver and crossed the fortified border to Austria regularly.  There really wasn't much difference between the villages on either side of the border and everyone watched the same TV channels, but blue jeans were in short supply.  Any Slovakian teenager with a pair of jeans was 'waaay cool' and my wife can still remember how she showed off when she got her first pair.

Unfortunately, I could not see any clear indication of exactly where my angel tubes came from, but the Russian lettering shows it was one of these two factories, since Philips would not print their tubes in Cyrillic.

Here is an amusing old Rusky circuit:

As with all tubes, the voltages are not very critical.  A tube can run on anything from 100V for a miniature, to 250V DC for a big fella.   Somewhere in the middle at about 150V is perfectly fine.  Similarly, the heater is rated at 6.3V AC and anything between 6 and 7 V RMS is OK.  So don't worry much about the power supplies - if it works, it works...

To make you little angel dance, simply put an AM envelope detector on the Gate, heat the Cathode, Bias the Anode, keep your fingers away from the high voltage parts and Bob's your uncle!

BTW, it may be a good idea to put a rubber mat on the floor in your workshop.

Zzzappp! Owww!!!

Saturday, May 23, 2015

Freethought vs Thinking Machines

Artificial intelligence in computing always seems to be beyond the horizon.  The abilities of Google Search, Apple Siri and Microsoft Bing would have looked like successful artificial intelligence to someone in 1980 (I know, because I would have thought so!), but the goal posts keep shifting out. We always expect more.

Artificial intelligence is now used against human dissidents.  The NSA and GCHQ are using enormous computers to troll the networks and sniff out supposed terrorists.  There was even news that Russian systems use social network data to predict who are likely to be future trouble makers.

This is all due to a recent shift in policing from crime prosecution, to crime prevention.

"Cogito, ergo sum"
-- Descartes

In the interest of crime prevention, the bar has been lowered and to me, the really disturbing thing is not that these immature children are supporting terrorism - they have no clue what it really is - but that they are being prosecuted for thought crimes - they haven't actually done anything wrong yet:
26 May 2015: A 14-year-old boy has been convicted of terrorism offences in Austria, including a potential plot to bomb a railway station in the capital, Vienna.   A 16-year-old girl was facing charges in Vienna on Tuesday of supporting IS.

What have we become?  Should we really prosecute these children, or should we prosecute their parents?

"Prudentia est enim locata 
in dilectu bonorum et malorum officium"
-- Cicero

It is a fine line that we need to preserve between order and anarchy, dogma and freethought.  Now we also need to give thought to computers, devices with no wisdom or sense of morality, passing swift judgement on us.

Whereas we used to prosecute criminals
 for things they have done,
We now prosecute people for things they are thinking of, 
but haven't actually done yet,
and soon, 
we may be prosecuting people for things
 they haven't even thought of doing yet.

Maybe one day we will be able to predict life so accurately that we can simply terminate a pregnancy proactively and avoid the whole child terrorist problem.

"Errare humanum est, 
sed in errare perseverare diabolicum."
-- Seneca the Younger.

Here, there be dragons...

Monday, April 6, 2015

RCS Calculations - Puma-EM on Ubuntu Linux

If you need to calculate the Radar Cross Section of something, then this installation guide for Puma-EM may help.

You can get Puma-EM here:

You may also need FreeCAD, Meshlab and GMSH or GiD, to prepare the mesh files:

Note that the mesh size typically needs to be about Lamda/10, which at 10 GHz amounts to about 3 mm.

Puma-EM on Ubuntu Linux


To ensure that you have a fast system, do a minimal install of the Ubuntu server edition and then add LXDE to make it more usable.

Get Ubuntu Server 14.04.2 LTS version here:

Make a virtual machine:

Create a new Virtualbox VDI VM for Ubuntu 64 bit Linux and a 20 GB dynamic disk.

Select the LTS CD image in the Storage section of the VM settings and boot.

Press Enter a few times to accept the defaults

Make a user account: user / 5uper5ecret

Some more Enters

"Guided - use entire disk" will result in a ext4 system

Write changes: Yes

Yet more Enters

If you can figure out how, install 'ssh server' and 'build-essential', otherwise, do it after installing the desktop

Type more Enters

La voila!

Reboot, then update the package lists:

sudo apt-get update

Long wait...

Now install LXDE:

sudo apt-get install lxde


sudo apt-get install --no-install-recommends lubuntu-desktop

(about 900 MB)


sudo apt-get install lubuntu-desktop

(about 1.3 GB)

...depending on how much bloat you want with your desktop.

Install the development tools:

sudo apt-get install build-essential

udo apt-get install cvs subversion git-core mercurial

sudo chown $USER /usr/local/src

sudo chmod u+rwx /usr/local/src

Install Guest Additions

Click Devices insert Guest Additions

Open in file manager

Open a terminal in /media/user/VBOX...

sudo ./

Then reboot

Configure the VM :

Enable the copy and paste buffer sharing and screen resizing features

Go to Power Savings and turn it off

Go to Light Locker and turn it off

Download Puma-EM:

Get it from here

Untar it in the user home directory

cd ~/Puma-EM/installScripts


It asks for a password once or twice and downloads and builds a lot of stuff

Long wait...

...and you should eventually reach the end of the compilation without errors.

Resolving problems:

Which Ubuntu package a missing file is in:

apt-file search missingfilename.pc

GMSH Meshing

Puma EM is designed for parametric .geo mesh files created by the GMSH 3-D mesh generator.  Most mesh utilities cannot handle big models with millions of triangles and will quickly crash and burn when you feed them an aircraft or ship surface.

GMSH can read a STP file directly and convert it to a surface mesh.  It is mainly a command line utility, but it has a kind of a GUI:

Read the tutorial before you go meshing around and wasting your time:

GMSH is easy to install since it should already be in your Linux distribution software repository:
# apt-get install gmsh

When preparing a mesh, be sure to set the maximum size to 1/10th wave length, which is about 3 mm for X-band tracking radar.

To convert a Step model into a parametric 2-D surface mesh, with maximum size 3 mm, you could try the following options:
$ gmsh -parametric -2 -clmax 3 -o output.geo -open input.stp
Obviously, if you have to mesh a whole aircraft, then this will take a looooooong time...

In my limited experience, it looks like any input file will generate long lists of inexplicable errors and warnings.  If GMSH errors out completely on a .stp file, try opening the file with FreeCAD and exporting it to a new .stp file.

Testing the .geo file is also a problem, since the only program that can display it is GMSH itself, but you can try to convert the resulting .geo file to a .stl mesh file and then open that one with FreeCAD, to confirm that the model still looks the way it should and that some pieces didn't go AWOL in the process.

GiD Meshing

Another option is GiD:   It is free for one month of evaluation use, so you can test it and see if it works on your .stp files before you buy it.  It worked for me on Ubuntu LTS 64 bit.  Do read the Readme.txt file.  Note that the evaluation version can only handle 1010 nodes.  If your file is bigger (my test STP file had over 300,000 nodes), then it will go through all the motions, but refuse to save the results.

The first thing to do after importing a .stp file into GiD, is to repair it, under Utilities, Repair Model.  It will likely fix several thousand 'errors', after which you should rotate the model and confirm that it still looks the way it is supposed to.  Now you can Generate a mesh under the Mesh menu and specify the size.

GiD could import my test STP file, but hung on my identical IGS file, so your mileage may vary.

I found that GiD crashed for mesh sizes of 3, 30 and 300, but worked for 321 and 220 (default).  So you got to experiment - it seems to have a problem with round numbers.  Therefore don't give up immediately if it doesn't work at first.   However, this left me wondering whether I should buy such a buggy program or not - there isn't anything else really, apart from the equally buggy GMSH above.

Have fun!


Friday, March 6, 2015

Travel with Computers

I used to think that one is safe against search and seizure of computers and phones at Canadian borders, but no more:

When I travel to the USA, I upload my encrypted data to a FTP server and take a Kindle with me.  The border guards can have fun with that all they like.   Now I'll have to do the same when I go home too - ridiculous.

I should be able to enter my own country without being harassed at the border!

I do think that sanity will prevail in the end, but until it does, rather mail/courier your computers and equipment to wherever you are going, or beg/buy/borrow something at your destination and travel light.

It is much the same as travel with medication - take the prescription with you and buy new medicine at your destination - and never, never, never take unidentifiable scary white powders with you.  Years ago, we had huge trouble in Paris because of a few tins of baby formula, so the stupidity is everywhere. Vive la difference....

Saturday, February 21, 2015

The Keys to the Kingdom

Apparently, the NSA stole the keys to the GSM kingdom.  It was already clear that GSM is not secure and two heads of state were annoyed by the Yanks listening in to their calls already, but this is ridiculous:

What is clear, is that the US government doesn't care how much damage the NSA causes to states and corporations the world over.  This is a Dutch/French company, NATO members and the NSA did them in to the tune of half a billion Dollars, with hardly a peep from any politician anywhere.  If your computer system is not secure, then you can lose your business thanks to the US military, whether you are an ally, at peace, at war or neutral.  With such friends, who needs enemies?

The CTO of Lenovo has now proven himself to be just as clueless as a previous CTO of Sony:

They all failed to understand that if you subvert thousands of computers, then the system is weakened and can be misused by anyone else too.  Even the much maligned DHS is on the ball on this one

Where did these guys buy their university degree certificates - maybe here

The only way to combat the spying, is to buy all your computer and networking equipment in bits and pieces from random vendors and assemble it yourself, then load it with an obscure version of UNIX such as OpenBSD.

Whatever comes preinstalled on any machine, not only from the special class at Lenovo, cannot be trusted.

Monday, February 9, 2015

Thermionic Valve Amplifier

I stumbled upon a source for some cool old stuff called Magic Eye tubes.  The shop is in Chelyabinsk Russia, called Tubes Store.

Here is a nice VU meter video:

While browsing there, I decided to make a little audio amplifier to hook to my Mac, get a couple of Magic Eye tubes to use for a VU meter (blah) or robot eyes (yes!) and some Nixie tubes for a clock or digital read-out, or goodness knows what, so I ended up buying a handful of brand new old junk.

Tubes Aglow - What a mess, but it sounds great!

Now the problem is getting high voltage transformers and capacitors that can handle >200 Volts.  Everything in my junk box is low voltage and will go pop, just like the weasel of yore.

After a little bit of head scratching, I came up with this cool little thermionic valve audio amplifier design:

It is a pretty standard push-puller, using a miniature 6N21B dual triode valve at the front end and a pair of 6E6PE power tetrode valves at the back end (It is a rough drawing, but it gives the idea - I ended up using a full wave rectifier).  This push pull circuit should be able to deliver about 20 W RMS and will make a good lead guitar amplifier.

The first bipolar transistor audio amplifier I built when I was about 12 and the first song that blared forth was Money Honey, from the Bay City Rollers.  Yeah, I'm that old...

For an output stage made from bipolar transistors, one can use NPN and PNP power transistors, but all valves are the same, so a transformer is required to make a complimentary output.  It is also required to transform the impedance down to drive a low ohmage speaker - about 6000:1.

The second audio amp I built was a monster - a 600 Watt RMS bipolar transistor bass guitar amp - and the first song that thundered out of that one at 2am at night was Tie Your Mother Down of Queen.  I don't want to know what the neighbours thought of it.

Due to the high voltages, I used big 2 W metal film resistors, except for R5, R8 and R20, which I made 10W wire wound.   The capacitors should all be 250V or higher rated, to keep them from going pop.

When I finally turned up the volume on this little tube amp, the first song that came out of the speaker from my Mac tuned to Antenna Bayern, was - wait for it - drum roll...  Music Was My First Love of John Miles - really!

Bluetooth Audio

I'd like to have both a wired and wireless interface.  It may be an old fashioned amplifier, but it is the 21st century after all!

Sparkfun sells a Bluetooth Audio interface module

Improvising and Bread Boarding

Now where on earth can I get transformers for the 6.3V heaters and 160 V anodes?  One could use an automotive ignition coil for the audio output transformer (10,000:1) and a couple of low voltage transformers back to back for the heater and high voltage power supply, but it turned out that there is a manufacturer of replica guitar amp transformers in Canada, Hammond Manufacturing, eh...

The prototype is built on an olde skool wooden bread board.

The Hammond classic audio output transformer should sound better than a car coil.  Well, I hope - at least it will look better:

and one can get high voltage electrolytic capacitors from Digikey:

Next time I walk past a Pakistani trinket store down town, I'll pick up an old fashioned wooden box to put it in. I saw a replica His Master's Voice wind-up record player the other day - that store will have something.

So, it is no problem to build a new old toy today, but it ain't cheap.  Shipping transformers and high voltage parts halfway around the world is expensive.  I guess my little amplifier will cost about $300 when it is all done.


I finally ordered the transformers.  It turned out to be easiest to get them from Mouser and instead of getting a multi-winding valve amp power transformer, I got separate transformers for the heaters and anodes (as in the schematic!) - easier that way. Mouser does stock a Hammond Fender replica power transformer, but it is 115 V only - while I live in UAE with 240 V mains supply.

Therefore I got a Hammond 185C230 for the anode voltage:

Primary 230 V:
Connect in series
.1, 6 = 230 V mains
2, .5 = Short

Secondary 115 V:
Connect in parallel
12, 8 = Short
.11, .7 = Short

Since the secondary was paralelled and not centre tapped as in the schematic above, I then built a four diode full wave rectifier instead.

A VPS12-2000 is used for the heaters:

Connect in series
.6, 1 = 230 V mains
5, .2 = Short

Connect in parallel
.12, .8 = short
11, 7 = short

The audio transformer I settled on is the Hammond 1750H:

.Blue / Brown = 6600 Ohm
Red = Centre Tap

.Black, Brown = 8 Ohm

Note that you must never run a valve amp without a load - the output transformer will arc and destroy itself.  I mounted a large 10 Ohm 25 Watt resistor on the bread board next to the output transformer to use as a dummy load.

Let me say that again: Never run a valve amp without a load!

I'll get a 6 inch full range car speaker pair at Lulu or Carrefour and stick it in an old fashioned wooden box from my new found Pakistani friend downtown.

Also, do put a fuse in the mains line.  I used a 150 mA, 600 V polyfuse, 600R150-RBZR and most important, solder a couple of 1 Megohm resistors on the outputs of the high voltage PSUs to bleed the capacitors when nothing is connected, else you may be in for a surprise one day.


Both types of valves have 9 pins.  The power valve has a gap between pins 1 and 9 as usual.  Viewed from the bottom pin end, the number sequence runs clockwise.

The old yellowed Rusky data sheets are hilarious.

When I first met my wife (she is Slovak), I had a red hammer and sickle T-shirt (made in Honduras - where else?).  So she asked: "Where you get that shirt? You look like Russian athlete!".  Now I'm building toys from parts really made in ze olde CCCP, decades after everyone else stopped making them.  The commies were good at making things, but sometimes a bit slow in keeping up with advances.

The 6E6PE tetrode valve pin-out is as follows:

1 - k
2 - g1
3 - k
4 - h
5 - h
6 - k
7 - a
9 - g2

The pre-amp miniature dual valve is funny and has a gap between pins 6 and 8, just to be confusing.

The two triodes have a shield between them - you have to ground it. So this is a nice, compact, low power design with only three glass tubes, but four valves. Because the double triode is physically small, the operating voltage is lower than normal at 'only' 100 V.  This works fine, since in a simple valve amplifier design, each stage is isolated from the other with a power line RC filter.  

In this design, I drop the voltage from 160 V to 100 V using a 330 Ohm series resistor R8 and stabilize it with the capacitor C4.  This prevents voltage sags caused by the output stage, from feeding back into the input and reduces distortion.

The 6N21B miniature dual valve pin-out is as follows:

1 - k1
2 - s
3 - g1
4 - a1
5 - h
6 - k2
7 - no pin
8 - g2
9 - a2
10 - h


Valve Sockets

One can still buy new octal sockets.  They are manufactured for relays.  However, all the tubes I got have 9 or more pins, so that is no help.  I could make a plan with some D-sub connector sockets - they look like they will fit - but the Tubes Store also has ceramic sockets and they don't cost much.

You have to mount these things on a metal plate - and remember to ground it or you will get zapped sooner or later - likely sooner.  A cookie tin or bread pan is good, but do get an aluminium one, since steel is awfully hard to work by hand.  To make odd shaped cut outs, I use a Nibble Tool from Digikey:

The advantage of a nibbling tool is that it doesn't deform the sheet metal - it stays straight and flat - and you can cut any shape hole you need.  The disadvantage is that it is slow and painful to use.  Wrap some tape around the handles...

The double triode presented a problem, since it doesn't fit in a socket.  It has long thin wires.

I soldered it into a 1 inch square circuit board, leaving some space for heat dissipation and fashioned the wires into little eyelet loops at the bottom so I can wire it up to the rest of the circuit in the same way as with tube sockets.  Time will tell whether this was a good idea or not.

Terminal Strips and Turret Boards

These old fashioned high voltage solder tag strips are hard to find, but Digikey and Mouser do have them, if you know to search for 'turret boards'.

For hooking the parts up, you need 22 AWG tinned copper wire, which is unhelpfully named 'bus bar wire' by the vendors.  It is available in little 100 foot rolls.  Don't use 'magnet wire' - well, you could if you are a masochist.  Magnet wire is insulated with epoxy or nylon which is very hard to strip.

I'd recommend that you build the PSU first and when you are ready to test it, put a carboard box over it, before turning the power on, to contain the mess if something would blow up.   When I was a teenager, I built a 600 Watt bipolar transistor bass guitar amp and had a very big capacitor blow up in my face - it wasn't much fun - fortunately I was wearing glasses and I've been been rather more careful ever since.


When you wire things up, always use the big capacitors as star points for power and ground - don't daisy chain.  That keeps the voltage sags and distortion down.

Also make a massive star bundle of about a dozen long thin earth wires that you can later use to ground all the metal parts, transformers and chassis and twist around sensitive wires leading to the volume and tone controls and gate of the first triode.   You don't have to use screened wire - just twist an earth wire around a signal to protect it.  After the first triode, the signal is amplified enough that noise pickup won't a problem any more.

While the prototype sure looks messy, by tediously using a star grounding system throughout, I had no hum, no motorboating, no howling or squealing, no noise, just pure sound - purrfect.

 No noise - Just pure audio.

Note: Disconnect the ground wire of your oscilloscope.  If the scope is floating, then you cannot short things out with the ground clip and you can measure floating and differential signals directly.  I always gets annoyed when someone takes my scope power leads and that idjit then ends up with a Darwin Award ungrounded lead...

The missus prolly won't like having a Carrefour breadboard full of hot and sizzling high voltage parts in the living room - so once it is working, then one got to unscrew the terminal strips and valve sockets, lift it off the bread board and re-install the unholy rat's nest into a fancy looking box, so make sure that you mount the sockets from the under side, unless you want to re-solder everything...

Once all is working again, clean with alcohol and spray the electronics (not the power resistors and tubes!) with V-66 or similar conformal coating to keep it from corroding and it will keep working and look nice for years.