WordPress crayon syntax highlighter examples

Using the crayon WordPress syntax highlighter plug-in for laying out code is nice. However there is one thing that I never get right without a lot of trial and error and that is which theme to use when.
As there are no examples that I spotted right away here is a showcase iteration through the themes available in crayon.

The code is basically wrapped in <pre>CODE GOES HERE</pre> tags.

The opening pre tag will contain the theme. In the example below it is the amity theme:

Crayon theme examples

Theme Shell Example Java Example

Default

1c Kod

1c Zapros

809finest

Ado

Amity

Arduino Ide

Bncplusplus

Capacitacionti

Cg Cookie

Cisco Router

Classic

Coda Special Board

Coy

Dark Terminal

Eclipse

Epicgeeks

Familiar

Feeldesign

Flatui Light

Github

Idle

Inlellij Idea

Iris Vfx

Kaderu

Kayote

Light Abite

Mirc Dark

Mm Dark Blue

Monokai

Neon

Obsidian

Obsidian Light

Onderka15

Orange Code

Plain White

Powershell

Powershell Ise

Prism Like

Pspad

Qtcreator

Raygun

Secrets Of Rock

Shell Default

Solarized Dark

Solarized Light

Son Of Obsidian

Ssms2012

Sublime Text

Terminal

Tomorrow

Tomorrow Night

Turnwall

Twilight

Visual Assist

Vs2012

Vs2012 Black

X3info

Xcode

Linux hard drive information

Sometimes it is useful to get some more information about your hard drive than just the size remaining. For this purpose there is a Linux package called smartmontools available, which can be easily installed.

Once available you can inspect different quantities and qualities of your drive by issuing smartctl commands. A good article is available over at TechRepublic.com written by Vincent Danen

The tools will be installed to /usr/sbin/smartctl. In case you are on a machine that does not have sbin in it’s path (I was working on a bananapi, which does not) you will have to precede the commands with the full path.

Some commands and their output are given below.

Get the basic information from your drive

Starting a short test

Viewing the test results

The test results will be at the end of the ouptut provided by smartctl -a. Test information starts with a hash.

Setting up an NFS server on Banana Pi

Install the NFS Server

 

—————————————-
Mount the drive

—————————————–
Setting up the exports

————————————
Configuring the exported directories

———————————
Starting the server

————————————————————————-
After normal restart

—————————————–
Adding the NFS group

—————————————–
Assign the new group to existing files

—————————————–
Adding the group on the client machine

Using Californium in Eclipse

Why Californium?

When dealing with IoT on a technical level one of the protocols to look at ist CoAP. Well and for wetting your feets a library is required.

The Californium library is one of the rare libraries that provides the CoAP protocol on top of the secure DTLS protocol. Both CoAP respective DTLS are based on UDP.

Setting up Eclipse for usage with Californium

I am using Ubuntu 14.04 and the Eclipse you can install with the package manager is not featuring the required extensions:

  • EGit
  • Maven

So first thing is to install them manually.

Eclipse Install Menu

Select a site with Eclipse software

Eclipse Install Software Dialog. Select Site

Install EGit into Eclipse

Eclipse software dialog - Select EGit

Eclipse software installation - Egit

Install Maven Integration into Eclipse

Eclipse software installation - Maven

Import Californium into Eclipse

Importing a maven project into Eclipse

 

Select californium directory with projects

eclipse-iot-10

Setting up an own project using Californium

eclipse-iot-12

eclipse-iot-13

eclipse-iot-14

Getting Ginkgo CADx up and running on Ubuntu

I needed to look at some MRT images but the CDs doctors provide you after your tube ride only contain a windows viewer. So when I clicked on the image data on the disc Ubuntu was recommending Ginkgo CADx to me, which I installed right away.

The first start was however a disappointment. I was able to see a thumbnail of the image but when clicking on it no image was opening an an error message was displayed.

The Ginkgo CADx web site was also of no help. It seems once upon a time a fix was described but now it is gone. By the way I am using version 2.6 of that program.

Starting the program from command line reveals an error about shared libraries that do not load properly. So in the end editing the .inf files in that directory to load the correct library files fixed the problem for me.

How to fix it

1. Cd to

2. Open up the .inf file in an editor with super user privileges:

