Tips

Totaliser

%

Snake Oil

Get the latest copy of Snakeoil here

Speeding up XBMC

I have always run X-Box media centre from xbmc.org which is an amazing piece of open source software. The power, flexibility and scalability of it has blown me away. Currently the release is Frodo 12.3. Coincidently for a long time it no longer runs on the x-box unless some dirty tricks are applied, and for a long time I never even had one, but it runs beautifully on a Linux, several flavours of Windows computers and my Raspberry Pi.

The files in your library are automatically scanned by XBMC and it uses various scrappers to determine what the TV programme or film or music that the name relates to. But the rules are all straight forward and easy to follow. You can always create a .nfo file to describe the program if the file can not be found.

My main computer and the kids computers all want to watch the same films from a NAS drive (network attached storage – i.e. a disc available on your home network), and the best way to do that was to put it on a MySQL server.

That was easy enough, create a file called advancedsettings.xml and populate it with the basic data, obviously changing the host, usernames and database names to the appropriate settings for my configuration. The advanced settings file was on a windows box was under the user profile (.xbmc) either or in the home directory for a Linux box under ~.xbmc

<advancedsettings>
    <videodatabase>
        <type>mysql</type>
        <host>192.168.1.3</host>
        <port>3306</port>
        <user>xbmc</user>
        <pass>xbmc</pass>
        <name>video</name>
    </videodatabase> 

    <musicdatabase>
        <type>mysql</type>
        <host>192.168.1.3</host>
        <port>3306</port>
        <user>xbmc</user>
        <pass>xbmc</pass>
        <name>music</name>
    </musicdatabase>

     <videolibrary>
          <importwatchedstate>true</importwatchedstate>
     </videolibrary>
</advancedsettings>

Once it had loaded up with its new setting the concepts worked fine but the performance was always awful. It took 40 seconds to move between each menu and for a long time I thought this was just a problem with the size of my media library. I turned on the debugging (under advanced settings in xmbc and it appeared that the

Optimisations

MySQL

This gave massive performance advantages. As each request was actually timing out due to the reverse DNS lookup. The debug output did not give this impression, in fact it suggested the mysql server was very fast. Each time that a request was being made by XBMC to the SQL server, it looked up the name of who had made the request (Reverse DNS lookup) which it couldn’t resolve.

I solved this by ensuring all my devices running xbmc had the same ip address (using an option in my router under DHCP) and then set up a host table on the MySQL server to tell it what all the devices were called. (edit /etc/hosts and add each machines name and I/P address).

Raspberry Pi.

Use a fast usb stick or disc in addition to the SD card. Both are faster than the SD card itself.

XBMC

Under Setting -> system settings – Video Output

Put the resolution to disable 720 x 480. This only applies to the user interface and not anything you watch. By reducing this value, you are freeing up available memory.

Under Setting -> system settings – Video – File

Disable generate thumbnails – This scans each file as you preview it to find a thumb nail from the file. It massively slows down navigation.

Under Settings -> Skin settings -> Home Window Options

[Optional] Disable “recently watched”- Makes a fair performance difference on the Raspberry Pi – but I want this information so don’t disable it.

[Optional] Disable “Show Recently Added videos” – Makes a fair performance difference on the Raspberry Pi – but I want this information so don’t disable it.

Under Settings -> Skin settings -> Background Options

[Optional] Disable fan art

 

 

 

Printers

Adding a Printer / queue

Setup for Linux

Ensure you are root or sudo’ed

 

Adding Your First Printer from the Command-Line

Run the lpadmin command with the -p option to add a printer to CUPS:

/usr/sbin/lpadmin -p printer -E -v device -m ppd

or

/usr/sbin/lpadmin -p printer -E -v device -P <directory to ppd file>

For a HP DeskJet printer connected to the parallel port this would look like:

/usr/sbin/lpadmin -p DeskJet -E -v parallel:/dev/lp1 -m deskjet.ppd

Similarly, a HP LaserJet printer using a JetDirect network interface at IP address 11.22.33.44 would be added with the command:

/usr/sbin/lpadmin -p LaserJet -E -v socket://11.22.33.44 -m laserjet.ppd

 

Managing Printer Classes from the Web Interface

The Web interface is located at:

http://localhost:631/admin

 

You may need to check CUPS (Common Unix Printer Services) is installed and running

By default cups installs the following directories:

/etc/cups: Configuration directory.

/var/spool/cups/: The spooler directory where print jobs are held for printing.

/var/spool/cups-pdf: The spooler directory where CUPS-generated PDF files are held for printing.

 

CUPS also installs an executable binary in /etc/init.d/ (or /etc/rc.d/init.d) called cups. This binary is started with the command:

/etc/init.d/cups start/stop/restart

 

Create a printer on linux the hard way.

1. To create a printer called mylp for the /dev/lp1 device, open the /etc/printcap file with your preferred text editor. The sd option tells the Linux printing daemon, lpd, where to temporarily place printed (spooled) files. The mx command, used with a value of 0, places no limit on the size of spooled files. Type an entry such as this:

 

mylp:\
:sd=/var/spool/lpd/mylp:\
:mx#0:\
:lp=/dev/lp1:

2. Save the entry, and then create the printer’s spool directory by using the mkdir command:

mkdir /var/spool/lpd/mylp

3. Make sure the directory lp has the correct group ownership and permissions by using the chgrp and chmod commands, as follows:

chgrp lp /var/spool/lpd/mylp
chmod 755 /var/spool/lpd/mylp

4. Test the printer entry with the lpr (line printer command) using the -P option to specify your newly created printer:

lpr -Pmylp test.txt

5. Your printer should activate and print the test document.

 

Setup for IBM AIX

For this operation you need to be logged in as root or sudo’ed

 

run smit.

-> Print Spooling

-> Aix Print Spooling

-> Add a Print Queue

Select options

*     hpJetDirect

*     Other (Select this if your printer type is not listed above)

*     generic      Generic Printer

*     2 Do NOT make this system a BOOTP/TFTP server

Enter name of queue in ONE of the Names of NEW print queues to add – select PostScript if not sure (e.g. HP4050_QUEUE)

Enter HOSTNAME of JetDirect Card (e.g. HP4050_PRN)

Leave port 9100 as that is nearly always right.

 

Create a printer on Aix the hard way.

 

1. Add the printer to /etc/hosts

10.0.0.111 HP4050

2. Add the print queue

Option a) Generic ASCII

     /usr/lib/lpd/pio/etc/piomkjetd mkpq_jetdirect -p 'generic' -D asc -q 'HP4050asc' -h 'HP4050' –x '9100'

