One liner shell script to copy 500 random songs onto a USB stick or player

[/mnt] # find /home/music/ -name *.mp3 | shuf | head -500 | while read f ; do cp -v "$f" /mnt/; done


USB DAC Sound Card on Debian

On Debian by default when you plugin a USB DAC (Soundcard), it does not become the default audio playback device which is not particularly useful. 

To change the default soundcard or more correctly the playback hardware device, you need to edit the ALSA config file eith in the user home directory ~/.asoundrc or globally in /etc/asound.conf.

First find out the names of the soundcards available on your system with the aplay command. 

[~] # aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Generic [HD-Audio Generic], device 0: ALC887-VD Analog [ALC887-VD Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 1: ALC887-VD Digital [ALC887-VD Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: M2496 [M Audio Audiophile 24/96], device 0: ICE1712 multi [ICE1712 multi]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: HDMI [HDA ATI HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: DAC [USB Audio DAC], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I want to use my USB Audio DAC, which has the name "DAC".

This is my ~/.asoundrc

pcm.!default {
    type hw
    card DAC

ctl.!default {
    type hw
    card DAC

To test the sound is now coming out the correct device you again use aplay. 

[~] $ aplay /usr/share/sounds/alsa/Noise.wav
Playing WAVE '/usr/share/sounds/alsa/Noise.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono


Verbatin V3 MAX 32GB speed test

Looking for a fast USB drive to use on my Chromebook, which only has USB2, I came across what appears to be bargain "fast" USB3 drive from Verbatim. Claimed transfer is 175MB/s on USB3, of course you will not get this on USB2 but I was hoping it would comfortably max out the USB2 limits. 

Here are the results:


On my HP laptop:

[~] # hdparm -t /dev/sdb

 Timing buffered disk reads:  96 MB in  3.03 seconds =  31.69 MB/sec

[/media/VERBATIM] $ dd if=/dev/zero of=test bs=10240 count=102400
102400+0 records in
102400+0 records out
1048576000 bytes (1.0 GB) copied, 42.0829 s, 24.9 MB/s

Which is what I was hoping for, from wikipedia the maximum USB2 throughput is  35 MB/s. 




Magento product search using a search term of less than 4 characters returns no results

With a default magento installation often searches terms for 3 character (or less) will return no results. This is how to fix it. In the Magento Admin interface:

System > Configuration > Catalog, then Catalog Search

The Minimal Query Length sets the minimum number of characters that can be submitted in a query. First make sure this is set to a value you want, in most cases 3 is a sane solution, maybe 2 if you have products with 2 letter names or codes. This is not the only setting which controls the Magento search. The most common cause of this issue is mySQL full text word length variable ft_min_word_len. By default this value is 4, resulting in 3 character words not being index and thus not being displayed in results. To change the full text word length variable to 3 add this to your my.cnf:


Restart mysql

# service mysqld restart

Finally reindex the magento catalog, you can do this via GUI or command line.

$ php magento/shell/indexer.php reindexall

After the reindex completes you should be able to search your magento store succesfully with 3 character search terms.

Using xrandr with fluxbox on a laptop or dual monitors

Recently I gave up on Mint Linux 15, the bloated slowness of the interface and unstable web browsing experience really disappointed me. I was fedup with disappointment on my desktop, previuosly being disappointed with Ubunut's Unity interface I jumped my workstation ship to Fedora. This didn't last long until I had Gnome 3 shoved down my throat. Which led me to follow the crowd to Mint. Fed up with being disappointed I went back to where I should never have left, hello fluxbox and damn my machine is responsive again.

Puppet "SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B" error

[root@test ~]# puppet agent -t
err: Could not retrieve catalog from remote server: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
warning: Not using cache on failed catalog
err: Could not retrieve catalog; skipping run

If you are running fedora 18 or newer

timezone, Europe/Prague

If you have something older

Using iperf to test broadband speed

The iperf tool is already widely used by system administrators to test and benchmark networks links. I even used it at home to work out how to layout my powerline adapters for best performance.

A less obvious use for iperf is to measure your broadband speed. Nothing wrong with web based sites like, I use them a lot and can't resist running quick test when I join a new wireless network with my phone.

Bitcoin mining on Raspberry Pi with USB ASIC Miner Block Erupter

Despite the fact it will not make any real money, I just could not resist getting one of these beautiful little USB Bitcoin mining ASICS. At the current value of a bitcoin the only one that is making money from bitcoins are people selling hardware or anyone stealing free electricity. However the whole development of crypto currency is facsinating and I consider this a very small price to pay for keeping up to date with technology.

When the Block Erupter was first available in the UK they where going for about £100, I resisted the urge and after a month got a bargain on ebay for £70 deliver from Poland. Sounds like a bargain, but when you do the maths it will be a long time before it is making me any beer money. Using the calculator with electricity 13.020p per kWh and a rough guess of 5 Watt power consumption, it is going to take a massive 1 year, 227 days to break even.

There is always the chance that the bitcoin price will go crazy again, certainly not inconceivable that it might get back to its $240 peak, but even with double or tripling of the value it is still a long haul before my little ASIC pays for itself. Never mind though, it is a nice shiny little piece of kit, gives me something to do with a Raspberry Pi and a potentially a safer bet than a lottery ticket.

Here are my install notes for getting the ASIC Miner USB Block Erupter running on a Raspberry Pi running Debian or Raspbian. The commands should work on any Debian based system including Ubuntu.

Encrypt your USB memory stick

What to feel like Edward Snowden and walk around with an encrypted memory stick in your pocket?
Use cryptsetup to create LUKS encryption on your removable media. 


Best practise for Apache Virtual Hosts


As linux consultants we often work on systems that have been configured by someone else. Some of these systems have grown into webservers with a number of websites running as virtual hosts. Depending on the level of skill and insight the original system admin had, the apache configuration files can end up a tangled rats nest. I think this stems from the apache docs for vhost, albeit being very good, not give any guidelines on best practise for managing configuration files. Leading to people editing httpd.conf, to add virtual hosts, which soon gets mangled up. To make your virtual hosts manageable, the best practise is to use configuration files in /etc/httpd/conf.d/ for everything. Do not edit any of the config files in /etc/httpd/conf/ unless you really have to. A good starting point is to use a seperate file for each website. Or if you have specific needs create seperate configuration files to define difference web services. 




Subscribe to RSS