Archive

Archive for the ‘Misc’ Category

git-latexdiff errors? Workaround: using latexdiff manually allows fixing broken things

December 4, 2017 Leave a comment

In a previous post we have highlighted git-latexdiff, which visually highlights the changes between two versions of the same latex file managed with git – without you being required to checkout any versions of that file yourself. In certain cases git-latexdiff might terminate with errors instead of producing a visual diff file. For example, it might struggle with broken latex code, broken figures, certain usage of subfiles, etc. In such cases, it might help to manually do what git-latexdiff would do fully automatically for you. Here’s a simple step-by-step explanation of how you could achieve visual highlighting even with broken Latex files:

  • Have the repository R2 available, which contains the file F in the newer version you want compared. Copy the repository R2 to a different folder R1 (you could do this on other ways too, but with copying you can hardly mess things up). In the copied folder checkout the version of the repository which contains F in the older version you want compared. Therefore, R2 contains F in the new version and R1 contains F in the old version now.
  • You can now fix both versions of F  should they contain broken latex code. F essentially needs to compile in both R2 and R1.
  • If you run into troubles with figures (also in subsequent steps) it might be helpfull to add the “draft” parameter to the documentclass. This can be done in both F files or in the diff.tex generated later. It disables figures in the documents, which causes less problems later in case figures are part of what prevents latexdiff, pdflatex, or one of the other tex tools from doing their jobs. This might also the case if figures have both been added and removed, or if figure paths have changed between those versions.

After those preparations, in your terminal run the following command from somewhere outside both repositories:

latexdiff --append-safecmd=subfile R1/path/to/F R2/path/to/F --flatten > diff.tex

The option

--apend-safecmd=subfile

makes the subfile command safe to use within the scope of the “\DIFadd” or “\DIFdel” commands, which latexdiff uses to mark differences between versions. The option

--flatten

replaces “\input” and “\include” commands within body by the content of the files in their argument. This makes all content of the document appear in your highlighted diff in the end. If the latexdiff-command succesfully generated a diff.tex file, copy this file into R2 or R1, right next to where F is located. You should now be able to compile and show the pdf file:

pdflatex diff.tex && biber diff && pdflatex diff.tex && evince diff.pdf

Fixing even more problems

In case you run into errors during compilation using the method above you might be able to manipulate the diff.tex file. If this does not help and if you are just interested in differences in the plain text there is an even stronger workaround you can try: you can copy the important parts of the content of your main .tex files in both R1 and R2 into newly created – and therefore clean – dummy.tex files. The important part of the text will usually be textual paragraphs, and more importantly for big documents, includes of subfiles. The dummy.tex files need to be of the same document class (e.g. a book class document will need a clean book again to work).  Remember to do this in an identical way in both R1 and R2. Afterwards you can compare the dummy.tex files using latexdiff (instead of the original main files). Doing so can circumvent many different types of problems that might be introduced due to code in custom Latex .cls or .sty files that is either unsupported by latexdiff and/or is broken in some way.

git latexdiff usage: visually highlight changes in version controlled Latex files

October 2, 2017 1 comment

This is a follow-up post to latexdiff-git, which is outdated by now.

latexdiff is a powerful tool that uses two Latex files to generate a third Latex file in which differences between the first two files are visually highlighted. latexdiff is especially useful when comparing an old with a new version of the same Latex file. However, latexdiff does not account for any version control on its own. This means that if you want to visually highlight the differences between two versions of a version controlled Latex file, you are required to manually checkout the two different versions ahead of comparing them with latexdiff. In case you are using git as your version control system, this is where git-latexdiff comes into play. It accounts for checking out the different version of a Latex file as well as comparing them with latexdiff in a single command: you only need to specify which latex file and versions should be used for the comparison.

Preconditions

Ensure you have git, a latex distribution (e.g. texlive-full), and latexdiff installed and available in the path of your CLI.

git-latexdiff installation

