Mails als Anhang in Mutt versenden

Statt des bekannten

a

für »Datei anhängen« verwendet man

A

Dann kann man seine Ordner durchsuchen und sucht sich die Nachricht(en) heraus, die man an die aktuelle Mail anhängen möchte. Markiert diese mit

t

und geht dann mit

q

wieder zurück in die Mail-Ansicht. Dort sollten die ausgesuchten Mails in der Anhangsliste auftauchen.

Einfacher Rechner für die Bash

Da ich hier und da kleinere schnelle Berechung auf dem Numpad machen muss, stört im deutschen Tastaturlayout das Komma, da zum Beispiel bc kein Komma als Dezimaltrenner sondern einen Punkt erwartet. Wie das halt im englischen so üblich ist. Da her habe ich mir eine keine Funktion gebaut, bei der man Kommata ein und die diese auch wieder ausgibt.

Das ganze funktioniert nur mit einfachen Berechnungen und rundet auf die zweite Dezimalstelle.

Einfach in die .bashrc eintragen:

# simple calculator
calc () {
  echo "scale=2;$@" | sed "s/,/\./" | bc | sed "s/\./,/"
}

Diceware Passwörter mit der Shell generieren

Ich hab mir ein kleines Shellskript geschrieben, dass mir sichere Diceware-Passwörter generiert. Wer nicht weiß, was Diceware ist und warum die relativ sicher sind, dem seien folgende Links ans Herz gelegt:

Das ist natürlich ein typischer Fall von NIH, weil es für die Bash/Shell oder auch online wahrscheinlich hundert andere und gut funktionierende Tools dafür gibt, aber selber programmieren und grübeln macht einfach deutlich mehr Spaß.

Die Benutzung ist relativ einfach:

$ ./roll_password.sh

gibt ein Passwort mit fünf Wörtern (english) aus. Folgende Argumente können mit übergeben werden:

  • -c bestimmt die Anzahl der Wörter, die das Passwort haben soll (standard: 5)
  • -l die minimale Zeichenanzahl des gesamten Passwortes (standard: 14)
  • -w Wortlistendatei aus denen sich das Passwort generieren soll (standard diceware_wordlist_en)

Für Schlüssel-Signierungen und Kryptographie würde ich die generierten Passwörter nicht benutzen, dafür ist die $RANDOM-Umgebungsvariable nicht zufällig genug, aber als Passwörter für typische Online-Dienste sind sie sehr gut geeignet.

Das Skript kann man hier herunterladen. Im Download enthalden sind das Shellskript, die englische und die deutsche Diceware-Wortlistendatei.

roll_password.tar.gz

Und hier noch ein bisschen Skript, für die, die nur daran interessiert sein sollten.

#!/bin/bash
#
# Name: roll_password.sh
# Description: This script rolls a random passphrase based of a wordlist (Diceware).
# Author: Tommy Schmucker
# Created: 2012-06-08
# Modified: 2012-09-25
# Version: 0.2
#

usage()
{
	cat << EOF

This script rolls a random pass phrase based of a wordlist (Diceware).

usage: $0 [-h] [-c number] [-l number] [-w file]

-h Show this message
-c Count of words in the pass phrase
-l Minimun length of the pass phrase
-w Wordlist file

EOF
}

count=5
wordlist=diceware_wordlist_en
min_length=14
phrase=

while getopts "hc:l:w:" option; do
	case $option in
		h)
			usage
			exit 1
			;;
		c)
			count="$OPTARG"
			;;
		l)
			min_length="$OPTARG"
			;;
		w)
			wordlist="$OPTARG"
			;;
		?)
			usage
			exit
			;;
	esac
done

[ -e "$wordlist" ] || { echo "$wordlist does not exists, exiting"; exit 1; }

roll_number()
{
	number=
	for i in `seq 5`; do
		roll=`expr $RANDOM % 6`
		digit[i]=`expr $roll + 1`
		number=$number${digit[i]}
	done
}

get_word()
{
	word=
	roll_number
	word=`cat $wordlist | grep $number | awk '{print $2}'`
}

get_phrase()
{
	for j in `seq $count`; do
		get_word
		if [ $j == 1 ]; then
			phrase="$word"
		else
			phrase="$phrase $word"
		fi
	done
}

