2014-01-31

Mutt scoring

Eventually you found that making some e-mails distinct on index can be helpful, or you want to sort by some-kind-of-weight. Scoring to the rescue.

Some rules of thumb:
  • add some credit to all e-mail at the start. It lets you decrease scoring later - based on further rules - down to zero, what is a sign of spam; Some people add 2, some 100 at the beginning
  • with the rule above in mind, add set score_threshold_delete=0
  • choose one of the two scenarios: you add points after parsing all rules and based on achieved scoring you want Mutt to "F"lag a message, or you "F"lag a message manually what adds some points to a message (what brings it higher when sorting by score). In the first case add set score_threshold_flag=15, in the latter score "~F" +5
  • if you have a lot of e-mails just as a reference/documentation, and do not read it manually, you can find it useful: set score_threshold_read=5
  • use George Boole algebra: score "~s Apple | ~s apple" +5
  • increase scoring for e-mails you want (score "~f wife@domain.com" +666) and punish mails you hate (score "~s training | ~s Certificate" -100). After that (and score_threshold_delete set) all you need to remove spam is to press '$'.
  • make obsolete obsolete: score "~d >1m" =2
Paint e-mails based on scoring: 
color index  brightcyan      default  "~n 5-15"
color index  brightmagenta   default  "~n 16-100"

You can always score manually executing the commands above in Mutt after a colon:
:score "~f myboss@mycompany.com" +10
and then sort by pressing 'o'.

Useful links:

2012-08-03

Want to connect from Linux to SQL Server?
1. add Linux to domain with CentrifyDC
2. install unixodbc
3. install Microsoft ODBC driver manager
4. optionally pyodbc
5. install krb5-user
6. addspn in domain
7. set static port on SQL Server
8. $ kinit
9. $ sqlcmd -Sdatabase-server,port

More details soon, or e-mail me.

2011-02-24

Wrapper on check_nt!UPTIME

#!/bin/bash

HOSTADDRESS=$1
MINWARN=$2 # in hours
MINCRIT=$3 # in hours

SECONDS=`/usr/local/nagios/libexec/check_nt -H $HOSTADDRESS -p 12489 -s $ECRET$ -v COUNTER -l "\\System\\System Up Time"`
#### IS:           6817
#### SHOULD BE:    WARNING: uptime: 1:53 < warning|'uptime'=6817000;172800000;3600000;

HOURS=$(( $SECONDS / 60 / 60 ))
SECONDSINHOURS=$(( $HOURS * 60 * 60 ))
REMAININGSECONDS=$(( $SECONDS - $SECONDSINHOURS ))
MINUTES=$(( $REMAININGSECONDS / 60 ))
FORMEDUPTIME="${HOURS}:${MINUTES}"

if [[ $HOURS -lt $MINCRIT ]]; then
    echo "CRITICAL: System started ${FORMEDUPTIME}h ago."
    exit 2
fi

if [[ $HOURS -lt $MINWARN ]]; then
    echo "WARNING: System started ${FORMEDUPTIME}h ago."
    exit 1
fi

echo "OK. Uptime $FORMEDUPTIME.|'uptime'=${SECONDS}000;7200000;3600000;"

2010-07-14

Multisite Drupal

postgres=# CREATE DATABASE example_eu OWNER drupal6 ENCODING 'UTF8';
cp ./drupal/sites/default ./drupal/sites/www.example.eu
vim ./drupal/sites/www.example.eu/dbconfig.php
vim /etc/apache2/sites-available/example.eu
a2ensite example.eu
firefox https://www.example.eu/

2010-06-11

Cutting mailq

Removing selected mail messages from postfix's mail queue based on sender on recipients:


mailq | tail +2 | grep -v ’^ *(’ | awk ´BEGIN { RS = "" }
# $7=sender, $8=recipient1, $9=recipient2
{ if ($8 == "user@example.com" && $9 == "")
print $1 }
´ | tr -d ’*!’ | postsuper -d -

2010-01-28

Print folded book in Evice

To print folded "book" in Evince its necessary to define what pages and in what order to print on both sides.

If the number of pages is not divided by 4, increase it (e.g. 62 increase to 64).

Then generate two series of page numbers:

#!/usr/bin/perl -w

use strict;

my $pages=64;
my $modifier=0;

for (my $i=1; $i<=$pages/4; $i++) {
  my $left_page  = $pages-$modifier;
  my $right_page = $modifier + 1;
  print "$left_page,";
  print "$right_page,";
  $modifier+=2;
}

print "\n";

$modifier=1;

for (my $i=1; $i<=$pages/4; $i++) {
  my $right_page = $modifier + 1;
  my $left_page  = $pages-$modifier;
  print "$right_page,";
  print "$left_page,";
  $modifier+=2;
}

print "\n";
exit 0;

Paste it in the print form (without the last comma).

2009-10-06

List of MySQL grants

The command line shows list of all grants on all databases, including root@locahosts. It also shows encrypted passwords as they exists in mysql.user table.

mysql -Bse "SELECT CONCAT('SHOW GRANTS FOR \'', user ,'\'@\'', host, '\';') FROM mysql.user" | mysql -Bs | sed 's/$/;/g'