Clone git-latexdiff:

git clone https://gitlab.com/git-latexdiff/git-latexdiff#

Follow instructions in the README. This will involve a:

sudo make install

in most cases on an Ubuntu system. If all went well “git latexdiff” should be available in your CLI (it should print the help message):

user@machine:~$ git latexdiff

fatal: Please, provide at least one revision to diff with.
Usage: git latexdiff [options] OLD [NEW]
 git latexdiff [options] OLD --
 git latexdiff [options] -- OLD
Call latexdiff on two Git revisions of a file.

OLD and NEW are Git revision identifiers. NEW defaults to HEAD.
If "--" is used for NEW, then diff against the working directory.

Options:
 --help this help message
 --help-examples show examples of usage
 --main <file> name of the main LaTeX, R Sweave,
 or Emacs Org mode file.
 The search for the only file containing 'documentclass'
 will be attempted, if not specified.
 For non-LaTeX files, a reasonable `prepare` command
 will be used unless explicitly provided
 --no-view don't display the resulting PDF file
 --latex run latex instead of pdflatex
 --bibtex, -b run bibtex as well as latex
 (pdflatex,bibtex,pdflatex,pdflatex)
 --biber run BibLaTex-Biber as well as latex
 (pdflatex,bibtex,pdflatex,pdflatex)
 --view view the resulting PDF file
 (default if -o is not used)
 --pdf-viewer <cmd> use <cmd> to view the PDF file (default: $PDFVIEWER)
 --no-cleanup don't cleanup temp dir after running
 --no-flatten don't call latexpand to flatten the document
 --cleanup MODE Cleanup temporary files according to MODE:

- keeppdf (default): keep only the
 generated PDF file

- none: keep all temporary files
 (may eat your diskspace)

- all: erase all generated files.
 Problematic with --view when the
 viewer is e.g. evince, and doesn't
 like when the file being viewed is
 deleted.

--latexmk use latexmk
 --latexopt pass additional options to latex (e.g. -shell-escape)
 -o <file>, --output <file>
 copy resulting PDF into <file> (usually ending with .pdf)
 Implies "--cleanup all"
 --tmpdirprefix where temporary directory will be created (default: /tmp).
 Relative path will use repository root as a base
 --verbose, -v give more verbose output
 --quiet redirect output from subprocesses to log files
 --prepare <cmd> run <cmd> before latexdiff (e.g. run make to generate
 included files)
 --ln-untracked symlink uncommited files from the working directory
 --version show git-latexdiff version.
 --subtree checkout the tree at and below the main file
 (enabled by default, disable with --whole-tree)
 --whole-tree checkout the whole tree (contrast with --subtree)
 --ignore-latex-errors keep on going even if latex gives errors, so long as
 a PDF file is produced
 --ignore-makefile ignore the Makefile, build as though it doesn't exist
 -* other options are passed directly to latexdiff
 --bbl shortcut to flatten a bbl file of the same name as the project
 --latexpand OPT pass option OPT to latexpand. Use multiple times like
 --latexpand OPT1 --latexpand OPT2 to pass multiple options.
 --latexdiff-flatten use --flatten from latexdiff instead of latexpand

Unrecognized options are passed unmodified to latexdiff.

git-latexdiff usage

The main CLI usage of git-latexdiff is:

git latexdiff --main YOURFILE OLD_HASH [NEW_HASH]

A bunch of useful options are available for git-latexdiff. For example:

-v # good in case you run into any errors
--cleanup keeppdf # delete the checked-out 'old' and 'new' folders but keep the pdf
--cleanup all # delete all generated files afterwards
--output FILE # copy pdf before deleting it to FILE (disables automatically viewing the pdf). good in combination with --cleanup all
--tmpdirprefix ./FOLDERNAME/ # alternative to the above: specify where temporary stuff is stored, makes it easier to access diff files. good in combination with --cleanup keeppdf
--bibtex # also run bibtex
--biber # also run biber