3. Change the first line in each of the two files by basically just removing each time the trailing “.2.6.0.” as shown below and of course save the changes.

Start the program again and it should work. I recommend to start it from the command line.

Original lightvisualizator.inf file

Bildschirmfoto Ginkgo-error vom 2016-03-02 21:35:44

Fixed file

Bildschirmfoto Ginkgo vom 2016-03-02 21:34:48

Original visualizator.inf file

Ginkgo inf file

Fixed file

Bildschirmfoto Ginkgo vom 2016-03-02 21:34:15

Using Ginkgo CADx

The program is working nicely. Remember it is for free.

Open up the “dicomdat” folder of your CD data, click on the thumbnail to view the real images.

Zoom in and out by turning the mouse wheel.

Hold down the Ctrl key while turning the mouse wheel to flip movie like through the views.

Quite impressive is the 3DTool which combines a series of images taken from one angle into a 3D view. Just try it out.

I prefer to start this program from the command line as it will not exit properly. So issuing Ctrl-C will then exit the program brutally but effective.

Ubuntu Upgrade Problem lösen

Schon zum zweiten Mal laufe ich in das Problem, dass die Upgrades des Ubuntu Systems sich nicht mehr installieren lassen. Wenn man nach den Symptomen in deutscher Sprache sucht findet man leider auch nicht allzu viel. Daher hier meine Anleitung wie ich die Installation wieder ans Laufen gebracht habe, samt dem Löschen nicht benötigter Kernel Versionen.
Für mich zur Erinnerung und vielleicht für Euch als Anregung.

Ihr solltet außerdem in der Lage sein mit der Shell umzugehen. Ich übernehme keinerlei Haftung für die Korrektheit oder für Schäden die durch das Befolgen dieser Anleitung entstehen. Ihr handelt auf eigene Gefahr.

Symptome

  • Der normale Upgrade Manger meldete ein Problem bei der Installation und konnte die Linux Kernel Header Dateien nicht installieren.
  • In der Kommand Bar erscheint ein Stoppschild, dass darauf hinweist, dass die Upgrade Funktion beschädigt ist.
  • sudo apt-get -f install schmeißt in etwa den im folgenden Unterkapitel gezeigten Log aus.
  • Im Ubuntu Software Center gibt es sofort eine Nachricht, dass das Paketierungssystem aus dem Tritt ist und man weder installieren noch de-installieren kann
  • Wenn man mit baobab (Shell Aufruf) in etwa folgendes in /usr/ sieht
    Bildschirmfoto baobab Ubuntu Kernel Header

Ich habe dann auch alle Varianten versucht, um z.B. Linux Header Dateien zu de-installieren aber alles läuft in einen Fehler.

sudo apt-get -f install

Ihr solltet dasselbe Problem haben, wenn die unten rot markierte Nachricht erscheint.

 

Lösung

  1. Auf jeden Fall, erst mal in der Shell
    sudo apt-get -f install
    aufrufen. Vielleicht ist das Problem ja damit schon behoben.

Wenn das nichts geholfen hat und Ihr auch die Log Zeile “Auf dem Gerät ist kein Speicherplatz mehr verfügbar” findet fahrt wie folgt fort, um Speicher manuell freizugeben.

Speicherplatz manuell freimachen

