Monthly Archive for October, 2007

Disabling Shell History Logging

It is just a simple setting I need everytime installing a new unix machine. May be it’s paranoid but in my opinion the file-based history logging should be disabled for security reasons – at least in the root account. You can easily do that by open the .bashrc file in the particular home directory and add the following line(s):

export HISTFILESIZE=0

Disables the file-based history logging.

export HISTSIZE=0

Disables the history logging.

By the way zero in the two statements above means: 0 entries in the history = history is disabled :)

Adding locales to Ubuntu

Lately I was confronted with the problem making Gallery2 (which I installed here) multilingual. Of course Gallery2 supports nearly “all” languages out of the box. The only additional thing you have to do is installing gettext and the corresponding locales. Apropos locales: I think that’s very well to say but how can you do this the command line way?

Firstly open the following file, find your favored locale and copy the line into the clipboard:

/usr/share/i18n/SUPPORTED

Now paste the previously selected locale into the following file:

/var/lib/locales/supported.d/local

Finally let the package manager update the new locale settings:

dpkg-reconfigure locales

That’s it!

MSBuild XSLT Task

Regarding my former article now I’d like to give you a further example for a helpful MS Build task – namely XSLT.

The following task implementation takes the definitions of a source file, a target file as well as a XSLT file and transforms the file by using these properties. Internally it uses the method XslCompiledTransform.Transform() for the transformation process. As you can see at line 40-43 it’s a only a simple code snippet:

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
 
namespace XSLTTask
{
    public class XSLT : Task
    {
        private string xsltFile;
 
        private string sourceXmlFile;
 
        private string targetXmlFile;
 
        [Required]
        public string XsltFile
        {
            get { return xsltFile; }
            set { xsltFile = value; }
        }
 
        [Required]
        public string SourceXmlFile
        {
            get { return sourceXmlFile; }
            set { sourceXmlFile = value; }
        }
 
        [Required]
        public string TargetXmlFile
        {
            get { return targetXmlFile; }
            set { targetXmlFile = value; }
        }
 
        public override bool Execute()
        {
            bool result = true;
 
            Log.LogMessage("Transforming from {0} to {1} using {2}",
                SourceXmlFile, TargetXmlFile, XsltFile);
 
            try
            {
                XslCompiledTransform xslTransform = GetXslTransform(XsltFile);
                XmlReader xmlReader = GetXmlReader(SourceXmlFile);
                XmlWriter xmlWriter = GetXmlWriter(TargetXmlFile);
                xslTransform.Transform(xmlReader, xmlWriter);
            }
            catch (Exception e)
            {
                Log.LogErrorFromException(e);
                result = false;
            }
 
            return result;
        }
 
        XslCompiledTransform GetXslTransform(String file)
        {
            XslCompiledTransform xslTransform = new XslCompiledTransform();
            xslTransform.Load(GetXmlReader(file));
            return xslTransform;
        }
 
        XmlReader GetXmlReader(String file)
        {
            return new XmlTextReader(GetTextReader(file));
        }
 
        XmlWriter GetXmlWriter(String file)
        {
            TextWriter textWriter = new StreamWriter(file);
            return new XmlTextWriter(textWriter);
        }
 
        TextReader GetTextReader(String file)
        {
            return new StreamReader(file);
        }
    }
}

And here comes the task definition embedded in a MSBuild project file:

1
2
3
4
5
6
7
8
9
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
  DefaultTargets="Default">
  <UsingTask AssemblyFile="XSLTTask.dll" TaskName="XSLT" />
  <Target Name="Default">
    <XSLT SourceXmlFile="input.xml"
          TargetXmlFile="output.xml"
          XsltlFile="transform.xslt"  />
  </Target>
</Project>