Therefore, the command you might want to run therefore might be similar to this:

git latexdiff --main MYFILE.tex --bibtex --output git-latexdiff.pdf --cleanup all OLD_HASH NEW_HASH

…where you can specify

--

as NEW_HASH, if you want to run git latexdiff against the current (possibly unstaged/uncommited) version of the file, or where you can leave out NEW_HASH completely, if you want to run it against the last commit. Or your command might look similar to this:

mkdir git-latexdiff; git latexdiff --main MYFILE.tex --tmpdirprefix ./git-latexdiff/ --cleanup keeppdf OLD_HASH

 

i3 window manager: quick setup and configuration

February 5, 2017 Leave a comment

i3_window_manager_screenshot

i3 example [Wikipedia]

The i3 window manager is a tiling window manager: it enables power users to operate/arrange/manage application windows in a very fast way in tiles, without any requirements to use a mouse. Alex Booker provides an excellent introduction and overview to the i3 window manager, which is divided into 3 videos: general introduction, configuration, and (visual) fine tuning. In this post we summarize the i3 configuration we use atm for a quick lookup (which is partially based on Alex Booker’s videos).

Installation


sudo apt-get install i3

Logout, then login to i3. The i3 configuration wizard starts automatically if there is no i3 configuration file yet (we recommend using Super as the mod key at this point, because Alt is used by a huge amount of applications for other tasks). You can always remove the i3 config file at ~/.config/i3/config and start the wizard again using i3-config-wizard.

Basic usage

We strongly recommend to go through all the shortcuts in the official i3 reference card (it just takes a moment and is the core of how you will operate i3 afterwards). Be aware that if you are using an alternative keyboard layout, i3 automatically detects which keys are located at the positions that i3 would normally use – so you will be able to use the same physical keys, even if you are using a completely different layout.

After being aware of the basic usage of i3, skimming through the official i3 user’s guide will make sense. This should highlight the possibilities with i3 (in both how to operate i3 and how to configure it), which will make later configuration tasks easier by far.

i3 config file

The main i3 config is located in ~/.config/i3/conf. This file is created by i3-config-wizard at first and can be modified as wished afterwards.

Be aware that changing any i3 config at least requires i3 to be reloaded (“restarted in place”) with Mod+Shift+R. Some configuration also require the underlying application that is started/controlled by i3 (e.g. compton) to be restarted. If i3 restarts those applications on each reload depends on its configuration (that’s the difference between exec and exec_always in the config file). If the underlying application was started with exec, restarting the application by hand or logging out/loging back in is required.

(Re)starting i3 from command line

To start i3 from a native tty command line:

DISPLAY=:0 # or :1 etc...
export DISPLAY
# killall i3 # required in case i3 is running
i3 -c .config/i3/config

To instead restart a running i3 from a native tty command line:

i3-msg reload
i3-msg restart

Media buttons etc.

Most likely i3 does not recognize your media buttons correctly from the beginning. You at first need playerctl to enable control over (parts) of the media buttons, of which you can get different packages (including .deb) here. The i3 FAQ then provides a config snippet that can be copied (appended) to your i3 config file to map keys to the media buttons. Be aware that the number of the pulse audio device may be different (in the script it’s 0, but for others it might e.g. be 1). If e.g. the buttons cause the currently focused window to flicker, but the volume does not change, this might be an indication for using the wrong device. If you want to specify the player that you control with the play/pause/next/previous buttons via playerctl buttons, you use the –player parameter, e.g. –player=rhythmbox. Be sure that the player provides an MPRIS D-Bus interface (e.g. vlc, audacious, spofity, etc). With Rhythmbox, for example, the corresponding plugin has to be enabled first.

Set wallpaper

You need e.g. feh to set a wallpaper in i3:


sudo apt-get install feh

By adding the following to your i3 config file you always set the wallpaper when i3 is started/reloaded:


