blog

Scrolling in PDF-XChange Viewer in wine in fedora linux

12 November 2012

There simply isn’t a nice PDF Viewer with all the needed features natively available for linux.

The PDF-XChange Viewer works nicely. All the annotation features are present and it works in wine quite well.

One bug that has bothered me since long time was the display artefacts after scrolling the pages with the scrollwheel.

In the great ubuntuusers.de wiki there is a solution to this problem.

Just go to: Edit > Preferences > Performance and select the option “Use synchronous mode of page rendering (may slow the application if used)”

Source: http://wiki.ubuntuusers.de/PDF_XChange_Viewer

Generating abbreviated sha1 filenames

28 September 2012

For a small slide show I wanted to randomize the filenames. I first thought about random numbers but I realized that there can be collisions. Then I came over the idea to use a hashing algorithm. The first few characters should be sufficient (like in git).

Here is a short snippet. It’s quick and dirty but it works. Maybe it would be nice to specify file extensions, too.

for f in *.png
do
echo $f
sha1sum $f
mv $f $(echo $f | md5sum | cut -b1-10).png
done

Sending raw ethernet frames in linux

25 September 2012

I needed to send raw ethernet frames in linux and found a C program from Austin Marton

However it was not possible to specify the target MAC address, so I added this feature in a gist fork:

https://gist.github.com/3765522#file_send_raw_eth.c

Using xrandr to control displays

24 September 2012

At home i have an external monitor connected via HDMI to my laptop. Before disconnecting you have to disable the output, or KDE will go crazy and display windows out ouf the visible desktop.

I don’t like the mouse intensive way of going to the menu, start the settings and click to the display configuration.

There is a simpler way to configure the display from the commandline with xrandr. I just created two scripts, one to enable the HDMI output and set it right of the LVDS output, and one to disable the HDMI output.

cat ~/bin/hdmi-off.sh
xrandr --output HDMI1 --off
cat ~/bin/hdmi-on.sh
xrandr --output HDMI1 --auto --right-of LVDS1

Using grml`s vimrc in Fedora 17

17 September 2012

To download grml`s vimrc from the git repository you can just do:

wget -O .vimrc "http://git.grml.org/?p=grml-etc-core.git;a=blob_plain;f=etc/vim/vimrc;hb=HEAD"

Colored output in Git command line interface

06 September 2012

This is very simple but useful:

git config --global --add color.ui true

Using the summon-arm-toolchain on Fedora 17 and the STM32F4 Cortex-M4

05 September 2012

Follow the guide at https://github.com/esden/summon-arm-toolchain.git

Prerequisites:

This is just a list of packages I had to install on my system.

sudo yum install libusb1 libusb1-devel automake libftdi libftdi-devel zlib-devel flex bison ncurses-devel libmpc-devel autoconf texinfo patch
git clone https://github.com/esden/summon-arm-toolchain.git
cd summon-arm-toolchain
./summon-arm-toolchain
# it failed downloading newlib-1.19 so I did the following as workaround:
cd sources
wget ftp://sources.redhat.com/pub/newlib/newlib-1.19.0.tar.gz
cd ../stamps
touch newlib-1.19.0.fetch
cd ..
./summon-arm-toolchain
# needs long time, fix missing requirements (mostly -devel packages)

#now clone stlink
cd ..
git clone https://github.com/texane/stlink.git
cd stlink
./autogen.sh
./configure
make

#environment setup
export PATH=$PATH:~/sat/bin
export PATH=$PATH:~/dev/stlink

#now get sample programs from ST
cd ~/dev/st-blinky
wget http://www.st.com/internet/com/SOFTWARE_RESOURCES/SW_COMPONENT/FIRMWARE/stm32f4discovery_fw.zip
unzip stm32f4discovery_fw.zip
cd STM32F4-Discovery_FW_V1.1.0/Project/Peripheral_Examples/IO_Toggle

#get Makefiles from jonathan thomson
wget http://jthomson.towhee.org/stm32f4discovery_files/STM32F4DISCOVERY_Makefiles.zip
unzip STM32F4DISCOVERY_Makefiles.zip
cp STM32F4DISCOVERY_Makefiles/Makefile.IO_Toggle STM32F4-Discovery_FW_V1.1.0/Project/Peripheral_Examples/IO_Toggle
cd $_
mv Makefile.IO_Toggle Makefile
make