Achtung das Löschen der Kernel Dateien kann ein System unbrauchbar machen. Insbesondere das Löschen der aktuellen Kernel Dateien führt ins Verderben.

  1. Feststellen welchen Kernel man selbst am laufen hat. uname -r war bei mir ergibt bei mir 3.2.0-84-generic-pae.
    !!
    Dateien die diese Nummer z.B. bei mir 3.2.0-84 enthalten auf keinen Fall löschen!! (wird bei Euch sicher eine andere Nummer sein)
  2. Listen der Header Datein ls /usr/src
  3. Löschen von Header Dateien rm -rf /usr/src/3.xxxxx (Sucht Euch die kleinsten Nummern raus bei mir z.B. 3.2.0.35) und löscht das ganze Verzeichnis
  4. Listen der Lib Dateien ls /lib/modules/
  5. Löschen der Lib Dateien rm -rf /lib/modules/3.xxxx (Nehmt hier die selben Nummern wie vorher bei den Headern
  6. Jetzt nochmal sudo apt-get -f install. Wenn es geklappt hat dann läuft das jetzt durch

Das war aber nur ein Teil der Miete, denn jetzt heißt es…

Aufräumen

Uns so geht das Aufräumen und das Freigaben von mehr Speicherplatz

  1. Die Header Dateien der Kernel die Installiert sind kann man sich anzeigen lassen indem man in der shell folgendes eingibt
    sudo apt-get remove linux-
    dann zwei mal Tab drücken.
  2. Jetzt die Header Dateien der Kernel für die man vorher Dateien manuell gelöscht hat mit apt-get löschen. Auf keinen Fall die Version die man oben mit uname -r ermittelt hat!!
    z.B.
    sudo apt-get remove linux-headers-3.2.0-29
  3. Die libs der Kernel kann man sich anzeigen lassen indem man
    sudo apt-get purge linux-image-3
    eingibt und zweimal Tab drückt.
  4. Jetzt wie oben unter 2 das ganze für die libs
    sudo apt-get purge linux-image-3.2.0-29
  5. Nun und das ganze wiederholen für die Kernel die man nicht mehr benötigt. Die letzten 5 würde ich persönlich stehen lassen.

Nach dem Aufräumen als Beispiel die verbleibenden Header Dateien.
Bildschirmfoto baobab Ubuntu Kernel Header nach Aufräumen

Fazit

Im Moment des Ausfalls hatte ich:

  • 89 MB pro Kernel an Header Dateien und
  • 135 MB pro Kernel an Lib Dateien
  • Das ganze 37 mal!

Nach dem Aufräumen hatte ich mal eben 6 GB freien Speicherplatz.

Das Problem ist je nach Perspektive:

  • Meine zu kleine Systempartition
  • Der Ubuntu Upgrade Prozess der dann eben doch nicht benutzerfreundlich die alten Kernel Logs aufräumt.

Aber ich tendiere zu letzterem. Es ist für den normalen Benutzer nicht nachvollziehbar warum das System plötzlich den Dienst versagt.  Wünschenswert wäre es nur die letzten sagen wir 5 Kernel aufzuheben oder den Platz für die Kernel sinnvoll zu begrenzen.

Und mal ehrlich wie oft geht beziehungsweise fällt man mehr als einen Kernel zurück?

File recovery from WD My Book World Edition NAS

I have a NAS WD ® My My Book World Edition and was happy with it but after six years of constant usage the device stopped working. At first from time to time the NAS was not accessible but a restart helped. Then one day it completely stopped to respond and the LED boot indicator (white light) showed no progress at all any longer.

Lucky you if you have a recent back-up. Mine was not recent enough and there were some pictures on the NAS that I wanted to recover?! So here is what happened and may help you as well. A few useful links that helped me can be found at the end of this article.

I provide this as a report about what helped in my situation yours may be completely different and if you follow the steps given in this article you act on your own risk and I will not be liable for any damage! I assume you have some knowledge of Linux and drives.

I hope you have  a backup of your data 😉

Well there are three main components of such a device that may break down. The power adapter, the controller and the harddrive. In my case the controller has a malfunction but the hard drive and power adapter were working.

There is a grain of salt for you. I was lucky that the drive was still working but if you have a problem it may as well be the case that your hard drive has a major failure. If you desperately need the data recovered don’t tinker around with it, please seek out professional support. Following the steps in this article may worsen the situation and you may lose all data.

Windows will kind of detect the drive but will not display it easily so I used Ubuntu 12.04.

Just mounting the drive to get a look at the data?

My first shot at the problem was to just mount the drive to see what happens. With the following command. (If your drive is not discovered as sdb you will have to change it accordingly maybe to sdc4, sdd4, …)

Now you can explore the drive with the nautilus filemanager GUI. However there was no accessible data on that drive.The good news for me was that my drive looked physically OK!

So next tool please.

Using palimpset to look at the drive

There is a disk utility program that provides a nice graphical overview about what you have on a drive. The English name for it is “disk utility” the German name is “Laufwerksverwaltung”. So you better use the name palimpset if your GUI is not set to English by default.

Open the Ubuntu dock (press the windows key), enter palimpset and select the drive manager.  This will open the following program that allows you to have a look at installed hard drives.

Bildschirmfoto vom 2015-04-18 23:42:08-small

As you may see there are 4 raid partitions on that drive.

Partition one to three (sdb1, sdb2, sdb3) contain the operating system and swap partition of the WD controller.

Partition four (here sdb4) is the larger partition and contains the data.

So my version of the WD My book world edition utilizes for some reason a soft raid system that you can use on a Linux machine by installing mdadm. For the standard use case this is just adding hassle. Raid from my point of view makes most sense in set-ups of two and more disks for your data.

Using the tool parted to get drive information

Installing the multi device administration program (mdadm)

To work with raid drives you will have to install the mdadm program.

Then you can some brief information about the drive by invoking mdadm as shown here.

A word of caution. In my case rebooting the machine now leads to a situation where Ubuntu discovered a raid file system and asks you if you want to mount it. I chose not to do this to stay on the save side. After this question you may end up in a bootloader, to be more specific in initramfs, here you should type “exit” and if asked to manually mount the drive you should not do it. Thereafter you boot normally into Ubuntu.

I booted up in this constellation a few times and once I discovered that the drives were mounted, shown in Nautilus and usable! That is all the below would not be necessary if this would work all the time. However I do not know how to reproduce this.

 My way to success

My procedure in short is:

  1. Get the WD hard drive out of it’s case and plug it into the PC
  2. Get a second hard drive to store the recovered data from the WD drive
  3. Generate a copy of the WD data partition to the other hard drive
  4. Bring up that image as a device
  5. Start the device with mdadm as a raid device
  6. Mount the raid device as a normal drive

Generate a copy

First I generated a copy of the sdb4 drive with the dd command. This took some time, in my case 24 hours. The recovery drive is the sdc drive and the sdc1 partition on it is big enough to contain the image.

Bind in the image as a device

With the losetup command it is possible to bind the image as a device. On my machine it is /dev/loop0. See [2].

The command losetup -d is used to unbind any possible previous use of the loop0 device. Usually unnecessary, here I do it just to be sure.

Start the raid

Mount the raid


Useful links in English

  1. http://community.wd.com/t5/WD-ShareSpace/HOWTO-Recover-files-from-a-RAID-1-mirrored-drive-when-the/td-p/138448
  2. http://wiki.osdev.org/Loopback_Device
  3. http://unix.stackexchange.com/questions/72279/how-do-i-recover-files-from-a-single-degraded-mdadm-raid1-drive-not-enough-to
  4. http://mybookworld.wikidot.com/forum/t-90514/how-to-recover-data-from-wd-my-book-world-edition-nas-device
  5. https://www.linuxquestions.org/questions/linux-server-73/mdadm-assemble-raid5-with-loopback-mounted-disk-images-715343/
  6. http://unix.stackexchange.com/questions/72279/how-do-i-recover-files-from-a-single-degraded-mdadm-raid1-drive-not-enough-to

Useful links in German

  1. http://www.florian-fritsch.com/mdadm-raid-nach-ausfall-wiederherstellen/
  2. http://www.synology-wiki.de/index.php/Datenrettung_von_Raid-Systemen_unter_Linux
  3. http://www.zeroathome.de/wordpress/platte-platt-datenrettung-mit-ddrescue-und-grml/

A first time Banana Pi experience

In this article I will present you with the experiences that I made when installing everything to boot up a Banana Pi with a Lubuntu operating system. I will also show you what went wrong and will sprinkle in some hints on how to configure the system.

How did I get this idea?

I was always wondering how to get my own server up an running at home. I did my first steps with a laptop but that was not satisfactory. I wanted to use the laptop also for other stuff and furthermore I disliked the ratio between power consumption and the time I actually used the server. So when hearing about the Raspberry Pi I was interested but only when reading about the Banana Pi I was hooked as I believed it would suit my requirements:

  • No fan, no noise
  • Small and unobstrusive
  • Constantly on as it consumes low power

Banana Pi Shopping cart

So I bought a few components.

components

  1. Banana Pi board
  2. SD Card SanDisk Ultra 30MB/s 8GB class 10
  3. Micro USB AC/DC Adapter, Model “MAREL-5V2000”

Installation

But the Banana Pi HW itself isn’t booting up on it’s own you need a decent Operating System and there exists a bunch of them. You will find all of them on the lemaker web pages. As I fancy Ubuntu my first choice was the Lubuntu distro. Besides you will find quite a few installation instructions which helped me a lot but there were also pitfalls.
I will show you how it worked in my case and as always I don’t take any responsibilities you use the following instructions at your own risk. 😉

Preparing the SD card

The below is pretty much the same as in the instructions. just the name of the SD card device is different. I used my laptop, which allows me to insert SD cards, with an installed Ubuntu 12.4.

When hiting return on the comamnd in line 6 be prepared to take a break. This took for me about 20 to 30 minutes to finish.

First start, first experience

Now it became interesting. I connected my old tube TV which features an AV input with the AV output of the Banana Pi and pluged in the power. What shall I say? The screen stayed dark. One minute, two minutes, five minutes. The only “eye candy” were two LEDs. Basically a red LED which was constantly on and a green LED which first was on and then went into a slow blinking pattern. An SOS? No actually this is a good sign as it shows that the CPU and SD card talk to each other.

  • RED LED = power
  • GREEN LED = SD Card Access

But then I connected the Banana PI via it’s HDMI plug to the TV and it worked!

Logging in to the Banana PI

I wanted to use the machine remotely so I tried to log in from a console via ssh. For this to succeed you need to know the IP address that the Banana PI got assigned via DHCP.

1_ping_lemaker

In your case the IP might be of course different but in mine the following command will alow you to log in as root.

2_first_login

Congratulations your first log-in!

As you see there are quite some upgrades pending.

Therefor the next thing to try is to call

Please note, as we just logged in using the root account this will work perfectly. If we however use for example the banapi user account where you would call

this will fail as the bananpi user account has no sudo permission. If you paid close attention you probably spotted that the console screenshot above shows a log-in with the bananpi user account. So I actually run into that problem and I will show you some chapters below how to get rid of this limitation.

A second SD card does not work

While using mainly ssh and no monitor. I realized that I am in for an OS change. An OS such as Bananaian without X support might fit better. Besides I find it a realy cool feature to just swap SD cards to fire up another OS and bought an SD card in a shop. Also 8GB, same vendor but this card was just Class 4 and not Class 10 as my initial card.

  • SanDisk SDHC Card 8GB class 4

I repeated the steps I made for the first SD card. This time with no success, it did not work. I had permanently the green LED on, which as I know today, is no good sign. In this case the device is not booting up and is not getting an IP address.

After hours of casting “format” commands and “dd” commands in different variations at the SD cards I felt frustrated and had to accept failure. The card itself is perfectly working in my laptop but it is not tolerated by the Banana Pi.

Trying a third card identical to the first

I wanted to have a second working card and just bought the same class 10 card and of cours it worked! So why does the class 4 not work…? If anyone knows please drop a comment.

Power consumption

As I mentioned, power consumption is a key parameter for me. So I tried to measure the power consumption with the meter that I have used in the past. Well what shall I say, the meter that is working happily on a TV, laptop or radio is not accurate enough to measure the Banana Pi. The Banana Pi does just not consume enough power and my meter does not bother and keeps displaying a 0 consumption.

Do you need a case for the Banana Pi?

If you studied carefully my list of ingredients at the top of the article you may have noted that I did not buy a case. I thought I could save the money but the handling of the naked board is cumbersome if it sits loosly in front of you on your table. So I would suggest that if you can spare the money go an buy a case. I will do the same.

Configuration changes I would recommend

Do not stay with the default passwords

The OS just installed has a password that is known to everyone. Even worse the password of root on that machine is known to everyone, which is dagerous. That should send cold shivers down your spine. So we better go and change it now!

It is no good idea to keep the passwords unchanged!

Just enter the below commands and type and re-type your new cunning password as requested.

Assign SUDO rights to user bananapi

I do not like working as root so to grant to the user bananapi the rights you have to add him to the sudo group as by default it belongs just to the below groups

We add the user bananapi to the group sudo

6_changing_passwords

Good-Bye Root! Now we can exit back to the bananapi account and work with the new sudo rights.

There is one catch, the systm did not reread the groups. The easiest way of getting a reset of the group ids is by exiting the ssh and reopen the ssh connection.

Inflating a 4GB image in an 8GB SSD leaves space

The OS image is apparantly from a 4GB card and I have used a 8GB card which leaves 4GB ununsed as you can see if entering the commadn fdisk -l when being logged in to the Banana PI. In the below you have to look at the used sectors and divide this by 2 to get to the size in kBytes.

Now what to do with it?

As said my aim is to use it as a server but this I will cover in another article where I am going to show how to setup Ruby On Rails with MySQL on that tiny computer.

 Copyright © 2014Georg Schweflinghaus

Mounting FAT drive in Ubuntu with the right permissions

I just plugged an old harddisk with a FAT filesystem on it that was used on a windows machine mounting it to my ubuntu system and ran into a problem of managing the files on that drive. I seldomly do this and if you run into the same issues maybe the following is of help to you. But first as always a word of caution. If you follow the steps I describe you do this at your own risk. I will not be responsible or liable for any damage or loss.

Symptoms

The symptoms were that I was able to see all data but was not able to delete or even move files.

[bash]>ls -l
-rwxr-xr-x 1 root root 113846 Apr 25 2006 TrekStor.ico
drwxr-xr-x 4 root root 32768 Mai 9 2009 Video
-r-xr-xr-x 1 root root 57636 Jul 18 2010 cache_0001.xml[/bash]

Initially I had this in the fstab file. The /dev/sdb1 is the device I mounted and the /media/sdb is the place where I mounted it in the linux file system as a FAT drive. Maybe you have something similar.

[bash]/dev/sdb1                /media/sdb     vfat    rw,user    0    0[/bash]

Thinking into the symptoms I realized that I am mounting a filesystem that does not know user rights into a file system that does. One might think that the “rw” option in the fstab should be sufficient but it is not.

The solution

To come to the point. I wanted the files of the mounted FAT drive to belong to my group and I wanted full read write execute rights on the file. In addition I wanted them to be only invisible for anybody else on the machine. To achieve this, first you need to find out your groups ID by issuing this command. (It shows my return values, yours may look different)

[bash]>id
uid=1000(georg) gid=1000(georg) Gruppen=1000(georg),….[/bash]

So now we know that (in my case) the group ID is 1000 we will enter this together with a mask into the fstab

gid=1000,umask=0007

by issuing.

[bash]sudo gedit /etc/fstab[/bash]

And then adding a line looking something like this.

[bash]/dev/sdb1 /media/sdb vfat rw,user,gid=1000,umask=0007 0 0[/bash]

Now you unmount then mount again, which will only work if you are no longer using the files on that mounted drive. So please close editors or cd out of the directory.

[bash]
>sudo umount /dev/sdb1
>sudo mount /dev/sdb1
[/bash]

And if you now look at the files on the drive you see that the permissions are set properly for you to change whatever files you want to change.

[bash]>ls -l
-rwxrwx— 1 root georg 113846 Apr 25 2006 TrekStor.ico
drwxrwx— 4 root georg 32768 Mai 9 2009 Video
-r-xr-x— 1 root georg 57636 Jul 18 2010 cache_0001.xml[/bash]

Finally Ubuntu’s Zeitgeist is useful for me

I never understood the concept of Zeitgeist, which seems to be a service running in the back and recording what I do. In fact I just know about it’s existens by chance. One day I tried to find a certain file I knew I had used with a certain program and a short internet search revealed that there is a service built into Ubuntu.

The only things that I was however able to lay my hands on were settings of what Zeitgeist is recording and what it isn’t. So as I did not and probably to a large extent still do not know what the program is truely doing it made me feel uneasy. Specifcally as obviously there is no direct use for me.

That changed when today I stumbled across a program called “GNOME Activity Journal”. I have a screenshot added below which shows that this program displays you your activities over time. It is even able to display the files you opened in a pre-view mode which is very nice.

You find it when searching for gnome-activity-journal.

Bildschirmfoto vom 2014-06-01 21:53:22

Now this is useful to me. Often some of my pet projects are carried out in loose intervals and if an interval is getting too large I have trouble to recall what I changed or did the last time I was tinkering with it.