exec_always feh --bg-scale /path/to/your/wallpaper.jpg

For different wallpaper scaling options, check out the man page of feh (it provides e.g. –bg-center, –bg-fill, –bg-max, –bg-scale, –bg-tile, …)

Launch applications on specified workspaces

At first, you need to find out the xprop window class of your target application. For this, start xprop and click on the application window. The 2nd string under WM_CLASS(STRING) is the string you need to know in the next step: add the following line to your i3 config file (and replace CLASS with the just determined string):


assign [class="CLASS"] 10

10 in this case indicates the nr. of the workspace the application window should be positioned.

Autostart applications

To automatically start applications, add one of the following lines to your i3 config file:


exec APPLICATION_COMMAND


exec_always APPLICATION_COMMAND

exec only executes the command when i3 is started, and exec_always executes the command each time i3 is reloaded. For example, starting your web browser is only useful for each fresh i3 start, but setting the wallpaper is useful to be done each time i3 is reloaded.

Monitor configuration

An easy way to configure the monitor setup using an UI is with arandr (UI for randr):


sudo apt-get install arandr

If you want to make a certain monitor configuration permanent you can a) configure monitors as wished in arandr, then b) save the configuration to a file, and c) add “exec_always CONFIG_FILE” to your i3 config file.

Wifi controls

i3 does not come with a built in UI for to control your wifi. To avoid configuring it via config files (which is still pretty cumbersome in Linux after all those years) you can use e.g. the graphical frontend wicd-gtk:


sudo apt-get install wicd-gtk
wicd-gtk

Change system fonts

One possible cosmetic improvement is to use different system fonts in i3. Alex recommends the Yosemite San Francisco Font: you can download it from its github page (under “manual install”), then change the font entry in the i3 config file to:


font pango:System San Francisco Display 10

Further, changing the font for the used gtk is recommended. You can do this is the gtk configuration file (in ~/gtkrc-2.0 and/or .config/gtk-3.0/…) by changing the font line to e.g.:


gtk-font-name="System San Franzisco 10"

Another option is to use the lxappearance config UI (but it currently seems buggy as not detecting all installed fonts correctly, as long they are not already in use with the system):


sudo apt-get install lxappearance
lxappearance

De-uglify i3

When you previously had Gnome Shell installed, you can use gnome-tweak-tool to configure your look-and-feel and add the following line to your i3 config file to “de-uglify” i3 at startup:

exec --no-startup-id gnome-settings-daemon

For further/other configuration or if the above approach does not work for you you can try lxappearance, gtk-chtheme, and qt4-config:

sudo apt-get install lxappearance gtk-chtheme qt4-qtconfig

Replace dmenu with rofi


sudo apt-get install rofi

In the i3 config file, replace the dmenu-shortcut with e.g.


bindsym $mod+a exec rofi -show run -lines 20 -eh 1.3 -opacity "85" -bw 0 -font "System San Francisco Display 10"

or, to have different colors:


set $bg-color   #2f343f
set $text-color #f3f4f5
bindsym $mod+a exec rofi -show run -lines 20 -eh 1.3 -opacity "90" -bw 0 -bc "$bg-color" -bg "$bg-color" -fg "$text-color" -hlbg "$text-color" -hlfg "$bg-color" -font "System San Francisco Display 10"

Transparency and fading effects

i3 does not provide for transparency or fading effects itself (it has less purpose in doing so, as e.g. windows don’t overlap in a tiling arrangement). To add those, use e.g. compton:


sudo apt-get install compton

and add “exec compton” to your i3 config file. The configuration is for compton is done via ~/.config/compton.conf, which you first have to copy from the example file location. With Ubuntu, this is:


cp /usr/share/doc/compton/examples/compton.sample.conf ~/.config/compton.conf