#flash the program to the STM32
sudo ./st-flash write IO_Toggle.bin 0x8000000

Fedora 17 and texlive 2012

29 August 2012

Fedora 17 contains the ancient texlive 2007 release in the package database.

To use a unofficial texlive 2012 with your Fedora 17 installation you can follow the steps noted here: http://fedoraproject.org/wiki/Features/TeXLive.

sudo rpm -i http://jnovy.fedorapeople.org/texlive/2012/packages.fc17/texlive-release.noarch.rpm
sudo yum update

Using KDE Wallet to store ssh key passphrases

13 August 2012

There is a short how-to in the archwiki which describes the process to get KDE Wallet to store your ssh passphrases.

https://wiki.archlinux.org/index.php/KDE_Wallet

Adapted to fedora you just have to

echo "#!/bin/sh
export SSH_ASKPASS=/usr/bin/ksshaskpass
ssh-add </dev/null" > ~/.kde/Autostart/ssh-add.sh
chmod +x ~/.kde/Autostart/ssh-add.sh
~/.kde/Autostart/ssh-add.sh

Then provide your passphrases and tick the “Remember” option.

Repository setup for fresh Fedora 17 installation

13 August 2012

With this short snippet you can install the free and nonfree repositories from rpmfusion and the livna repository.

su -c 'yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm http://rpm.livna.org/livna-release.rpm'

More information:

Fedora 17 additional packages to install after fresh reinstallation

13 August 2012

This is just my list of things I commonly install after reinstallation. Laptop, Fedora 17 KDE 32 Bit:

Rhythmbox 2.97 library empty after restart on Fedora 17

24 July 2012

I had this annoying bug that the library of Rhythmbox was empty after I restarted it.

After a bit searching I discovered that it is caused by moving your library from temporary storage to your harddisk.

This can be from a SD-card and symlinked to your home directory or from an encrypted partition symlinked to your home directory.

You can get some more information at this blog post or the bug database.

I didn’t care much about my entrys in the database so I just deleted it:

thomas@thinky ~ % rm ~/.local/share/rhythmbox/rhythmdb.xml                     

After that Rhythmbox builds your database new and should find all your music files.

Fedora17: creating a swap file

02 July 2012

create the virtual swap disk:

thomas@thinky /usr/local/etc % sudo dd if=/dev/zero of=swapfile bs=1M count=1k

make it a swap space and enable it:

thomas@thinky /usr/local/etc % sudo mkswap swapfile
thomas@thinky /usr/local/etc % sudo swapon swapfile

to store it permanently add it to /etc/fstab:

thomas@thinky /usr/local/etc % sudo -s
root@thinky /usr/local/etc # echo "/usr/local/etc/swapfile swap swap defaults 0 0" >> /etc/fstab

source: http://docs.fedoraproject.org/en-US/Fedora/14/html/Storage_Administration_Guide/s2-swap-creating-file.html

Copying the Fedora rootfs for raspberry pi with Fedora on the SD Card

27 June 2012

I had a few difficulties copying the fedora raspberry pi rootfs on the SD card.

thomas@thinky ~/Downloads % sudo xzcat f17arm-latest-arm-rpi-xfce-mmcblk0.img.xz > /dev/mmcblk0
zsh: permission denied: /dev/mmcblk0

The solution is to use a pipe and dd with sudo instead.

thomas@thinky ~/Downloads % sudo xzcat f17arm-latest-arm-rpi-xfce-mmcblk0.img.xz | sudo dd of=/dev/mmcblk0

Fedora17 getopt not in cstdlib

13 June 2012

In our current c++ program we used getopt for the argument processing. Compiling the program with Fedora16 was no problem. Today the code didn’t compile with Fedora17. The error was

thomas@thinky ~/FH/cs/3/cg/pr/3/Debug (git)-[master] % make
Building file: ../Cli.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"Cli.d" -MT"Cli.d" -o "Cli.o" "../Cli.cpp"
../Cli.cpp: In constructor ‘Cli::Cli(int, char**)’:
../Cli.cpp:7:42: error: ‘getopt’ was not declared in this scope
../Cli.cpp:20:7: error: ‘optind’ was not declared in this scope
../Cli.cpp:25:19: error: ‘optind’ was not declared in this scope
make: *** [Cli.o] Error 1

