Tomboy to Zim notes conversion

Updated: 2008-03-25


The script provided here is useful if you for some reason would like to convert your Tomboy notes to a set of notes for the similar Zim application. Both are desktop wiki style note taking applications. While Tomboy uses the Mono framework, Zim uses Perl and is in general considered to be leaner on resources than Tomboy.


This small python script converts notes written by the Tomboy application to notes for the Zim application. It does most of the work of conversion but some Tomboy formatting does not exists in Zim and is hence stripped of the notes (different text sizes, fixed width). Nested bullet lists in Tomboy is converted to a flat bullet list in Zim. Besides this the script does a descent conversion job, I think.


Usage:


Download the script. Make it executable with 


$ chmod a+x tzim.py


Run


$ <dir-path to tzim.py>/tzim.py


You will be asked for the path to the Tomboy notes directory. Press return for the default location (~/.tomboy). Then you will be asked where to put the zim notes. Default is current directory. After the conversion, open zim and add a new repository (i.e. the conversion directory). Walk through the notes and check that they are ok. 


This is a simple script without ambition to be perfect. The original tomboy notes are not affected by the conversion so the data should be safe under all circumstances. Feedback on enhancements would be appreciated as well as tomboy notes that did not convert. Email <bengt at blafs removethis com>. The software is distributed under the GPL.


Link to Zim - a desktop wiki and outliner.

# Rev:      1.2.1                                                                               #

# Date:     2008-03-25                                                                          #

# Changes:  Corrected typo in dialog. Translates tomboy's monospace to zim verbatim             # 

# Rev:      1.2                                                                                 #

# Date:     2008-03-24                                                                          #

# Changes:  Much revised code. Should be more robust against Tomboy note format now. Also added #

#           support for the new "Notebooks" concept (i.e. two-level name-spaces)                #

# Rev:      1.1                                                                                 #

# Date:     2008-03-08                                                                          #

# Changes:  Fixed an issue when Create date on tomboy note does not exist. Now displays both    #

#           "Last changed" and "Create date" (if these exists) and conversion date. Fixed       #

#           various issues with that could hang the script. Added a few character subs.         #

# Filename: tzim.py                                                                             #

# Rev:      1.0                                                                                 #

# Date:     2007-07-28                                                                          #

# Changes:  First version                                                                       #


MyPasswordSafe to KeePass DB conversion