Afterwards, you can change settings there to your needs. We usually do the following:

  • Increase window fading speed, which is specified in milliseconds between fading steps: “”fade-delta = 5;”
  • Remove transparency from unfocused windows and menues (increases their readability). To do so, comment out “inactive-opacity” and “menu-opacity”.

Replace the i3status bar (bottom/top bar) with i3blocks


sudo apt-get install i3blocks

Copy the example i3blocks config file:


cp /etc/i3blocks.conf ~/.config/i3/i3blocks.conf

And change the value of the “status_command” from “i3status” with “i3blocks -c ~/.config/i3/i3blocks.conf” in your i3 config file.

Then you can customize i3blocks in your ~/.config/i3/i3blocks.conf file. For example:

  • Set the interval of date/time to 1 to have a 1s time update interval.
  • For volume add “command=/usr/share/i3blocks/volume 5 pulse” and set the interval 1 to use the pulse audio volume level with 1s interval.
  • Replace the text of labels with character/utf-8 icons as you like – this saves space in the bar. Alex has some nice examples for this in his own config file on github.

Update notification in i3blocks

The following script checks and prints if updates are available and if a reboot is required after updates:

#!/bin/bash                                                                                                        

# count how many updates we have got
ups=`/usr/lib/update-notifier/apt-check --human-readable | head -1 | awk '{print $1;}'`

# print the results
if [ "$ups" -eq "1" ]
then
  echo "There is 1 update"
elif [ "$ups" -gt "1" ]
then
  echo "There are $ups updates"
elif [ -f /var/run/reboot-required ]; then
     echo 'Reboot required'
else
  echo "Up to date"
fi

This script can be included in i3blocks by adding the following to in the i3blocks config file:

# Update status
[updates]
label=
interval=3600
command=/path/to/update/status/script/from/above

Workspaces on predefined screens

For users using a multi-monitor setup configuring to which screen specific workspace automatically go might be interesting:


# put workspaces on specific screens
workspace 1 output HDMI-1
workspace 2 output DVI-I-1
...

More i3 shortcuts

  • Auto back-and-forth: after switching from workspace A to workspace B, pressing the shortcut for workspace B again to switch back to workspace A. Add “workspace_auto_back_and_forth yes” to enable this feature.

Application configuration

Usability of some applications benefits from some more configuration:

  • The new mail attention add-on for Thunderbird makes i3 raise the urgent notification flag for new mails, so that the corresponding workspace is highlighted.
  • Enabling the “Message Notification” add-on in Pidgin makes i3 raise the urgent notification flag for new messages, so that the corresponding workspace is highlighted.

More hints

As i3 does not come with a built in network configuration UI: to configure networks like VPNs you can use the following (parts of the network-manager and network-manager-gnome packages):

  • nm-connection-editor allows editing network settings
  • nmtui allows for activating/deactivating networks over the command line

i3 does also not come with a built in UI for configuring computer mice. The mouse pointer speed can be adapted with xinput:

  • use “xinput –list –short” to determine the name of your mouse device, then
  • “xinput –set-prop “MOUSE DEVICE NAME” “Device Accel Constant Deceleration” 1.8″ to change the mouse pointer speed. The latter can be added to the i3 config file to automatically keep the speed after a restart of i3.

Backup your i3 configuration

Most (if not all) i3 configuration is located in those 3 files, which consequently are the only ones that need to be backed up:


~/.config/i3/config
~/.config/i3/i3blocks.conf
~/.config/compton.conf

Categories: Linux, Misc

How I learned to type the Neo2 keyboard layout: a review after the first 1.5 years

December 27, 2016 Leave a comment

neo-iconA couple of years back, I was asking myself: should I switch my keyboard layout to a more effective one? If yes, which new layout should I learn? For obvious reasons I searched for reports of people that did such a switch before. And this is why I try to give such a report myself now, after typing Neo2 for about 1.5 years – which seems to be a good point for summarizing my success story with Neo2 so far.

