Missing Unicode Euro Symbol in lualatex

With lualatex and xetex it became straight forward to choose from the huge universe of TrueType and OpenType fonts for typesetting text at high quality. Recently, I was preparing to set a letter in the free Colaborate font face, when I observed that the Euro symbol was not rendered by lualatex.

After trying all usual suspects from various Euro symbol add-on packages to incuding the Euro symbol’s unicode character directly with

\symbol{"20AC}

I came to the conclusion that there was a problem with the Colaborate font face. Examination of the font in fontforge

View -> Goto-> 0x20AC

revealed that the Euro symbol was indeed missing from the font face. Browsing the gylphs provided by the font I discovered the Euro symbol as Unicode Character CURRENCY SIGN with hexadecimal code U+00A4. Entering this general unicode character in latex by

\symbol{"00A4}

finally gave me the Euro symbol. For further convinience, I defined a command in the documents preamble,

\renewcommand{\texteuro}{\symbol{"00A4}}

For managing issues with missing spaces after a latex macro, use it with trailing {} brackets, for example,

\texteuro{}

See also here for other solutions to deal with spaces after latex macros.

Advertisements

Lenovo Ideapad Z565 – Resolving sudden shutdowns

Recently my Lenovo Ideapad Z565 laptop shut down suddenly without any prior warning under heavy computational load. Having some experience with the interior of my laptop due to prior problems with the fan making more noise than expected, it turned out that the heat fins at the fan’s air outlet accumulated too much dust again to properly cool down the laptop.

Opening the laptop’s back cover and cleaning the fan’s outlet as described in this earlier post resolved all issues. The laptop is now running stable again, even with all three cores running at 100% for a long time.

usb 1-1.3: reset high-speed USB device number … using dwc_otg

After moving the root partition of an Raspbian installation from memory SD card to USB flash drive, as described here, I encountered significantly improved performance in some cases, but timeouts and really bad performance in others. Investigating the system logs with

dmesg

revealed numerous of the following messages

[...] kernel: [...] usb 1-1.3: reset high-speed USB device number ... using dwc_otg

Searching this error message online, the first thing that caught my eye was that most of the prominent results are related to the Raspberry Pi, such as this one here.

Diagnosis

These discussions relate above error message to power issues with connected USB devices. I am using a Transcend Jetflash 600 USB pendrive, that reports a maximal amperage of 100 mA with

lsusb -v

The Raspberry Pi provides this amperage on its USB ports, though it is the maximum current that may be drawn from the USB ports (please note that this is under-spec, with standard USB ports specified to provide 500 mA). Anyway, as things are, the USB pendrive seemed to use more power than it reports and than the USB port could provide.

Solution

As I was using a single USB port of the Raspberry PI only, I decided to use both USB ports to power the USB flash drive (An alternative would be an active USB hub – an option I did not pursue any further). For this purpose, I used a so called USB Y cable. This provides two USB A plugs (one for power and data, one for power only), that connect to a single USB A socket (to which the USB pendrive is connected in our case).

These cables are very cheap, you might have one at home or find one as cheap as for 2 EURs online. Using a USB Y cable resolved the power issues with the Transcend Jetflash 600 cable on my Raspberry PI. Now, the move of the root partition to an USB flash drive provides unlimited benefit.

Move an existing Raspbian installation from memory SD card to USB flash drive (USB stick)

We all love the Raspberry Pi. It is fascinating to observe, what kind of different uses this low cost device motivates. I am using it in a rather conventional way as web server and backup file server, running the Debian-based Raspbian Linux distribution optimized for the Raspberry Pi.

Motivation

The one thing that really bothered me with the Raspberry PI was the bad I/O performance to the memory SD card. My Kingston 16 GB class 4 card actually gives poor performance only, as a quick

dd if=/dev/zero of=/tmp/out bs=1M count=400

benchmark reveals

419430400 bytes (419 MB) copied, 94.3303 s, 4.4 MB/s

The more I was excited to learn that

  • performance with USB flash drives is as on standard PCs
  • and only Raspbian’s boot partition must reside on the SD memory card.

I decided to give it a try and move the root partition of my existing Raspbian installation to an USB stick and see, if things improve. In my case, writing performance improved by a factor of roughly 5.

Copying the Filesystem

Firstly, partition and format the USB flash drive to hold an ext4 partition large enough to take the current root partition. Let us assume that this partition on the USB flash drive is called /dev/sdb1 on your Linux like operating system. Then, shut down the Raspberry properly,

sudo shutdown

remove the SD card and connect it with a card reader to your computer. Just as for the USB flash drive, let us assume the card’s partitions are recognized as /dev/sdc1 for the boot partition and /dev/sdc2 for the root partition.

Next, we mount both the old and new root partition,

sudo mkdir /media/usb_root; sudo mount /dev/sdb1 /media/usb_root
sudo mkdir /media/sd_root; sudo mount /dev/sdc2 /media/sd_root

and copy all the files and their attributes from usb_root to sd_root

sudo cp -a /media/sd_root/* /media/usb_root/

This may take a minute.

Configuration

After copying the filesystem, unmount the USB flash drive and the SD card

sudo umount /media/usb_root /media/sd_root

and connect the SD card only to the Raspberry PI. After powering the Raspberry PI, it will boot as before from the memory card. Login to the PI, open a terminal and connect the USB flash drive to the Raspberry PI. You may find out under what label the USB flash drive’s partition is recognized by scanning through the most recent system logs that the

dmesg

command will output:

[   90.129945] usb 1-1.3: new high-speed USB device number 4 using dwc_otg
[   90.237528] usb 1-1.3: New USB device found, idVendor=8564, idProduct=1000
[   90.237557] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   90.237575] usb 1-1.3: Product: Mass Storage Device
[   90.237588] usb 1-1.3: Manufacturer: JetFlash
[   90.237599] usb 1-1.3: SerialNumber: 3POVU7A9
[   90.249596] scsi0 : usb-storage 1-1.3:1.0
[   91.252354] scsi 0:0:0:0: Direct-Access     JetFlash Transcend 32GB   8.07 PQ: 0 ANSI: 4
[   91.254679] sd 0:0:0:0: [sda] 62717952 512-byte logical blocks: (32.1 GB/29.9 GiB)
[   91.255910] sd 0:0:0:0: [sda] Write Protect is off
[   91.255944] sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00
[   91.257156] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[   91.264365]  sda: sda1
[   91.269011] sd 0:0:0:0: [sda] Attached SCSI removable disk

In the second to last line you see, that on my system the USB flash drive is recognized as /dev/sda1.

Next we tell the boot configuration where to search for the new root partition. For this, we open the file /boot/cmdline.txt with root permissions in our favourite editor and change the line from

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

to

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/sda1 rootfstype=ext4 elevator=deadline rootwait

You see how we replace the root option in the kernel argument list. Moreover, open the file /etc/fstab and change the device label of the root filesystem to generic /dev/root. Though this step is not required, it keeps things clean.

Testing

We are done. Reboot the Raspberry PI

sudo reboot

Please note that you will not loose any data if things go wrong, as you simply have to revert file /boot/cmdline.txt on a computer to boot from the SD card again.

Once the Raspberry PI booted, check by a

ls -al /dev/root

if the root file system is now mounted from the expected partition. If everything is fine, you may now remove the root partition from the SD card and use the memory for something else.

In my case, redoing the benchmark

dd if=/dev/zero of=/tmp/out bs=1M count=400

gave greatly improved results

419430400 bytes (419 MB) copied, 17.7538 s, 23.6 MB/s

Notes

  • Once your root filesystem is on an external drive, you may remove the memory SD card after booting the Raspberry PI. Don’t forget to properly unmount all the memory card’s partitions (e.g. boot).
  • Take care if you connect multiple storage devices to the Raspberry PI’s USB port, this might mess up the partition labeling. To be on the safe side, remove any USB devices other than the flash disk on booting.
  • If you experience error messages like usb 1-1.3: reset high-speed USB device number … using dwc_otg, your USB flash drive might consume more power than a single USB port of the Raspberry PI might provide. See this post here for a more detailed discussion and a solution.

References

The idea for this post originates from this instructions here to directly install a Raspbian distribution to a USB flash drive.

Rendering Shadows in Blender 2.6

Blender is a great piece of open-source 3D modelling software and ships with a powerful rendering engine. Creating high quality renderings of 3D models requires many lessons to learn. Regard this post as one of these lessons. We will illustrate, how to equip your 3D model with a shadow.

The final result of rendering a cube with shadow in blender.

We start from a standard cube mesh, that is present in the default startup file of blender. We assign a material to the cube, and as you probably already know, the material will define how the cube will be rendered. The blender tutorial describes in detail, how to create and assign a new material to an object. For our tutorial example, we simply assign an RGB value of 0.4/0.8/0 to the cube.

Pressing F12, the keyboard shortcut for rendering, we get a first impression of the rendered cube. Hitting ESC brings us back to the modelling window.

Let us get rid of the grey background. In the World settings, we click the Horizon Color button and choose a completely white horizon color. Pressing F12 another time, we see the white background now.

To create shadows we need an object that receives the shadows. Right now, the cube hangs in the air and its shadow runs into the void. For the purpose of getting a shadow, we place a mesh plane right beneath the cube, so that the cube elevates slightly above the plane. We scale the plane such that it extends well around the cube.

We add a translated and scaled mesh plane to the scene. The plane will receive the shadow of the cube.

Our next task is to make the plane invisible, such that it display the shadow only. We add a completely white material the mesh plane and check in the Shadow subgroup nearly at the bottom of the material settings the Shadows Only option. Therein, we choose Shadow Only from the dropdown box as well. Hitting F12 we see that we already get a shadow on an invisible plane.

The plane can’t be distinuished from the white horizon anymore.

We are nearly there. The shadow right now is very sharp. We prefer fuzzy shadows however, that give the rendering a smoother appearance. For this, we select in object mode the default light source.

For configuring the shadows, we select the light source in the model.

In the Object data tab for the Lamp, we can set not only light intensity and color, but also the Number of Samples in the Shadow group of settings close to the bottom of the tab. We increase the number of samples to 5. Think of every sample as a rendering pass, with the light source slightly displaced. Aggregating all shadows yields the intended fuzzy result. The amount of displacement is
set with the Soft Size slider next to the number of samples option. The higher, the more fuzzy the final result will be. Let us choose a value of 4 for the Soft Size.

At this stage, the shadow is fuzzy though of low quality.

One thing is still missing. The shadow is fully black and of rather low quality. In order to get a proper grey shadow, we adjust the alpha value of the plane mesh’s material transparancy sub-group (you need to check Transparancy to access the alpha value). The smaller the alpha value, the less intense the shadow will be.

Modifying the plane’s alpha transparancy yields the intended result.

Playing around with light and camera settings and adding a second light, we obtain our final result.

The final result of rendering a cube with shadow in blender.

References

There are various forum posts in the blender community that discuss one or another aspect of rendering shadows. I found this post here in particular useful.

Ubuntu 12.04 Precise Pangolin – sudo and the PATH variable

Recently I noticed that a modified $PATH variable – even system-wide by scripts like

export PATH=add_to_path:$PATH

in /etc/profile.d – is not preserved when doing sudo, giving a familiar

sudo: (...) command not found

error message. As discussed here, the reasoning behind this are security measures. A convenient temporary work-around is to set the PATH variable when calling sudo

sudo env PATH=$PATH YOUR_COMMAND

This will give sudo the same PATH environment variable as the calling user.

SVN over SSH with multiple svn users and a single unix account without shell access (Windows client configuration)

Our goal in this three part tutorial is to provide multiple users access to a SVN server running a recent version of Ubuntu Linux through the SSH protocol. In SVN language, this combination of protocols is called svn+ssh. The straight forward way would be to create a unix user account for every SVN user and let them tunnel to the SVN server. However, giving all these users shell access to the server is a potential security issue and goes far beyond the initial purpose of just giving access to the SVN server. As a solution, we will create a single unix user account, that is not allowed to have any shell access, and let the SVN users connect through this user account to the SVN server.

This third and last part of the tutorial focusses on the configuration of a Windows client. The first part of the tutorial managed the server-side configuration whereas the second part walked through the configuration of a Unix / Linux client.

Client-side configuration on Windows systems

As stated in the server-side configuration, the private key file id_rsa needs to be distributed to the user on the client side. He or she will use the private key to connect to the SVN server. As the private key is enough to establish the connection, it needs to be stored in a safe place on the computer (and may be additionally secured by a password, see ssh-keygen above).

On Windows, we will use PuTTY to establish the SSH connection and TortoiseSVN for the SVN connection on top of the SSH connection:

As a first step, we are required to convert the private key from OpenSSH format to a format, that PuTTY can read. For this, start PuTTYgen (that came with the PuTTY installer) and select from the menu

Conversions -> Import Key

Load the private key file id_rsa and then click the “Save private key” button in PuTTYgen’s main window. Choose a meaningful filename, for example id_rsa.ppk.

Now as we have the private key file in a format compatible with PuTTY, we configure a so called PuTTY session that connects to the SSH/SVN server with the private key. This session will then be used by TortoiseSVN to automatically set up the SSH connection. Start PuTTY, enter the host name of the  SSH/SVN server, in

Connection -> Data

enter the username sshsvn and in

Connection -> SSH -> Auth

provide the path to the private key file id_rsa.ppk. After you have done all configuration, change back to the first tab and store the configuration as a new session that we will call here svn_over_ssh.

After storing the session, double-click it from the list. A  terminal window will open and stop after displaying some messages. As expected, the connection is established with the provided private key, but is not granted a shell (pty). Remember, that we disabled shell access for user sshsvn. The last line is output from the SVN server.

Using username "sshsvn". 
Authenticating with public key "imported-openssh-key" 
Server refused to allocate pty 
( success ( 2 2 ( ) ( edit-pipeline svndiff1 absent-entries commit-revprops depth log-revprops atomic-revprops partial-replay ) ) )

After closing the terminal window (and quitting PuTTY at the same time), start TortoiseSVN by right-clicking the Desktop and selecting

TortoiseSVN -> Repo-Browser

from the context menu. The syntax of the URL for the repository is

svn+ssh://PuTTY_SESSION_NAME/repo-path

so in our case reads

svn+ssh://svn_over_ssh/

Please note that in difference to the Linux client, there is no need for a trailing @ char to browse the root directory. Clicking the OK button will connect to the SVN server and we are ready to use TortoiseSVN to connect to the SVN server.

Summary

We have seen how to connect from a Windows system to a SSH/SVN server with a private key for the SSH connection. The server will decide upon the matching public key which SVN user account is used for the SVN connection.

Further Reading

Apart from the documentation of PuTTY and ToroiseSVN, the main source for this tutorial has been http://tipsandtricks.nogoodatcoding.com/2010/02/svnssh-with-tortoisesvn.html.

This is part three in a series of three tutorials: