How to launch Cygwin in the active FreeCommander directory

Under Windows, I rely on trusty FreeCommander for all my file management needs. And I use Cygwin for having my most needed shell programs nearby. Sometimes there is the need to quickly open a Cygwin terminal in the current folder within FreeCommander.Luckily, there is already a popular StackOverflow question for that. Unfortunately, most answers rely on registry editing or installing the additional chere utility. However, the answer by user Tom Kay does neither and works quite well for FreeCommander. Here is how: Continue reading “How to launch Cygwin in the active FreeCommander directory”

Say you have your contacts and calendar synchronised via your own private or trusted ownCloud instance. But then at your workplace, you have to use Outlook for your work stuff. Then there is the occasional late appointment, and you run into collisions because you did not look at your private calendar before accepting a meeting invitation. What to do? Wouldn’t it be nice to see your private calendar as an overlay directly in Outlook?

Search no further, the solution is Continue reading “How to include your ownCloud calendar into Outlook (read-only)”

How to list subdirectories recursively with total size

Just a note to myself, as I always have a hard time understanding the find manpages. To list the directories and subdirectories up to a certain depth, “simply” enter:

find . -maxdepth 2 -type d


Option maxdepth states how deep the subdirectories should be listed, option type restricts output to directories (d).

If a directory listing including size is required, this much shorter snippet does the trick, using du (disk usage), the counterpart to the often-used df (disk free):

du -hd 1

Option h triggers human-readable output, replacing size byte count (5820) with SI prefixed numbers (5.8K), while d limits the recursion depth like before.

How to remap the Win button on a Microsoft Sculpt Comfort mouse

If you use the Microsoft Sculpt Comfort Desktop with its gorgeously sculpted keyboard and the round pebblestone mouse, you might not need the brightly branded “Windows” button on the mouse. Program AutoHotkey to the rescue! Simply remap the Right Windows key (that conveniently does not exist on most keyboards anyway) to any other convenient key press, script, autostring, …

In this example, I map the Browse forward action to the button, because the button below can be configured to browse backwards:

RWin::Browser_Forward

The definitive full-frame graphic command for beamer in LaTeX

2018-06-02: This content has been superseded by this newer post: Finally the definitive full-frame graphic commands for beamer in LaTeX. Look there for an updated version.

After my previous post on the same topic, I have improved upon the command considerably. This time, it is based on Matthew Leingang’s answer on the question Image on full slide in beamer package.

Usage:

\fullframegraphic[optional credits]{path/to/image}


To use, copy this definition in your preamble. Requires package tikz.

\newcommand{\fullframegraphic}[2][]{%
\begin{frame}%
\begin{tikzpicture}[remember picture,overlay]%
\node[at=(current page.center)] {%
\includegraphics[height=\paperheight,width=\paperwidth,keepaspectratio]{#2}%
};%
% optional argument: credits on lower-right corner
\ifx\relax#1\relax\else%
\node[at=(current page.south east), anchor=south east,font=\tiny,text=white,fill=black,fill opacity=.5,text opacity=1,inner sep=2pt,text height=1ex,text depth=.25ex] {#1};%
\fi%
\end{tikzpicture}%
\end{frame}}


Visual example (for the credits overlay):

Source: File:DA_Cambridge_c1937.jpg on Wikimedia Commons

How to add subcategories to templates in WordPress

This is the snippet I have added to my category template in my blog’s child theme. I paste the following snippet usually after the taxonomy-description paragraph. This is how it looks (the two paragraphs Parents and Subcategories):

This is the code:

<?php
$parents = get_category_parents($cat, true, " +++ ");
$parents = explode(" +++ ",$parents);
$parents = array_slice($parents, 0, -2);
?>
<?php if ( count($parents) > 0 ) : ?> <div class="taxonomy-parents"><em>Parents:</em> <?php print(implode(', ',$parents)); ?></div>
<?php endif; ?>

<?php
// Subcategories
$list = wp_list_categories('depth=-1&orderby=name&style=none&echo=0&title_li=&child_of='.$cat);
$list = substr(trim(str_replace('<br />', ', ',$list)), 0, -1); // replace newlines by commas, trim whitespace, cut of final comma
?>
<?php if ( !preg_match("/No categorie/",$list) ) : ?> <div class="taxonomy-subcategories"><em>Subcategories:</em> <?php echo$list; ?></div>
<?php endif; ?>


And then in the (child) theme’s stylesheet, add suitable specification. In my case, I stick to the precedence of similar paragraphs in the Twenty Sixteen theme:

.taxonomy-parents, .taxonomy-subcategories {
color: #686868;
font-size: 0.8125rem;
line-height: 1.6153846154;
}


How to horizontally align beamer columns with surrounding text

If you (like me) assumed that placing two columns width 50% textwidth next to each other would align with preceding or following text on a beamer slide, then you are mistaken (like me).

Fortunately, a discussion on Bug #262: Provide more usable columns environment showed a viable solution in form of the optional argument onlytextwidth.

However, in order to use it successfully, one must then take care of spacing oneself. Here is my result of some experimentation:

Here is the corresponding document source code:

\documentclass{beamer}
\usepackage{mathtools}
\usepackage{listings}
\lstset{basicstyle=\ttfamily}

\usepackage{hyperref}

\begin{document}
\begin{frame}{Testing columns spacing}{How to achieve
correctly spaced columns with beamer}
\emph{The documentation doesn't tell you anything about
the alignment of the columns or the space in between them.
In particular, the side effect of totalwidth (which
changes the columns to be left aligned within the
textarea of the slide rather than center aligned on the
page).}
\vspace{.5cm}
\begin{columns}[t,onlytextwidth]
\begin{column}{.5\textwidth-.25cm}
This slide shows the successfull result to align the
margins of these two columns with the surrounding text to
exactly \lstinline{\\textwidth}.
\end{column}
\begin{column}{.5\textwidth-.25cm}
What to do?

Do your own math and specify column widths with spacing.
These columns have equal width of
\lstinline{.5\\textwidth-.25cm}.
\end{column}
\end{columns}
\vspace{.5cm}
From:
\href{https://bitbucket.org/rivanvx/beamer/
issue/262/provide-more-usable-columns-environment}
{Issue \#262}: Provide more usable columns environment}
\end{frame}
\end{document}


In case you also want to justify all the text on this slide, check out the follow-up post How to align and justify text in beamer columns with surrounding text.

My Python setup

In this post, I summarise my custom settings for my IPython, Matplotlib and IPython Notebook for my Windows machine at work.

IPython

First some aesthetic preferences:

# select qt backend for plotting from terminal
from IPython.terminal.ipapp import TerminalIPythonApp
TerminalIPythonApp.matplotlib='qt'

c = get_config()
# bigger plots in IPython notebooks
c.InlineBackend.rc = {'figure.figsize': (16.0, 8.0), 'savefig.dpi': 72}


These are for productivity, mainly:

# always reload packages interactively

# import mainly used packages
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

# change to pandas default "beautiful" style
pd.options.display.mpl_style = 'default'
# but keep sans-serif fonts (instead of monospace)
plt.rcParams['font.family'] = 'sans-serif'


Matplotlib

For coherence with my employer’s style guide, I set my plot font to Arial with the following two lines:

font.family         : sans-serif
font.sans-serif     : Arial


All this results in the following default plot appearance (here for a Pandas area plot of multiple timeseries):

Share as Gist toolbar button

Once that is prepared, get the file gist.js from minrk’s ipython extensions GitHub repository and place it in in the folder .ipython/nbextensions.

Then add the following lines to file custom.js, located in your profile:

require(["nbextensions/gist"], function (gist_extension) {
});


The next time you launch ipython notebook, a share button should appear in every notebook’s toolbar. The first time you click it, you must paste your GitHub access token. From there on, it will work automatically. Here is how it looks in action:

(And here is the link to the corresponding Notebook: urbs-result-plot.ipynb.)

Full-frame graphics on a LaTeX beamer presentation

2018-06-02: This content has been superseded by this newer post: Finally the definitive full-frame graphic commands for beamer in LaTeX. Look there for an updated version.

This snippet defines the custom command \fullframegraphic. Paste it into the document preamble (header) of your presentation:

\newcommand{\fullframegraphic}[1]{
\begin{frame}
\includegraphics[height=\textheight,width=\textwidth,keepaspectratio]{#1}
\end{frame}
}


Then, you can create a full-frame graphic slide anywhere (outside a frame) using

\fullframegraphic{image}


There are multiple questions with even more answers on this exact question at Stack Overflow. The simplest answer, which I failed to find again, looks like this. Add the following lines to your repo’s .git/config:
[alias]

Simply change remote and branch names to fit yours and from thereon, a git pushall will do all the work.