Saturday, 8 February 2014

Update on Debian with Lenovo X1 Carbon

On my previous post, I noted that the X11 trackpad customisations. Since then I have implemented the SSD optimisation recommendations as recommended here. I'll give a summary below, where detailed notes on my configuration are here.
Firstly are /etc/fstab options to reduce writes:
# /dev/sda1
UUID=??? / ext4 discard,noatime,commit=600,errors=remount-ro 0 1
# /dev/sda5 (swap)

UUID=??? swap swap sw,discard 0 0
Next, reduce swappiness. Add to /etc/sysctl.conf
# optimise for SSD

vm.swappiness = 0
Finally, use the deadline scheduler. In /etc/udev/rules.d/60-ssd-scheduler.rules


# Only sda is SSD, see https://wiki.debian.org/SSDOptimization
# set deadline scheduler for non-rotating disks
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline"
In my case I need only do this on the sda device.
Please read my document on this as it provides extra information and links.

Saturday, 1 February 2014

Debian Linux on Lenovo X1 Carbon

I am now using a Lenovo X1 Carbon for work. After the installation hassles with the Samsung Series 9, I'm certainly sticking with Lenovo. It was such a breeze. While I had every intention to maintain the Windows 7 partition, between Lenovo and Windows they consumed all the spare volumes. If required, I can resort to Mac OS X as a commercial alternative. Besides, I have been Windows free since 1998, so have not got a valid reason to retain it. So Windows and Lenovo recovery got dumped onto an unused external hard disk. Someday, I may need to recover, but history is against it.

My notes on the installation, though thin are here. It is running Debian, with Xfce installation. The only customisation worth noting are the X11 settings for the trackpad. The custom settings used are:

#
# File: /usr/share/X11/xorg.conf.d/50-synaptics.conf 
#
Section "InputClass"
   Identifier                      "lenovo x1 carbon touchpad"
   Driver                          "synaptics"
   MatchIsTouchpad                 "yes"

   # three fingers for the middle button
   Option "TapButton1"             "1"
   Option "TapButton2"             "2"
   Option "TapButton3"             "3"
   Option "ClickPad"               "1"

   # drag lock
   Option "LockedDrags"            "0"

   # prevents too many intentional clicks
   Option "PalmDetect"             "1"

   # vertical and horizontal scrolling
   Option "VertTwoFingerScroll"    "1"
   Option "HorizTwoFingerScroll"   "1"
   Option "VertEdgeScroll"         "1"
   Option "CoastingSpeed"          "8"

EndSection

Update on Samsung Series 9

I have been using a Samsung Series 9 with Linux Mint Debian Edition for nearly two years. It is a wonderful machine to use. Crisp screen. Fast. Silent. Lovely keyboard. But it was a real pain to get working reliably under Linux. And with the reported BIOS bug you feel like on tender hooks doing a reinstall or upgrade.
I'm, however, relatively happy to report that apart from the occasional kernel panic when using USB ports it has been reliable. Now that I know it is USB sensitive, I take extra precautions when yanking out USB devices. Ensure it is properly unmounted, eject if able. Put machine into suspend mode, then yank out. A pain, but I'm more confident going the extra effort to avoid uncontrolled panics while in the middle of an edit.

I am disappointed with recent change of direction of Linux Mint Debian Edition. I like the rolling release. Having successfully implement two updates now, the process is relatively smooth. However they have abandoned the Xfce desktop as a installation choice. That will push me back to using base Debian. Which is not such a bad idea. I used Linux Mint initially due to its rolling distribution option. That this is simply a pointer to Debian testing, means I should be able to revert to Debian. More on this in a later post.

Please be sure to check my updated notes on this installation here. It has been maintained as the machine was tweaked and optimised.

Saturday, 18 January 2014

Quantum Quackery

Here is the latest quackery, Scientists claim that quantum theory proves consciousness moves to another universe at death from Robert Lanza.
This has been addressed many years ago by the respected physicist Victor Stenger in Quantum Quackery.

Here is a direct response, Biocentrism Demystified.

Figures from the UK suggest that while people are leaving organised religions, they are increasing in spiritualist organisations.

It requires constant and disproportionate effort to debunk spiritualist claims.
It is far easier to make stuff up than to convince people of their fiction.

Saturday, 9 March 2013

Samsung Series 9

Since June 2012 my primary machine has been the Samsung Series 9. It is a lovely machine to use. Great keyboard. Fabulous screen. Possibly, a too sensitive a track pad. I love the keyboard backlight, particularly if I want to do late night internet surfing! That being said, it was not the easiest of machines to build. My distribution of choice is Linux Mint Debian Edition. It is a rolling edition so at least I will not ever need to do a re-installation! In theory at least. So far so good.
There is way to much to cover in this blog about what I did to configure this machine. Instead please read my Google Drive page about this, here.

Monday, 11 February 2013

I'm Learning JavaScript!

I’ve finally learning about JavaScript after listening to the Google TechTalk, Doug Crockford: JavaScript: The Good Parts. Here are my first couple of test scripts. I’m using Rhino for runtime and JSLint (obviously) to check the code.

Through these code examples I learnt a lot, about the tools, the language and how to integrate it to do useful stuff. It is early days, but I can see JavaScript being a valuable instrument in my tool box!

Example 1 - Random Digits

Here is a simple command line script to produce random numbers from 0 to 9. The first two lines are pragmas passed to JSLint.


/*jslint indent: 4, maxlen: 80, rhino: true */
/*global java*/


// returns a semi-random digit between 0 and 9
function getRandomDigit() {
   
'use strict';
   
return Math.round(Math.random() * 9);}


// example using array
var digitName = (function () {
   
'use strict';
   
var names = ['zero', 'one', 'two', 'three', 'four',
       
'five', 'six', 'seven', 'eight', 'nine'];
   
return function (n) {
       
return names[n];
   
};
}());

// example using associative array
var getDigitName = (function () {
   
'use strict';
   
var names = {0 : 'zero', 1 : 'one', 2 : 'two',
       3 :
'three', 4 : 'four', 5 : 'five',
       6 :
'six', 7 : 'seven', 8 : 'eight',
       9 :
'nine' };
   
return function (n) {
       
return names[n];
   
};
}());

/*
* MAIN
*/
print(
'Printing 10 random digits ...');
var i;
for (i = 0; i < 10; i += 1) {
   
var rd = getRandomDigit();
   print(
'\t' + i + ') ' + rd + ' is ' + getDigitName(rd));
}


Here is an example execution of this script
$ rhino digit.js
Printing 10 random digits ...
0) 0 is zero
1) 6 is six
2) 2 is two
3) 1 is one
4) 3 is three
5) 2 is two
6) 1 is one
7) 6 is six
8) 8 is eight
9) 2 is two

Example 2 - Read an XML Document

Here I am using XPath to process an XML document.
Here is the test input file test.xml.

<?xml version="1.0" encoding="UTF-8"?>
<company>
 <employee id="003">frank</employee>
 <turnover>
   <year id="2011">100000</year>
   <year id="2012">140000</year>
   <year id="2013">200000</year>
 </turnover>
</company>

The script reads the document in three ways

  • query for a specific element meeting an attribute condition
  • show content of all nodes from a specific point
  • show the same, but this time including the attributes

/*jslint indent: 4, maxlen: 80, rhino: true */
/*global java, javax, org*/


// returns a semi-random digit between 0 and 9
function loadXml(fileName) {
   
'use strict';
   
var dbFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance(),
       dBuilder = dbFactory.newDocumentBuilder(),
       xmlFile = java.io.File(fileName),
       xmlDoc = dBuilder.parse(xmlFile);
   xmlDoc.normalizeDocument();
   
return xmlDoc;}


// constructor
function DocumentNodes(xmlDoc) {
   
'use strict';
   
//var my = this;
   
this.xmlDoc = xmlDoc;
   
this.xpFactory = javax.xml.xpath.XPathFactory.newInstance();
   
this.xpath = this.xpFactory.newXPath();
   
// return node set of a specific type for a given expression
   
this.get = function (expression, type) {
       
var xpexpression = this.xpath.compile(expression);
       
return xpexpression.evaluate(this.xmlDoc, type);
   
};
}