But first: some details about my typing characteristics before I learned typing the Neo2 layout. I…

  • …was “successfully” using the German QWERTZ keyboard layout for something like 12 years with a 10-finger-system.
  • …was typing with somewhere around 450 characters per minute for normal text.
    …did software development for a living and especially disliked the access to special characters my back-then keyboard layout.
  • …didn’t like the idea of using an ineffective keyboard layout in general. The layout I was using back then was a) not optimized for today’s hardware and b) I used it all day as it is the number 1 tool used in my profession, so investing in improvements should really pay off on the long run.

Overview of alternative keyboard layouts

There are (and were back in the day) many alternatives to the layout I used. For some examples, see e.g.:

I looked a bit into heuristically optimized keyboard layouts. Some of them use the same higher layers as Neo2 and just have layer 1 and 2 rearranged heuristically, such as the bone layout (German: http://wiki.neo-layout.org/wiki/Bone). Why didn’t I chose such a layout? Those had/still have less support, as they are not used so widely. This brings additional effort when configuring/using different PCs/hardware.

Additionally, for something so important for me and my daily business I preferred to use something already proven to work well, and would therefore bring less problems with it.

Why use Neo2 instead of other alternatives?

Neo was designed back in 2004 and was optimized for the German language. Due to German being very similar to English from key frequency point of view the “being optimized to German” did not make a big difference to me (and still does not make any, you can rest assured that it’s very comfortable to type English with it). Neo2 has a very good heatmap (optimized for key position and typing interleaving with left/right keys:

keyboard_heatmap_for_german_neo

Though there are arrangements that are a little more effective and further optimized (e.g. heuristically),  when it comes to key frequencies, having such a heatmap still is an amazing thing.

To me, even more important was that access to special characters is solved very cleverly with Neo2. There are 6 layers in total:

  • Layer 1+2 are lower and upper case characters – those are the ones you are probably used to on your keyboard. The “modifier” keys are the Shift keys.
  • Layer 3 are special characters (right below your fingers, e.g. in the home row!). The “modifier” keys are the CapsLock button on the left side and the “#” key on the right side.
  • Layer 4 are other special characters and special keys
  • Layer 5+6 are Greek letters.

The special characters on layer 3 make accessing special characters for programming very easy. And layer 4 is something that is easily underestimated: it features:

  • Keys to control cursor position like up/down/left/right, page up/down, delete left/right, home/end, escape, tab, enter, etc. – all under your left hand.
  • All numbers in the form of a keypad – all under your right hand.

From this point of view, Neo2 is more effective for programmers than e.g. Dvorak, Colemak, or similar keyboard layouts (still, those are pretty cool too). But besides the Neo2 layout having a lively community and already being proven to working well, this was the main reason for learning Neo2 instead of any other layout.

Learning and switching to Neo2

How not to do it

Maybe 3 years before I already had tried Neo2 – for very short time. Back then I set my goal similar to “I want to type in Neo!”, printed a Neo2 layout onto an A4 sheet of paper, switched my keyboard layout to Neo2 and just started typing it. In short: it did no work out. I had to search for every key using the printout, and of course got frustrated over the extremely low speed of typing (which was to be expected) very fast – and quit within hours.

How to do it

After the first try, the goal of switching keyboard layout remained. I wanted to use a more effective keyboard layout/Neo2 someday, as it would just be so much more effective for my everyday usage. The second time (maybe 2 years after the first try) I was better prepared to really perform a switch:

  1. I used KTouch with Neo2 to train single keys – one after another (the KTouch “beginner mode”). I did this is my free time, at work I continued to use my QWERTZ layout. Further, I made sure that I typed all keys with the correct fingers (I had had a slight mash-up with the QWERTZ layout before).
  2. In KTouch I used standard settings, which are minimum 180 chars per minute and 98% accuracy to pass each lesson and unlock the next one. This ensures you don’t try to learn  too much at once, which was the problem with my first try.
  3. Using KTouch I trained about 1/3 of the Neo2 lessons provided. Those were all about introducing and training new character keys. It was no problem to write with my QWERTZ layout at work at the time (switching was smooth).
  4. After finishing about 1/3 of the Neo2-lessons provided with KTouch (within 1.5 months as far as I remember), I did the “all in” thing: I switched all my layouts to Neo2 and typed all texts with it. This included my keyboard at work as well as e.g. my on-screen keyboard on my mobile phone. Of course it was very slow at the beginning again (first few days), but now I learned very fast. After about 2 to 3 weeks of typing, my speed was OK, while I was still learning at a fast rate without requiring any extra training time. This was when typing the old QWERTZ layout became more difficult for me.
  5. Since then I’ve just continued to write Neo2. Once in a while I did some more lessons in KTouch – but these were just for training and comparing typing speeds. But overall, using a typing trainer like KTouch definitely was the “enabler” of learning a new keyboard layout for me.

Progress report after the first 1.5 years

I started learning Neo2 around end of February 2015. Within about 1.5 months (after successfully completing about 1/3 of the lessons in KTouch) I made the “all in” move and switched all my layouts to Neo2. My progress since then:

  • Mid of April (~2 months): about 190 chars/min, 95.5% accuracy in the 1000 English words test from KTouch Neo2.
  • End of April: feeling more comfortable every day.
  • Mid of May (~3 months): about 250 chars/min, 95.5% accuracy in the German/English words test from KTouch Neo2.
  • Mid of June (~4 months): 286 char/min, 98.5% accuracy (09:02 in the “repeat many words test” in KTouch Neo2).
  • End of September (~7.5 months): 286 char/min, 96.3% accuracy (21:13 in the 1000 most frequently used English words test in KTouch Neo2) and 289 char/min, 97.2% accuracy (08:57 in the “repeat many words test” in KTouch Neo2).
  • Beginning of February (~1 year): 337 char/min, 96.8% accuracy (6:50 in the KTouch Neo2 train comma lesson).
  • Mid of February 2016 (~1 year): 330 char/min, 97.2% accuracy (18:20 in the 1000 most frequently used English words test in KTouch Neo2) and 311 char/min, 96.4% accuracy (8:20 in the KTouch Neo2 “repeat many words test”).
  • April 2016 ~1 year 2 months: 318 chars/min with 97.2 accuracy with the KTouch Neo2 congratulation text for finishing Neo2 training. Programming: 241char/min with 96.5% accuracy in KTouch Neo2 shell text (special characters, numbers, …). This pretty much is what I wanted in the beginning – it made me writing code on my keyboard more effectively. Additionally: have the feeling that I need to think less about how I do things, and more about what I want do to. Specially the position keys under left hand at level 4 (move cursor up/down/left/right, page up/down, delete left right, home/end) have proven extremely effective – much more than I initially thought – to quickly move the cursor around when programming.
  • July 2016 ~1 years 5 moths: 333 chars/min with 98.0% accuracy (18:09 in the 1000 most frequently used English words test in KTouch Neo2).

This is an example of how your progress for learning Neo2 in KTouch could look like:

  • Left: progress for one single lesson: usually, you will always increase in speed and accuracy when repeating the same lesson (which is why you are able to learn a new keyboard layout relatively fast if you take it seriously).
  • Right: progress for different/all lessons: usually, you increase in speed and accuracy for a specific lesson, and when you move on to the next lesson your speed and accuracy will be lower for it at the beginning – which is because you are just learning completely new things there. I can scroll far to the left in this view – and it’s a good feeling to see speed and accuracy continuously increasing over time there 😉

 

 

 

 

The final (and frequently asked) questions

Is my typing speed still increasing? Yes, definitely. Was it worth the effort? Would I do it again? Yes, definitely, to both. Though, at the moment I’m still a bit slower in typing regular texts than I was before, programming is definitely faster already. Typing feels less cumbersome: especially complex combinations of symbols/characters are easier to type, and I don’t need to move my right hand anymore for reaching e.g. arrow keys, delete/insert, or similar. Besides making a large number small tasks a little faster (which sums up to a lot in the end), this also just feels more satisfactory.

So, bottom line: in my opinion, especially when your job involves something like programming, learning Neo2 really pays off in the end.

Repair PDFLaTeX generated pdf using GhostScript (Adobe Acrobat Reader error 131)

February 28, 2016 Leave a comment

I tend to do presentations using LaTeX and Beamer, while working on Linux and using TeXLive as LaTeX distribution – which all work fine. But sometimes I need to share these PDFLaTeX compiled presentations with people using Windows and Adobe Acrobat Reader as their pdf viewer. The feedback I usually get back: your pdf is broken, error 131. And frankly, that seems to be true.

Opening PDFLaTeX generated pdf files with Windows Adobe Acrobat Reader results in error 131 – more precisely in the displayed error message “There was a problem reading this document (131)”. Other pdf viewers don’t complain about the pdf, just Adobe Acrobat Reader. A quick solution to repair the pdf file is by using GhostScript:

gs -dSAFER -dBATCH -dNOPAUSE  -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf</code></pre>

Voilà, the pdf file can be opened using Adobe Acrobat Reader – although, the source of the problem still exists of course (generating a pdf file not adhering the standard in the first place).

latexdiff-git: highlight changes between revisions of latex files managed in git

July 31, 2014 1 comment

latexdiff is a useful tool to determine changes between different versions of latex files and highlight them in a pdf (similar to MS word does with tracking changes). latexdiff-git is a wrapper around latexdiff optimized for git (and mercurial, but we’ll only look into git here). With it you can specify a latex document file (which is in a git repository) and a commit hash from that repository to look for changes between the file and its version from the specified commit. Same is possible with e.g. specifying two different commit hashes.

Installation (Linux)

  1. Clone latexdiff-git
    git clone git@gitorious.org:git-latexdiff/git-latexdiff.git
    
  2. All further steps are stated in the README file inside the repository you just cloned:
    1. Ensure you have a ~/.gitconfig file and that it’s accessible for your user.
    2. Add the following lines to .git/config
      [difftool.latex]
       cmd = latexdiff "$LOCAL" "$REMOTE"
      [difftool]
       prompt = false
      [alias]
       ldiff = difftool -t latex
      
    3. Change the checked out script file latexbatchdiff.sh: search for revlatexdiffcmd='please define' and replace it with revlatexdiffcmd='git ldiff'
  3. Place latexbatchdiff.sh somewhere in your path (I tend to place it in ~/bin) and make it executable: chmod +x latexbatchdiff.sh

Usage

You can generate a tex file from differences between a latex file and a revision checked into git with (replace GITHASH and FILE with your git commit hash and latex file)

latexdiff-git -r GITHASH FILE

Alternatively you can generate the tex file from changes between two specific commits of a latex file:

latexdiff-git -r GITHASH1 -r GITHASH2 FILE

To view changes hightlighted in a pdf:

pdflatex *diff*tex # create pdf highlighting diff
evince *diff*pdf # replace evince with your preferred pdf-viewer
Categories: Misc Tags: , , , , , ,

Batch video conversion on Linux command line

A short note on batch video conversion on Linux command line – on the example of converting all MOV in the current folder to AVI and keeping the original files.

find . -iname "*MOV" -exec avconv -i {} -b 18000k -b:a 192k -s 1280x720 {}.avi \;
rename s/MOV\.avi/avi/ *

You can replace the MOV and AVI file extensions in the find command with basically any other format, but may need to play around with the command’s parameters then. Typically used parameters include:

-b video quality
-b:a audio quality
-s video resolution

avconv is part of libav-tools in Ubuntu 14.04, therefore you can install it using:

sudo apt-get install libav-tools
Categories: Linux, Misc Tags: , ,