getopt is not in cstdlib anymore. The includes are extended with getopt.

#include <cstdlib>
#include <getopt.h>

Shell Helper Create New Post

12 June 2012

I created a little shell helper to create a new markdown file for a blogpost.

File: newPost.sh:

#!/bin/sh
touch _posts/`date +%Y-%m-%d`-$1.md

With this scipt i can do

thomas@thinky ~/dev/pages (git)-[master] % ./newPost.sh Shell-helper-create-new-post

EDIT: I extended the snippet a little bit:

#!/bin/sh
FILENAME="_posts/`date +%Y-%m-%d`-$1.md"
echo "---
layout: default
---" > $FILENAME && $EDITOR $FILENAME

Now the default layout is added to the file and the fileeditor $EDITOR is launched.

Android App Review Airdroid

03 June 2012

AirDroid is a Android app which provides a webinterface to your Android device. The webinterface is accessed through the local WiFi.

The most useful feature for me is to write Textmessages (SMS) from your Laptop. Another nice feature is to make screenshots and download it directly with the browser. The interface is very well designed and the app is for free.

Screenshot of the webinterface:

thumbnail

Download Airdroid from Google play.

Social Media Icons

01 June 2012

Very nice icons found here. I will use it to link to my profiles around the web.

icondock

Free to use for whatever purposes.

A nice xda Logo found here:

arrioch

Jekyll Default Template

31 May 2012

By now I have to type

---
layout: default
---

on top of every new page I create. How to apply a layout to all page per default?

Seems there is no way to get this behaviour.

First Post

31 May 2012

This is my first Post trying the github pages and jekyll.

H Bridge To Control A Small Motor From A Uc (mbed Cotrex M0)

19 April 2012

This time I am sharing a simple design for a H-Bridge with used parts and an mbed ARM Cortex-M0 controller.

I had a bit difficulties to control the PNP transistors with the controller. The deal was to lift the voltage for the base of the PNP.

My design is based on used parts out of old cheap 5.1 dvd / audio combination and other stuff. Basically I think it doesn’t really matter which type of transistor you use unless you are dealing with high powered motors.

Not so much text, here is the schematic:

thumbnail

Here a picture of the breadboard prototype:

thumbnail

To control the motor with the mbed you can write a program based on the following source:

#include "mbed.h"

DigitalOut a(p17);
DigitalOut b(p18);
DigitalOut c(p23);
DigitalOut d(p24);

void rechts() {
    a = 0;
    b = 1;
    c = 0;
    d = 1;
}

void links() {
    a = 1;
    b = 0;
    c = 1;
    d = 0;
}

void stop() {
    a = 1;
    b = 0;
    c = 0;
    d = 1;
}
    

int main() {
    while(1) {
        rechts();
        wait(0.2);
        stop();
        wait(0.1);
        links();
        wait(0.2);
        stop();
        wait(3);
    }
}

Sending A Program From The Commandline To Background

02 March 2012

You know this situation you started eclipse in a terminal and after opening a few files you want to type some commands in the terminal but you forgot the & after the command.

You can kill the programm (eclipse) with strg+c or you can pause it with strg+z and send it to the background with the bg command. After that your programm is continuing normal and you can use the terminal.

    thomas@thinky ~ % eclipse
    ^Z
    [1]  + 5497 suspended  eclipse
    20 thomas@thinky ~ % bg
    [1]  + 5497 continued  eclipse
    thomas@thinky ~ %

Middle Mouse Trackpoint Scrolling On Fedora 16

01 March 2012

Just figured out how a long missed feature can be configured on fedora16: the scrolling with the middle mouse button and the trackpoint.

I liked this very much and couldn’t figure it out how to do it.

Here is a short note:

thomas@thinky ~ % sudo yum install gpointing-device-settings

And configure following in the GUI.

thumbnail

Control Your Camera From The Commandline On Linux With Gphoto2

19 February 2012

Using gPhoto and libgphoto2 you can control your Camera with your Linux PC and the Commandline. I’m using fedora16 and a Nikon D5000. With this setup you can easily shoot and download pictures using the USB cable. It is used as control and after the capture downloads the picture to your local folder.

To install gphoto2 on fedora use following command:

sudo yum install gphoto2

Connect your Camera to your PC or Laptop. Run following command to capture and download a Image:

gphoto2 --capture-and-download