/**************************************
* MAIN
**************************************/


// load document
var xmlDoc = loadXml('test.xml');

// read using xpath
var nodes = new DocumentNodes(xmlDoc);var results = nodes.get('/company/turnover/year[@id=2012]',
               javax.xml.xpath.XPathConstants.NODESET);


// show a specific year
var i;for (i = 0; i < results.getLength(); i += 1) {
   
var node = results.item(i).getFirstChild();
   print(
'Year 2012 has turnover of ' + node.getTextContent());
}


// show all years
results = nodes.get(
'/company/turnover/*',
           javax.xml.xpath.XPathConstants.NODESET);

for (i = 0; i < results.getLength(); i += 1) {
   print(results.item(i).getTextContent());

}


// show attributes and value for each year
for (i = 0; i < results.getLength(); i += 1) {
   
if (results.item(i).hasAttributes()) {
       print(results.item(i).getTextContent() +
' has attributes');
       
var attribs = results.item(i).getAttributes();
       
var j;
       
for (j = 0; j < attribs.getLength(); j += 1) {
           
var n = attribs.item(j);
           print(
'\t' + n.getNodeName() + ' = ' + n.getNodeValue());
       
}
   
}
}

And here is the scripts execution

$ rhino loadxml.js
Year 2012 has turnover of 140000
100000
140000
200000
100000 has attributes
id = 2011
140000 has attributes
id = 2012
200000 has attributes
id = 2013

Friday, 28 September 2012

How To Upgrade Linux Mint Debian Edition

Upgrade

I recently had to perform upgrades for multiple machines from Update Pack 4 to Update Pack 5. It was really rather easy to do as the following instructions show.
Thanks to this blog for correcting some of my mistakes.

Update the Update Manager

The update manager will indicate when updates are available. For a distribution upgrade like Update Pack 5, I revert to command line. Use CTL-ALT-F1 to switch to a native console session. Then update the update manager with the commands
sudo apt-get install mint-debian-mirrorssudo apt-get install mintupdate-debiansudo apt-get --fix-missing --list-cleanup updatesudo apt-get install mintupdate-debian

Run Distribution Upgrade

So, now we are ready to perform the upgrade with
sudo apt-get --fix-missing --list-cleanup updatesudo apt-get dist-upgrade

Questions Asked During Upgrade

Questions will be asked during the upgrade. If you have a default installation you can normally use the package maintainers version. If unsure check the differences.
With kernel updates you will be asked where to install Grub.
Answer with the location of your current Grub menu, which on most systems is /dev/sda.

Post Upgrade Tasks

Get Best mint-debian Mirror

After installation refresh mirrors with
sudo dpkg-reconfigure mint-debian-mirrors
When I did this I got the following error.

How to Solve NO_PUBKEY 07DC563D1F41B907

Thanks to this blog for this solution.
If we add the repository http://www.debian-multimedia.org  on Debian testing
it can happen that when we try to execute the comand apt-get update, we see a GPG error:
W: GPG error: http://www.debian-multimedia.org squeeze Release:The following signatures couldn't be verified because the public key is not availableNO_PUBKEY 07DC563D1F41B907
To solve this problem we need to install the debian-keyring package
apt-get install debian-keyring
And then execute this command:
gpg --keyring /usr/share/keyrings/debian-keyring.gpg -a --export 07DC563D1F41B907 | apt-key add -
After that, when we try to execute apt-get update, there will be no the GPG error anymore.

Google Chrome

The repositories for Google Chrome (I use the beta releases) are no longer valid. Google recommends downloading the Debian package and re-installing. This updates the Debian repositories.

Thunar Slow to Start

This is due to Thunar trying to auto-mount network drives. It is easy to fix with,
vi /usr/shares/gvfs/mounts/network.mount
And set 
AutoMount=false