Wednesday 28 January 2015

Glyphicon frustration

One of those "banging my head against a brick wall" days at the keyboard.
The problem, I was implementing a boostrap carousel which decorates the internal links with glyphicons. Glyphicons are a woff font type, referred to by the CSS. 
When viewed using Chrome or Firefox, the glyphicons were not diplaying properly, but being replaced by standard characters. (Gnome's own browser showed the glyphicons correctly, proving that my resources were correctly linked to etc..)







When I googled such terms as "glyphicons not displaying correctly" I got a tonne of hits. It turns out that there are a few reasons why these delicate little icons are not displayed. This stackoverflow question shows a variety of fixes, but none of the solutions there made any difference to my situation.
So my issue was not a missing fonts folder, file permissions, mime types etc... My problem was down to the fact that my apache web server I was serving the css from a subdomain of my site, and chrome and firefox have recently become picky about this if the server doesn't specifically allow it.
I found this out by looking at the Chrome Browser web developer extension (network -> console).


Font from origin 'http://static.highlandbrass.org' has been blocked from loading
by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header
is present on the requested resource. 
Origin 'http://highlandbrass.org' is therefore not allowed access.









There are numerous ways to fix this problem, but for me the cleanest was to enable mod_headers for apache2, then tweak the conf file for the site.


sudo a2enmod headers


Then edit the conf file for my site /etc/apache2/sites-enabled/highlandbrass.conf

<VirtualHost>  # for static.highlandbrass.org
       Header add Access-Control-Allow-Origin: http://highlandbrass.org
</VirtualHost>


Reload the server


sudo service apache2 reload


Job Done!




Monday 25 March 2013

Techup Inverness

So tonight I am attending my second techup meeting. A rare chance for me to socialise (non-virtually) with real geeks.

In preparation, I am making a list of the techy things I have been doing since the last meeting a month ago, something I have never really done before.

  1. My first django powered website. Running as a wsgi script on apache on my VPS.
  2. IPv6 compliance for all my websites.
  3. My first arduino project.
  4. Made a case for my raspberry pi.
  5. A dual boot win8/debian wheezy onto a new laptop (uefi install using linux foundation secure boot shim).
  6. Steam install onto my son's fedora 18 box.
  7. Fresh install of Ubuntu 13.04 onto my daughter's pc (which was bought with ubuntu 8.04 installed, and has migrated step by step to 12.10.. but was gettings a little 'confused' in a few ways).
Very little direct work on openmolar though, although the django stuff is aimed at rolling out online appointment system for patients to use.


Monday 18 February 2013

Google (android) stores wifi passwords "in the cloud"


2 months ago I bought a Nexus 7, and laboriously entered my 63 character wifi password.
Today, I brought my shiny new nexus 4 into work.
Guess what? It connected automatically.

Convenient, sure, but a massive step too far IMHO, I trust no one with my wifi password, yet google have it in their database.

BTW - I know realise this is not new, I find blog posts about this dating back to 2011.

Thursday 20 December 2012

My Blog Stats

One nice feature of blogger is the stats page. It gives a nice summary of viewer activity.

Here's mine captured today.

USA > UK > Germany.

59% are windows users.
28% are marked as "linux" (whatever the heck that means).

and chrome > firefox.

Interesting.

Wednesday 19 December 2012

Python, PyQt, Qt and windows - legal issues

I write GPLv3 applications using python and pyqt4, and by association Qt.

I build binaries mainly for Debian based gnu/linux distributions. Consequently, I let the mighty apt take responsibility for a valid python and pyqt environment. Up until now, therefore, I am simply distributing my own code.

Recently, however, I have been playing with creating packages for windows. Using Pyinstaller I can build executables which pull all my python and qt dependencies and roll them into either a single folder, or even a single *.exe .

These give me cause for concern however, as these standalone executables contain several files I believe I am unlicensed to redistribute. Those files come from 2 sources.

  1. microsoft themselves.
    • Microsoft.VC90.CRT.manifest
    • msvcm90.dll
    • msvcp90.dll
    • msvcr90.dll
  2. and pyqt/qt stuff (see below for full list)

In conjunction with Wix I can go even further and create an *.msi package which helps for clean installation, removal and upgrading of my application. I believe most application developers using these very same tools on windows simply do exactly this and don't care about the legal and moral issues here. I, however, am not content to do this and believe I need to find a way to comply with the licensing terms of microsoft, qt and pyqt4.

I believe one possibility is to write a separate application in conjunction with the Wix installer to emulate apt and install those components separately.

I would welcome comments from anyone who has addressed this problem.

Here are the files produced by one particular (non-trivial) PyQt4 application of mine.
$ ls -lR rotagen/
rotagen/:
        71680 Jul  4  2010 bz2.pyd
      1019904 Oct 20  2010 LIBEAY32.dll
         1857 Nov  7  2007 Microsoft.VC90.CRT.manifest
       224768 Nov  6  2007 msvcm90.dll
       568832 Nov  7  2007 msvcp90.dll
       655872 Nov  7  2007 msvcr90.dll
       266752 Nov 11  2010 phonon4.dll
      1594880 Dec 24  2010 PyQt4.QtCore.pyd
      5670912 Dec 24  2010 PyQt4.QtGui.pyd
       468480 Dec 24  2010 PyQt4.QtNetwork.pyd
       304640 Dec 24  2010 PyQt4.QtWebKit.pyd
      2286080 Jul  4  2010 python27.dll
      2238464 Nov 11  2010 QtCore4.dll
      7943168 Nov 11  2010 QtGui4.dll
       891392 Nov 11  2010 QtNetwork4.dll
       674816 Nov 11  2010 QtOpenGL4.dll
       276480 Nov 11  2010 QtSvg4.dll
     10843136 Nov 11  2010 QtWebKit4.dll
       339456 Nov 11  2010 QtXml4.dll
      1009069 Dec 16 11:10 rotagen.exe
          730 Dec 16 11:10 rotagen.exe.manifest
        11776 Jul  4  2010 select.pyd
        66560 Dec 24  2010 sip.pyd
       209920 Oct 20  2010 SSLEAY32.dll
       688128 Jul  4  2010 unicodedata.pyd

    rotagen/include:
         21451 Dec  6  2009 pyconfig.h

    rotagen/qt4_plugins:
        
        rotagen/qt4_plugins/codecs:
         141824 Nov 11  2010 qcncodecs4.dll
         167936 Nov 11  2010 qjpcodecs4.dll
          77824 Nov 11  2010 qkrcodecs4.dll
         155136 Nov 11  2010 qtwcodecs4.dll

        rotagen/qt4_plugins/graphicssystems:
         14336 Nov 11  2010 qglgraphicssystem4.dll

        rotagen/qt4_plugins/iconengines:
         36864 Nov 11  2010 qsvgicon4.dll

        rotagen/qt4_plugins/imageformats:
          26624 Nov 11  2010 qgif4.dll
          28672 Nov 11  2010 qico4.dll
         196096 Nov 11  2010 qjpeg4.dll
         220672 Nov 11  2010 qmng4.dll
          22016 Nov 11  2010 qsvg4.dll
         284672 Nov 11  2010 qtiff4.dll

Batch Converting Video for Nexus7 with ffmpeg.

The title says it all, I have a folder of videos, and want to have them play on my Nexus 7 Android device.
In other words, I want to be able to do this:-

~$ cd Videos
~$ somescript *.avi|*.mov|*.mpeg

then go to bed and wake up with nexus 7 supported files.

Here is my version of that script.
#! /bin/bash

############################################################
# script to convert video files to nexus (android) devices #
############################################################

HELP="\n
This script will convert video files to the preferred format for android devices\n
It uses ffmpeg to do a 2 pass encoding.\n
See http://patdavila.wordpress.com/2010/03/10/re-encoding-mythtv-recordings-for-viewing-on-your-android-phone/\n
\n
EXAMPLES\n
convert quicktime movies\n
~$ ./android_video.sh video_file.mov\n
\n
convert mpgs\n
~$ ./android_video.sh video_file.mpg\n
\n
convert avis\n
~$ ./android_video.sh video_file.avi\n
\n
wildcard use is supported, and unique filenames for the output 
videos should ensue by simply prefixing .mp4\n
eg.\n
~$ ./android_video.sh *.avi\n
"

 
function show_help {
    echo -e $HELP
    exit 1
}


convert()
{
 SRC=$1
 DEST=$1.mp4
 
 ffmpeg -i $SRC -aspect 16:9 -s 800x480 -vcodec libx264 -b 480k -r 13 -acodec libfaac -ab 128k -sameq -pass 1 -f rawvideo -an -y /dev/null && \
 ffmpeg -i $SRC -aspect 16:9 -s 800x480 -vcodec libx264 -b 480k -r 13 -acodec libfaac -ab 128k -ac 2 -sameq -pass 2 $DEST
}

if [[ "$1" == "" ]]
 then
  show_help
fi

while [[ "$1" != "" ]]; do
 convert $1
 shift
done

exit 1

Saturday 10 November 2012

mythtv 0 byte recordings

there seems to be a problem going around where mythtv is failing to record shows (on DVB tuners) and recording that the show HAS been recorded, but with a zero byte file size.

I have had this happen on my machine, which is currently running mythbuntu 12.10 64 bit.

When it happens on my machine, further recordings and live tv all fail too.
A quick google gives me the following impression.

  1. This seems to happen when folks have multiple DVB tuners.
  2. setting "quick tuning" to always may help.
  3. altering the vmalloc of your kernel may give the DVB cards more headroom? (perhaps multiple tuners, along with nvidia graphics blobs can quickly use up the default 128M?)

so, as I am in category 1, I have tried fixes 2 and 3. incidentally, fix 3 should be done in this manner for most grub2 based distros.

sudo nano /etc/default/grub
change the line which looks this (you may have other options already like splash)
GRUB_CMDLINE_LINUX_DEFAULT="quiet" 
by appending vmalloc=512M ie..
GRUB_CMDLINE_LINUX_DEFAULT="quiet vmalloc=512M" 
then save & run
"sudo update-grub"

I've done this.. I'll let you know if it doesn't work (might be 2 weeks before the next program is missed, and I'll bet it is my wife's favourite gardening program again)

Tuesday 23 October 2012

MySQLdb Gotcha!!

I pushed a relatively minor upgrade to my openmolar program today to find it broken on the debian squeeze boxes I use in the surgeries here.

"What happened?", you may ask.

Consider this (python) code.
import MySQLdb
db = MySQLdb.connect(db="openmolar", user="academy", passwd="XXXXXX")
cursor = db.cursor()

query = '''INSERT INTO notes (ndate, serialno, note)
           VALUES (DATE(NOW()), %s, %s)'''

values = ((1, "hello"), (1, "world"))

cursor.executemany(query, values)
this code works with python-mysqldb 1.2.3 (on debian wheezy), but not python-mysqldb 1.2.2 (debian squeeze). the error I get is
TypeError: not all arguments converted during string formatting
it seems that being able to include MySQL functions (ie. the DATE(NOW()) bit) in the values tuple is only recently supported. what is surprising, however, is that this can be done with single executions.. eg.
cursor.execute(query, (1, "hello"))
Obviously, this is not consistent behaviour, and has been fixed in the current release, but it does demonstrate a hazard for developers who target various gnu/linux distros. (yes, I know I should have a test suite... ) FOLLOW-UP - I looked into the python-mysqldb sources, and found the culprit to be an improved regex lookup introduced in cursors.py

Wednesday 22 August 2012

openmolar2 - update on progress

I've been asked to give an update on openmolar2, and where it is at.

I am very, very happy with progress, to be honest, although I realise that it is presently a set of libraries, rather than a useable set of applications.

Here, however, are some screenshots which should give some indication of what I have been playing at.

OpenMolar version2 is very different from the "rushed by necessity" openmolar which I still utilise daily in my practice. It has 3 components. A server management tool (a daemon running on the same unix machine as the postgresql server), an administrative application, and a client.

Here are some screenshots.

More information at The project homepage.

So this is the startup page for a configured admin application. It is configured to report on three openmolar servers, and has connected to 2 of them.
One important thing of note.. The admin application can tell you exactly who is connected, and their IP address (or "None" for a unix socket.. I need to fix that!)

Populating a new database with demo data.
Exploring/Editing the tables of that database.


Making a Query on that database.




And finally... using the client application for a graphical view of a (fictitious) patient's data.

Friday 27 July 2012

Configuring Reprepro for apt-file

I use reprepro to manage my debian/ubuntu repos.
I noticed, however that apt-file search didn't return results.. so what had I confgured incorrectly?

answer (provided by Daviey from the Ubuntu UK Podcast).
I needed to add the following line to each distribution in conf/distributions.

Contents: .gz

after that I ran "reprepro export" to update the indices. Job done.

Now to test it.

~$ apt-file update
~$ apt-file search createdemodatabase.py
openmolar-orig: /usr/lib/python2.6/dist-packages/openmolar/createdemodatabase.py
openmolar-orig: /usr/lib/python2.7/dist-packages/openmolar/createdemodatabase.py
openmolar-orig: /usr/share/pyshared/openmolar/createdemodatabase.py

Whoopee!!

Wednesday 25 July 2012

Sikuli.

Sikuli is really cool.

http://youtube.googleapis.com/v/FxDOlhysFcM

could be a good way to write gui tests?

Saturday 21 July 2012

Low Carb Experiment

Wondering if I'll regret posting this. Probably. But here goes.

For the last 3 weeks I have been experimenting with a very low carbohydrate lifestyle.
No sugar, refined starch (bread rice potatoes). 

And I have just weighed myself.
I am 83kg.

I was 88kg three weeks ago, and have been consistently around that weight for about 20 years (with the exception of when I was training very heavily for the world masters rowing event in 2005, when I was down to 83kg.).

Conclusion - for weight loss, and for me as an individual, a low carb diet is very effective.

However, I am pleasantly surprised by some other observations.

I no longer fart. Haven't "bottom burped" in days. For anyone who knows me well enough (perhaps to have shared a long car journey with me) you will know that is quite unusual.
My Urine is almost completely clear, and totally odourless.

TMI? sorry.

(I also have less back pain, feel less tired, and have fewer hayfever symptoms, but all that could be placebo, or due to the recent holiday in Corsica)

So my conclusion is that something in my "regular" eating habits does not agree with me. Gluten perhaps?

I have now to decide what my eating habits are going to be for the rest of my life. One thing is for sure, I am going to be VERY careful in re-introducing those foodstuffs.

And that, hopefully, is good news for my passengers ;)