get_phrase
length=`echo -e "$phrase\c" | wc -m`

if [ $length -lt $min_length ]; then
	echo $'\n'"Phrase \"$phrase\" is too short ($length chars)."$'\n'"You should run the command again!"$'\n'
else
	echo $'\n'"$phrase"$'\n'
fi

Quick & Dirty: Shellscript »batchzip«

Für den täglichen Bedarf an wiederholenden Aufgaben schreibt man sich ja oft kleine Shellscripte. Hier hab ich ein eines, welches Dateien gleichen Namens aber unterschiedlicher Dateiendung zusammen in ein Zipfile packt.

Kann man unter anderem gut gebrauchen, wenn man Projektdateien hat. die ja oft projekt.txt, projekt.docx, projekt.psd, projekt.pdf etc. heißen.

Das Script sollte auf jedem System mit Standard-Shell und zip und rm funktionieren.

Herunterladen kann man sich das auch hier: batchzip

#!/bin/sh
#
# Name: batchzip
# Description: This script zips files with same basename (ignoring the extension).
# Author: Tommy Schmucker
# Created: 2012-05-13
# Modified: 2012-05-16
# Version: 0.3
#

usage()
{
	cat << EOF

This script zips files with same basename (ignoring the extension).

usage: $0 [-h] [-r] [-d directory]

-h Show this message
-d Input directory
-r Remove original files
EOF
}

dir=`pwd`
rm_orig=0
me=`basename $0`

zip=/usr/bin/zip
rm=/bin/rm

[ -x $zip ] || { echo "No such executable: $zip"; exit 1; }
[ -x $rm ] || { echo "No such executable: $rm"; exit 1; }

while getopts "hrd:" option; do
	case $option in
		h)
			usage
			exit 1
			;;
		r)
			rm_orig=1
			;;
		d)
			dir="$OPTARG"
			;;
		?)
			usage
			exit
			;;
	esac
done

[ -d "$dir" ] || { echo "$in_dir is not a directory, exiting"; exit 1; }
dir="${dir%/}"