This script takes as input a .txt file that has been exported from MyPasswordSafe and formats it into a CSV file that KeePass (http://keepass.info/) can import. While MyPasswordSafe is a simple and stable password store it does not seem to be maintained anymore (see http://www.semanticgap.com/myps/), and it is not cross-platform. I opted for KeePassX instead (http://keepassx.sourceforge.net/) which has variants for all major OS's. But migrating password stores is usually a pain in the a**. Here is how to do it for this case.


Using MyPasswordSafe (ver 0.6.7 tested) save your password database using the "Plain UNENCRYPTED Text (*.txt)" export format, to a .txt file, for example "pass.txt". Then run this script with "pass.txt" as input (when asked for, not as parameter):


$ chmod a+x my2key.py

$ ./my2key.py

Exported .txt file from MyPasswordSafe: pass.txt

CSV data written to "pass.csv"


The script produces a "pass.csv" file in your current directory. This "pass.csv" can be imported into keypass using the import CSV option. Note that KeePassX can't import CSV files so you have to go via KeePass for Windoze... :( I actually installed KeePass (ver 1.0.7) under wine and imported the CSV file and saved it in the default *.kdb format. This file could then be opened in KeePassX :D )


This sounds complicated, but compared to re-write all password records it is a breeze...



ISO week function

Every now and then i would like to know what week number it is now. I can get it from a a calendar application such as Evolution or from the calendar applet in the panel, but it would be nice to get it from the shell also, in an easy way. Thus produced this simple little script. Cut and paste it to a file with name "isow", "chmod +x isow" and dump it to /usr/local/bin, and you have a useful utility.

#!/bin/sh

#

# ISO week function

# Uses `date' function to present various ISO date formats

# 2005-11-12

# Bengt J. Olsson

#

if [ "$1" = "-d" ] ; then

  date --iso-8601

elif [ "$1" = "-dt" ] ; then

  datum=`date --iso-8601` ; datum="$datum `date +"%T"`"; echo $datum

elif [ -z "$1" ] ; then

  date +"%V"

elif [ ${#1} -gt 5 ] ; then

  date --date=$1 +"%V"

else

  echo "Usage: isow [-d|-dt|-h]"

  echo "                   prints ISO week number"

  echo "             -d    prints ISO date"

  echo "             -dt   prints ISO date + local time"

  echo "             -h    prints this help message"

  echo "       isow YYYYMMDD|YYYY-MM-DD prints ISO week number of given date"

fi


Trivia: Unix time epochs

Sun Feb 14 10:26:13 UTC 2010

Following is a table of semi-interesting unix time epochs. Unfortunately, at the time of writing, there are no really interesting epochs in sight, such as "1234567890", or so. So you have to keep up with these somewhat far-fetched numbers instead... :)

1000000000 Sun Sep  9 01:46:40 UTC 2001

1111111111 Fri Mar 18 01:58:31 UTC 2005

1222222222 Wed Sep 24 02:10:22 UTC 2008

1234567890 Fri Feb 13 23:31:30 UTC 2009

1333333333 Mon Apr  2 02:22:13 UTC 2012

1357913579 Fri Jan 11 14:12:59 UTC 2013

1357997531 Sat Jan 12 13:32:11 UTC 2013

1444444444 Sat Oct 10 02:34:04 UTC 2015

1555555555 Thu Apr 18 02:45:55 UTC 2019

1666666666 Tue Oct 25 02:57:46 UTC 2022

1777777777 Sun May  3 03:09:37 UTC 2026

1888888888 Fri Nov  9 03:21:28 UTC 2029

1999999999 Wed May 18 03:33:19 UTC 2033

2000000000 Wed May 18 03:33:20 UTC 2033

2111111111 Mon Nov 24 03:45:11 UTC 2036

2147483647 Tue Jan 19 03:14:07 UTC 2038    (Last second of Unix time)

If you wanna try yourself, try


Linux:


$ for i in 1000000000 1111111111 1222222222 1234567890 1333333333 1357913579 1357997531 1444444444 1555555555 1666666666 1777777777 1888888888 1999999999 2000000000 2111111111 2147483647; do echo -n $i$'\t'; date -u -d @$i; done


With Mac OS X:


$ for i in 1000000000 1111111111 1222222222 1234567890 1333333333 1357913579 1357997531 1444444444 1555555555 1666666666 1777777777 1888888888 1999999999 2000000000 2111111111 2147483647; do echo -n $i$'\t'; date -j -u -f %s $i; done


Install Zim on a Mac

2011-03-06

To install zim on a Mac you can either install directly via macports, but then an old 0.28 perl based version is installed. To have the latest version you must install from source. The installation instructions one http://zim-wiki.org/install.html is versy terse, to put it mildly... the following notes should however guide someone with a little experience of macports and the shell.

To install Zim 0.50 on my mac (os x 10.6.7) the following steps were required for me:

(the latter should be made persistent in for example ~/.bashrc).

Start by just typing "zim" at the command line.

Efergy e2 IR trådlös elmätare

2013-03-09

Efergy e2 IR är en relativt billig elmätare som fungerar genom att man sätter en optisk pulsräknare på elbolagets elmätare hemma som skickar informationen trådlöst till en basenhet inomhus, som man i sin tur kan ansluta till en dator för att samla statistik etc. Bl a Clas Ohlson har den i sitt sortiment.

Trots att det i manualen står att man ska ansluta sensorn mot en IR diod och inte mot den synligt blinkande dioden så funkar den utmärkt mot den synligt blinkande dioden. Har en Telvent elmätare från Vattenfall som inte har en IR diod som blinkar ut effektförbrukningen utan det finns bara en vanlig röd blinkande diod som blinkar 1000 ggr per kWh.

Som sagt, den räknar pulser från elmätaren, och skickar en uppdatering till inomhusenheten var 30:e sekund. Med 1000 pulser per kWh => 1000 pulser per 3600 kWs => 1 puls per 3.6 kWs => 1 puls / 30 s = 3.6 kWs / 30 s = 120 W

Alltså 1 puls per 30 sek = 120 W. Upplösningen är alltså 120 W och displayen visar mycket riktigt husets effektförbrukning i multiplar av 120W (tyvärr med något avrundningsfel så den visar typ 7199 W isf 7200 W).

Räkna pulser på elmätaren framstår som ett robust och nogrannt sätt att mäta totalförbrukningen. En nackdel är att behöva vänta 30s - 1 minut för att kunna se resultatet av en förändring (efter att ha slagit av ett element t ex). Ofta hinner andra källor slå av/på medan man väntar. Men för längre mätningar borde den ge väldigt exakt svar.

Programvaran är ganska spartansk och ger i princip bara statistik ner till tim nivå. Detsamma gäller export funktionen till Excel. Skulle vara trevligt att kunna få ut rådatan i pulser per 30 s och själv kunna processa den. USB kommunikationen mot Mac är "sådär" vilket betyder att jag som regel måste dra ut och sätta i USB sladden mellan dator och inomhusenheten varje gång jag ska hämta data till Macen. Kanske funkar bättre med PC?

Men på det hela taget funkar den som det ska och är förhållandevis billig.