Using A Custom Windows 7 Iso For The Windows 7 Usb Tool

12 February 2012

I had to install Windows 7 Home Premium on a Laptop where the DVD drive doesn’t work. I ordered DVDs, and realized it doesn’t boot.

After creating a .iso image of the DVD I realized the Windows USB tool isn’t accepting custom .iso images, just the ordered from the windows shop.

To make the Windows tool accepting your .iso file you can use the tool from withinwindows: http://www.withinwindows.com/2009/11/01/use-the-windows-7-usbdvd-download-tool-with-custom-isos/

After using it the Windows USB tool is accepting my image.

Delete Nef Raw Photos Where No Jpg Exists

01 February 2012

Sometimes I shoot my pictures with Nikons NEF/RAW format but keep also shooting JPEGs. To sort bad pictures out I only view the JPG and delete them if I don’t like them. After this process I end up with sometimes very much NEF/RAW images which I don’t want.

To delete the unwanted NEF/RAW files you could probably just find them in the file explorer and delete them.

If you are at a Linux Box, there are better ways to do this. If also using the zsh, you can use this simple command to print all NEF files where no JPG exist:

print *.NEF(e_'[[ ! -e $REPLY:r.JPG ]]'_)

or just delete them:

rm *.NEF(e_'[[ ! -e $REPLY:r.JPG ]]'_)

Command based on http://grml.org/zsh/zsh-lovers.html

# Show me all the .c files for which there doesn't exist a .o file.
$ print *.c(e_'[[ ! -e $REPLY:r.o ]]'_)

Repair Windows 7 After Deletion Of 100mb Partition

31 January 2012

Why is there a 100 MB partition on my Windows system? Don’t know, I deleted it. It wasn’t a good idea. This is a short note how I rescued my system.

mark the partition where windows 7 is installed as active: http://www.sevenforums.com/tutorials/71432-partition-mark-active.html

Go in the repair mode and answer ok ;-)

Don’t know how it worked particularly, it was just a note I found and thougt I could share it ;-)

Install Zsh And Grml's Zshrc In Fedora 16

31 January 2012

Install zsh:

sudo yum install zsh

Grab grml’s zshrc and save it to /etc/zshrc.

sudo wget -O /etc/zshrc "http://git.grml.org/?p=grml-etc-core.git;a=blob_plain;f=etc/zsh/zshrc;hb=HEAD"

Edit /etc/passwd and choose /etc/zsh as your shell:

vi /etc/passwd

Change the line containing your Username:

user:x:1000:1000:name:/home/thomas:/bin/zsh

Execute zsh.

How To Deutsche Anführungszeichen Mit Vim Latex In Fedora 16

11 January 2012

vim-latex installieren:

% sudo yum install vim-latex

schauen was installiert wurde:

% repoquery --list vim-latex | grep ngerman
/usr/share/vim/vimfiles/ftplugin/latex-suite/packages/ngerman

Damit die Deutschen Anführungszeichen auch in einer include oder input Datei gelten muss folgendes gemacht werden:

die Deutschen Anführungszeichen gelten dann in allen LaTex Dokumenten.

die let-Befehle für SmartQuoteOpen und SmartQuoteClose aus der angegebenen Datei kopieren und in ~/.vim/ftplugin/tex.vim kopieren (evlt. Anlegen).

oder in einem: ;-)

% repoquery --list vim-latex | grep ngerman | xargs cat | grep SmartQuote >> ~/.vim/ftplugin/tex.vim

How To Install Microsoft Core Fonts In Fedora 16

27 December 2011

First follow this guide: http://corefonts.sourceforge.net/

install xfs:

sudo yum install xfs

then install chkfontpath from centos i386 architecture:

sudo rpm -ivh http://mirror.centos.org/centos/5/os/i386/CentOS/chkfontpath-1.10.1-1.1.i386.rpm

after that the command

sudo rpm -ivh $HOME/rpmbuild/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm
error: Failed dependencies:
    /src/sbin/chkfontpath is needed by msttcorefonts-2.0-1.noarch

should work

Node.js On Fedora

14 December 2011

Don’t do a sudo yum install node if you want to install node.js. There is currently (fedora 16) no node.js package.

i got a strange error cant find /etc/ax25/axports when trying to run a rails application.

To use node.js go clone the git repository at github.com and build it yourself.