for this_file in "$dir"/*; do
	basename=$(basename "$this_file")
	name=${basename%.*}
	if [ ! -h "$this_file" ] && [ "$basename" != "$me" ]; then
		$zip -j "$dir"/"$name".zip $this_file
		if [ "$rm_orig" == 1 ]; then
			$rm "$this_file"; echo "$basename removed."
		fi
	fi
done

yab_navigation – A navigation management plugin for Textpattern

Grab it here
yab_navigation_v0.1.beta.zip
or here
yab_navigation_v0.1.beta.tar.gz

There are a couple of browser issues this time, namely for Opera, all Internet Explorer versions and Konqueror. Some are CSS-related, some Javascript related. Because of these issues this is a beta release. I will try to fix these issues asap.

Feature Screencast

Feature Screencast of yab_navigation from trenc on Vimeo.

What you need to know

The navigation used and generated by yab_navigation is based on a »simple« template of Textpattern tags (<txp:variable />, <txp:section_list />, <txp:article_custom /> etc.). This navigation will be saved in a form called »yab_navigation« (Opps!). This form will be created automatically.

Since the navigation is saved in this form you can call the navigation with the following command in your page template:

<txp:output_form form="yab_navigation" />

And your articles you can call simply with:

<txp:if_individual_article>
  <txp:article status="4" limit="1" />
<txp:else />
  <txp:article status="5" limit="1" />
</txp:if_individual_article>

in your page template(s).

For your frontpage you need a section with the value »On front page« set to »yes« and the same title as the home_title in the configuration (see below).

That’s all actually, but

What you really need to know

Since Textpattern sections and articles are completly different in behaviour and database structure and they are not only pages – as maybe known from other CMS – this plugin can only be an approach, of course. For understanding the concept I have to explain something.

The first section on the left side in your backend navigation will represent your frontpage aka your home. So the name of this section is only shown in the plugin, The real name, which is shown as a link in your frontend navigation is set in the config (see below).

The first article (first list point) of every section in the backend navigation will represent the parent section in the frontend navigation. This article will always be fixed (status 5) and is not displayed in the frontend navigation. So the name of the article is only shown in the backend navigation.

The rest of the articles will be shown in the frontend navigation in the order you choose.

What you maybe need to know

When you install the plugin and you go to the backend navigation, your whole navigation is shown of the right.

Reload the site again

Now your navigation should be shown on the left side but maybe it looks weird. This is because the plugin reads the whole stuff from database and not from a navigation template, because this is still empty. You have to move a section to force the generating of the navigation template. When done, reload the backend page again.

Now you should see on the right side a place where you can see hidden or new detected sections – if they exist.

If something won’t work or you can’t see the navigation on the left side, go to you form templates and empty the yab_navigation form. Then begin anew in the navigation backend.

Useful things you need to know

Every new created section is hidden by default, you have to move it from the right side in your backend navigation. Every created article is hidden by default, except if it is the first article of a section, then it’s fixed.

Btw. hiding the first article of a section doesn’t really make sense. :)

Renaming a section or an article will not change the name of section or the URI of the article. It will only rename the title of the element. I’ve decided for this behaviour because of the URI consistence (»Cool URI’s don’t change!«).

If you ever delete or rename a section in the Textpattern section menu you are lost.
Not really but …
If you have deleted a section this way you only have to hide this section in the backend navigation. Next time (or after a reload) this section will disappear.
If you have renamed a section this way … uh … fucked up! You have have to empty the yab_navigation form and build your navigation in the backend anew. Sorry!

Really useful things you need to know

There are configuration options for the plugin. You will find them in an array $yab_nav_prefs in the plugin code:

Option Description Default
home_title The title of the frontpage. Has to be the same title as your frontpage section title. Home
sort The sort order for the articles position asc
active_class Active class for sections or articles active
passive_class Passive class for sections or articles passive
exclude_sections Here you can completly exclude sections from navigation listing (comma delimited) (empty)
exclude_articles Here you can set sections, which articles will not be listed in the navigation. Useful for a news section or a section which does not have a single article as content. And you can’t move other articles in this section in the backend. (comma delimted) (empty)
section_default_page Default page template when creating a section default
section_default_css Default CSS when creating a section default
section_default_rss Should be created sections include in RSS Feed? 0
section_default_frontpage Should be created sections on frontpage? 0
section_default_searchable Should be created sections searchable? 1
jquery_ui The link to the jQueryUI Script min. JS from Google CDN
article_limit Hard limit for backend navigation article list 30

If you develop sites locally with no internet connection or you don’t like Google, you can change the jquery_ui link to a local jQueryUI framework. If you want to minfy the script, you don’t need to load the complete jQueryUI framework. The only things you need are Core, Widget, Mouse and Sortable. (http://jqueryui.com/download)

The function yab_nav_gTxt below the configuration array is used for the localisation and language. You can edit this on your own.

Other things you need to know

Deleting sections or articles will not be implemented. For deleting sections or articles you have to go the standard way.
The rights management (user privileges) could be bypassed by this plugin, if you set the rights for this plugin lazier than other rights are (for example access to editing sections in the section tab).
The plugin does only know the article status fixed (5), live (4) and hidden (2). Other status – as draft or pending – will be overwritten!

Things you really don’t want to know

This plugin is made with some Javascript, jQuery, jQuery UI, XML (really), AJAX, PHP, Textpattern, Debian, Kate, Firefox/Iceweasel. I like the Allman style for php coding with a maximal measure of 80 chars – if you ever look at the plugin code. And if you have seen the feature screencast, this is made with recordMyDesktop and converted with mencoder.

libdevmapper1.02 missing LSB tags and overrides

Sollte jemandem die Meldung bei einem Update auftauchen – genauer bei einem Update zum »dependency based boot system« – einfach mal nachschauen, ob libdevmapper1.02.1 schon bzw. zusätzlich installiert ist. In dieser Version sind die fehlenden LSB-Header gefixt. Wenn ja, die veraltete (deprecated) Version entfernen (purge):

apt-get remove --purge libdevmapper1.02

und die Umstellung auf das neue Bootsystem erneut anstoßen:

dpkg-reconfigure sysv-rc

| ältere Einträge