where ‘HP4050asc’ is the queue name and ‘HP4050’ is the host name as specified in /etc/hosts

Option b) Generic Postscript

     /usr/lib/lpd/pio/etc/piomkjetd mkpq_jetdirect -p 'generic' -D ps -q 'HP4050ps' -h 'HP4050' –x '9100'

where ‘HP4050ps’ is the queue name and ‘HP4050’ is the host name as specified in /etc/hosts

 

Lost passwords email recovery

Email spam, phishing and abuse seems to be on the rise again and there a a variety of technologies out there to try to limit it.

However various web applications and legitiamate email messages are also getting blocked. The worst recently was an email password recovery utilitity on a web site would send out an email to the user who lost there password. A message would also be sent so I could see who was requesting a password and look for abuse.

For the last 9 months or so password requests have been on the increase. This wasn’t that more people were losing them, but the same people were coming back several times trying to recover their password and not receiving the email.

Google searches for lost passwords, emails not getting through and stuff like that proved fruitless.

The problem eventually seemed to be traced to incorrect Sender Policy Frameword records. This was not something I had previously come accross. SPF records define which servers are allowed to send emails and is defined against the domain DNS management.

The SPF record is fairly simple and micosoft even provide a wizard to help create one but it simply looks like

v=spf1 ip4:a.b.c.d/ip_range -all

This calculator here works out ip address ranges nicely.

Some of the better ISPs allow you to edit and add SPF records directly on the domain management. Any changes are not reflected for 24 hours.

 

 

Photoworld on Ubuntu Linux

One of the constant complaints about running Linux at home is how difficult it is to install applications.

I was impressed to see that Photoworld did a linux version of there software. Installation was not too painful. Download a perl script and EULA in a compressed tar.

Extract it with archive manager.
Execute it from the command line with
perl install.txt

Confirm the EULA and exit it.
But once it had been install it immediately did not work.
Running it from command line told me that it could not find libgomp.so
“error while loading shared libraries: libgomp.so.1: cannot open shared object file: No such file or directory”

I checked my machine (a 64 bit installation of Linux Ubuntu 11.04) and found the file. I tried adding it to the path, copying and linking the file but all I got from my efforts were
./PHOTOWORLD: error while loading shared libraries: libgomp.so.1: wrong ELF class: ELFCLASS64

Eventually I discovered there is a 386 version of the libgomp library I needed for this application and quickly managed to solve my problems and install it with a

sudo apt-get install libgomp1:i386

Combine to avi files together

On Linux, simply use mencoder

This command says copy using existing audio codec (-oac) and copy using existing video codec (-ovc).

mencoder -oac copy -ovc copy  <file1>  <file2>  -o  <output_file>

Buffers in Vim

47618

I have been a long time user of Vim but started to get into some of the more advanced commands and one of my favourite with vim is the use of buffers and splitting the screen. Please note buffers and screen splitting functionality are only available in later versions of vim – version 5 onwards.

Buffers

You can edit multiple files simulatenously.

:e <filename> – To edit a secondary file

:ls – To list all files you are currently editting

:b<1> – To jump to a specific edited file.

