Install latest version of duplicity on Debian Wheezy

First make a folder for the duplicity sources:
mkdir /home/myuser/duplicity
cd /home/myuser/duplicity

Download the latest version of duplicity, e.g.:
wget http://code.launchpad.net/duplicity/0.6-series/0.6.24/+download/duplicity-0.6.24.tar.gz

Unpack it in the current folder:
tar -xvf duplicity-0.6.24.tar.gz

For compiling and installing python applications we need a two more packages:
apt-get install python-setuptools python-dev

Now we are ready to install duplicity by changing in the extracted folder and running the setup:
cd duplicity-0.6.24
python setup.py install

UTF-8 encoded AJAX calls

Sometimes you want to do a HTTP POST via jQuery/AJAX with enforced UTF-8 encoding. Therefore you have to use the method $.ajaxSetup, cause to set the encoding in $.ajax doesn’t seem to be enough.

Here is an example out of an application using jQuery UI Autocompletion:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  $(document).ready(function() {
    $("#mydropdown").autocomplete({
      source: function(request, response) {
 
        $.ajaxSetup({
          contentType: "application/x-www-form-urlencoded;charset=utf-8",
          type: "POST"
        });
 
        $.ajax({
          url: '/mypath/myapp/myajax.php',
          dataType: 'json',
          data: request,
          success: function(data) {
            response(data);
          }
        })
      },
      minLength: 2,
      messages: { noResults: "", results: "" }
    });
  });

How to enable Digest Authentification over HTTP in Apache 2.2

The often used basic Authentification for HTTP transmits sensitive userdata (username & password) in a very insecure way. The transmitted data can be transformed into plaintext in just a few seconds. A more secure way to accomplish Authentification is the method via digest auth. It makes use of the MD5 hashing algorithm.

Enabling digest auth in Apache 2.2 is rather simple. At first you have to activate the module mod_auth_digest. Therefore search the following line in apache/conf/httpd.conf:

1
#LoadModule auth_digest_module modules/mod_auth_digest.so

and change it to:

1
LoadModule auth_digest_module modules/mod_auth_digest.so

Afterwards you have to create a user file. For this purpose there exists the tool “htdigest.exe”, which can be found in apache/bin:

htdigest -c /path/to/your/new/digest.passwd realm username

Note: realm is the name of the closed area (displayed when the browser asks you for login). Amongst other things the realm is used for generating the response.

Finally you have to create a file called .htaccess in the folder you want to protect. Fill the file with the following, respectively make it fit to your needs:

1
2
3
4
5
6
7
AuthType Digest
AuthDigestProvider file
AuthUserFile /path/to/your/new/digest.passwd
AuthName "NameOfTheRealm"
AuthDigestDomain /YourPath/ http://YourDomain.com/YourPath
AuthDigestNonceLifetime 300
require valid-user

Restart Apache now. Afterwards you should be prompted to enter your username and password by accessing http://yourdomain.com/yourpath via browser.

My favorite plugins for Miranda IM

After using Miranda IM for a few years now, I’m still enthusiastic about it.
There are a couple of plugins which make this messenger so powerful.
Installing plugins in Miranda IM is rather simple: just copy the downloaded
.dll-file into your Miranda install folder (default is C:\Program Files\Miranda IM)\Plugins.
In the following I want to introduce my favorite ones:

History++
The standard history functionality of Miranda IM is very rudimentary.
With the History++-Plugin you add some useful features concerning the history.
For example it provides a comfortable search & filter feature, bookmarks,
functions for exporting, password protection, and so on.

History++ plugin for Miranda IM

History++ plugin for Miranda IM

PopUp Plus
For notification purposes it might be useful to install a plugin for viewing popups,
e.g. PopUp Plus. It offers a wide range of settings. For noticing contacts going online
you should install Contact Status Notification additionally.

PopUp Plus plugin for Miranda IM

PopUp Plus plugin for Miranda IM

OTR (Off-the-Record)
The “official” ICQ-Client doesn’t offer any possibility to encrypt conversations.
Messages are transfered in plaintext, what is insecure. Experienced users are
able to read your conversations by sniffing your network. With the OTR plugin
you can enable encryption for messaging.

Off-the-Record plugin for Miranda IM

Off-the-Record plugin for Miranda IM

FTP File YM
Sometimes the filetransfer over Miranda IM to a contact might not work or you want to
send a file to several contacts. In this case FTP could be an alternative solution. With FTP File YM
you can upload and manage files via FTP in a very comfortable way. After uploading a file succesfully
the plugin is able to automatically paste the download URL in the message window or delete the file
after a given delay. Of course you need a FTP server (respectively webspace) to get this working.

FTP File YM (picture taken from addons.miranda-im.org)

FTP File YM (picture taken from addons.miranda-im.org)

Tomcat 6 and UTF-8 (German umlauts)

When sending POST data from a JSP to a Servlet, it may encouter that they won’t get encoded properly. This effect especially occurs by using german umlauts. It seems that the POST data arrived in the wrong encoding, but that’s what just did not happen. The standard character encoding in Tomcat is ISO-8859-1, which won’t work for the umlauts. To force Tomcat to use UTF-8, do the following:

web.xml (as child of the web-app element):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!--CharsetFilter start-->
    <filter>
        <filter-name>Filter Encoding</filter-name>
        <filter-class>my.package.FilterEncoding</filter-class>
        <init-param>
            <param-name>requestEncoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
    </filter>
 
    <filter-mapping>
        <filter-name>Filter Encoding</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!--CharsetFilter end-->

Add a class named “FilterEncoding.java” in my.package with this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package my.package;
 
import java.io.*;
import javax.servlet.*;
 
public class FilterEncoding implements Filter {
    private String encoding;
 
    public void init(FilterConfig config) throws ServletException {
        encoding = config.getInitParameter("requestEncoding");
 
        if (encoding == null) {
            encoding = "UTF-8";
        }
    }
 
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain next)
            throws IOException, ServletException {
        // Respect the client-specified character encoding
        // (see HTTP specification section 3.4.1)
        if (null == request.getCharacterEncoding()) {
            request.setCharacterEncoding(encoding);
        }
 
        next.doFilter(request, response);
    }
 
    public void destroy() {
    }
}

Make sure that all documents are encoded in UTF-8 also, as well as the database.
For JSPs: <%@page contentType="text/html" pageEncoding="UTF-8"%>

Also see: Tomcat Wiki

Hiding an empty section in CrystalReports

Recently I had to hide a section in CrystalReports (Visual Studio Designer) when a specific variable becomes null. Right-click the section to be hided and open the section expert. Set up as follows:

Surpress Section

  1. Surpress (no drilldown)
  2. Add formula
  3. Insert the following into the editor:
1
2
3
4
if(IsNull({Befehl.myfield})) then
true
else
false

Distinct Rows in DataTable

After writing some Comparers and other stuff, I realized that there is a very simple method to
get a DataTable without duplicate DataRows. The way it works is described here:
http://www.c-sharpcorner.com/blogs/BlogDetail.aspx?BlogId=230

In fact it is one simple line to get the distinct rows:

1
DataTable distinctTable = originalTable.DefaultView.ToTable(true);

WPF RibbonTab Click Event

You may have noticed that there is no “Click”-event for a RibbonTab in WPF.
With a smart workaround you can although easily solve this problem.

Catch the SelectionChanged-event offered by the Ribbon-object:

1
2
3
4
5
6
private void Ribbon_SelectionChanged(object sender, SelectionChangedEventArgs e) {
RibbonTab r = e.AddedItems[0] as RibbonTab;
if(r == null) return;
 
switch(r.Name) {
...