if you are still reading.. my inspiration to try this was the experiences of computer scientist Steve Gibson of grc.com , and the following resources.

Book. (an extreme view in my opinion)
http://www.amazon.co.uk/The-Science-Carbohydrate-Living-ebook/dp/B005CVV2AE

Nutrition podcast. (very, very sensible tips)
http://nutritiondiva.quickanddirtytips.com/

Saturday 16 June 2012

Root partition space needed

Using pbuilder to target 5 distros (unstable, testing, stable, precise, lucid), and using apt-cacher to speed the process up, I'm running out of room on a drive parition (lots of stuff in /var/cache!). Going to create a separate var partition. If I am away for some time, this has gone badly.

Thursday 14 June 2012

Facebook is shit.

2 weeks ago, at a Rotary Club meeting, fellow Rotarian James Martin convinced me that social networking had a place for all businesses. So, over the last 2 days, I revisited facebook with a view to maintaining a presence there for my dental practice. Here are my thoughts (the title is a synopsis).
  • IRC is better for casual social banter with like minded people.
  • twitter is better and less intrusive for knowing what folks are up to.
  • A self-published website is much better for fine control over your web presence, if you can't be bothered with the amount of work, something like blogger provides a very good alternative.
  • For video and photo hosting, many better alternatives again.
  • Old school Newsgroups and mailing lists are better for the argumentative type of discussion.

So what's so bad about Facebook?

I can't avoid it.
It is second rate in all of the above, but makes all this useable by totally non-techie types, some of whom I actually quite like. Worse though, is the "app extensions" where noise from outside (such as my daughter's school feed) which puts non-authored, non referenced, and simply PLAIN WRONG opinions out as if they are hers. I can't stand it when someone is WRONG on the internet and I can't personally flame them. Damn my OCD.

Wednesday 16 May 2012

PyQt4 and audio playback with phonon

So today I wanted to try and use PyQt4 to play music. I couldn't find an example.. so here goes. first.. you need some obscure(ish) dependencies.
~$ sudo apt-get install python-qt4-phonon phonon-backend-gstreamer
then the following code should work. (choose your own music file of course!)
import sys
from PyQt4 import QtCore
from PyQt4.phonon import Phonon

app = QtCore.QCoreApplication(sys.argv)
app.setApplicationName("my_player") #phonon useage requires an application name

m = Phonon.MediaSource("/home/neil/Music/pop/ABC - All of My Heart.mp3")
obj = Phonon.createPlayer(Phonon.MusicCategory, m)
obj.play()

app.exec_()