:bn – To jump to the next file in the buffer

:bp – To jump to the previous file in the buffer

These last two commands are nice to place into you vim resource file to map a ctrl sequence onto the commands to quickly move between them.

Screen Splitting

Screen splitting is a step beyond and complimentary to buffers. Screen splitting allows to see the window split across the center of the current file (either horizontally or vertically) and allows you to see the currently editted file. This is extremely useful if you want to see your declarations or definition of a piece of code (especially in the same file). This is much prefered to opening a secondary file as you do not get warnings about swap files nor do you need to keep in mind where you can edit as all edits are to the same file.

<ctrl-w>  s – Split screen (horizontally)

<ctrl-w>  v – Split screen (vertically)

<ctrl-w>  c – Close current screen split

<ctrl-w>  k – Move up a screen split

<ctrl-w> j – Move down a screen split

<ctrl-w> l – Move right a screen split

<ctrl-w> h – Move left a screen split

<ctrl-w> r – Reverse screen splits

 

Screen virtual terminal emulation.

Finally as a tip – If you are working with Linux up can use the screen virtual terminal emulator. This will allow you to swap sessions on a virtual terminal

Use the command screen from a terminal session to start the virtual terminal emulator

Once running you can

<ctrl-a> c – To create a new session (no need to log in another session

<ctrl-a> k – To kill the session

<ctrl-a> ” – To list all your running screen sessions

<ctrl-a> A – Will allow you to name (title) each session

<ctrl-a> 1..9 – Will swap you to a given session

<ctrl-a> d – To detach from the session

If you detach, the screen session will continue to run, you can see what is still running with

screen -ls

then re-attach again if you are running just a single one with no session name, or just enough to make unique if more than on is running.

screen -r [session name]

 

Another use of screen permits you to run a session and let multiple users attach and work in it simulateously. This is done by running against a special resource file

screen -c .my_resource

Create .my_resource containing (for example)

sessionname <The session name>
shelltitle <The session name>

multiuser on

 

 

 

 

 

Colourful grep on aix.

1237237

Linux implements a decent version of grep and highlights the search term using colour. Whilst AIX  terminals can support colour (if your term session supports it) with escape codes I have not seen any way of making grep or egrep etc colourful.

On linux you simply add the parameter –color=auto such as
grep --color=auto SearchTerm  {files}

Well as I couldn’t find anything on google I decided to implement something. And this is what I came up with. However the one bug I didn’t manage to resolve was If searching case insensitively the highlighting will only find the correct case. As sed does not support case insensitively this is a problem to solve. If nawk or gawk is installed, they do support it with the -i parameter.


#!/bin/ksh
#************************************************************************
#                                                                       *
# Module Name : grepc.sh                                                *
# Author      : Dave Jarman                                             +
#                                                                       *
# Edit Record (most recent edit at top of list)                         *
# Date          By      CF      Comments                                *
# ---------     ---     ----    --------------------------------------- *
# 5-Apr-12      DCJ i           Use ampersand in sed search results as 
#                               matched string to better handle regular 
#                               expressions (thanks Zolo).
# 20-Sep-11     DCJ             New file                                *
#************************************************************************
#
# Executes grep but with the escape codes to colourise the output.
#
# Known Bugs:
#   If searching case insensitively the highlighting will only find the
# correct case. As sed does not support case insensitively this is a problem
# to solve. If nawk or gawk is installed, they do support it with the -i
# parameter.
#
# Other colours are available. Use the following lines.
# Blue          echo "s/$QRY/\033[1;34m$QRY\033[0m/g" > $TMP/$$.sed
# Light blue    echo "s/$QRY/\033[1;36m$QRY\033[0m/g" > $TMP/$$.sed
# Inverse blue  echo "s/$QRY/\033[44;37m$QRY\033[0m/g" > $TMP/$$.sed
# Red           echo "s/$QRY/\033[0;31m$QRY\033[0m/g" > $TMP/$$.sed
#************************************************************************
# Check for any options and save them
OPT=
while [[ $1 = [-+]?* ]]
do
  OPT="$OPT $1"
  shift
done
#
# Get the search string.
QRY=$1
shift
#
# Create a sed script to subsitiute for the appropriate colour.
# Show the search term in Blue
# echo "s/$QRY/\033[1;34m$QRY\033[0m/g" > $TMP/$$.sed
echo "s/$QRY/\033[1;34m&\033[0m/g" > $TMP/$$.sed
# echo /usr/bin/grep $OPT "$QRY" $* "|" sed -u -f $TMP/$$.sed
/usr/bin/grep $OPT "$QRY" $* | sed -f $TMP/$$.sed
#
# Clean up the tmp file                                                   *
rm $TMP/$$.sed
#
# Finish
exit 0

Canal Holiday

1351

Back from holiday on Barge. Mapped route using the great iPhone app Cycle Meter by abvio.


View Larger Map
 

Go to Top