Big Qmail Clusters

http://sourceforge.net/docman/display_doc.php?docid=18802&group_id=85937

Udgivet i Knowledge Base, Old Base | Skriv en kommentar

Linux Autodetect Software Raid

gamle howto deprecated, min nye forklarer meget mere:
http://wiki.kaspersandberg.com/doku.php?id=howtos:softwareraid
Udgivet i Knowledge Base | Skriv en kommentar

mod_proxy config

<VirtualHost thor.btworld.dk>
ServerName thor.btworld.dk
DocumentRoot /var/www/thor_redirect/htdocs
ProxyPass /samurize/ http://thor.btworld.dk/samurize/
ProxyRequests Off
</VirtualHost>

Udgivet i Apache, Knowledge Base, Linux, Old Base | Skriv en kommentar

Billedredigering med imagemagick

Rotate pictures?

mogrify -rotate 90/180 */001.jpg

Resizing picture
mogrify -size 120×120 -resize 120×120 +profile “*” *.jpg

Udgivet i Knowledge Base, Linux, Old Base | Skriv en kommentar

putty tunnels from system tray

This is how to connect some ssh forwarded ports without having any unused putty windows in the taskbar.

First download and install putty and configure pageant to start with windows.
(use the installer package, not the standalone putty.exe)
Make som keyfiles for authentication.

Now, the tunnel can be established by using plink, that comes with putty.
plink.exe -ssh -batch -l black -L 2401:10.0.3.129:2401 -L 25:10.0.3.129:25 -L 143:10.0.3.129:143 -N munin.btworld.dk

Now this nice little program, will send all output from the ssh session to stdout, which we can catch with our own little C# program, that minimizes to tray.

(code for C# program will be uploaded when I’m done)

Udgivet i Knowledge Base, Old Base, Programmering | Skriv en kommentar

C# write XML to stream with XmlDocument

Stream outputStream = new MemoryStream();
XmlDocument doc = new XmlDocument();

XmlElement root = doc.CreateElement("packet");
XmlElement type = doc.CreateAttribute("type");
if (this.request)
  type.Value = "request";
else
  type.Value = "response";

root.AppendChild(type);

XmlElement callElement = doc.CreateElement("call");
XmlAttribute funcAttr = doc.CreateAttribute("func");
funcAttr.Value = this.func;
callElement.AppendChild(funcAttr);
root.AppendChild(call);

XmlElement errElement = doc.CreateElement("error");
XmlAttribute noAttr = doc.CreateAttribute("no");
noAttr.Value = this.errorNumber;
XmlAttribute msgAttr = doc.CreateAttribute("msg");
msgAttr.Value = this.errorMessage;
errElement.AppendChild(noAttr);
errElement.AppendChild(msgAttr);
root.AppendChild(errElement);

XmlElement[] parameterList = new XmlElement[parameterNames.Count];
for (int i = 0; i < this.parameterNames.Count; i++)
{
  parameterList[i] = doc.CreateElement("parameter");
  XmlAttribute nameAttr = doc.CreateAttribute("name");
  nameAttr.Value = parameterNames[i];
  XmlAttribute valueAttr = doc.CreateAttribute("value");
  valueAttr.Value = parameterValues[i];
  parameterList[i].AppendChild(nameAttr);
  parameterList[i].AppendChild(valueAttr);
  root.AppendChild(parameterList[i]);
}

doc.AppendChild(root);
XmlWriter writer = new System.Xml.XmlTextWriter(outputStream, System.Text.Encoding.UTF8);
doc.WriteTo(writer);

 

Udgivet i Knowledge Base, Old Base, Programmering | Skriv en kommentar

how to edit strings with mysql

Mysql replace is nice

UPDATE `users` SET homedir = REPLACE(homedir, ‘/home/daemons’, ‘/home/vmail/’), maildir = REPLACE(maildir, ‘/home/daemons’, ‘/home/vmail/’);

Udgivet i Knowledge Base, Old Base | Skriv en kommentar

how to add a user to a group

This is a nice way to add a user to a new group,
from any script or other non-interactive metod:

usermod -G $(id -nG root | sed -e “s/ /,/g”),vmail root

Udgivet i Knowledge Base, Linux, Old Base | Skriv en kommentar

proftpd bandwith limit

<Directory />
  AllowOverwrite                on
  TransferRate                  APPE,RETR,STOR,STOU 25:1024 user !black
</Directory>

limits to 25KB/s with a 1024KB fullspeed limit, excludes the user black

 

Udgivet i Apache, Knowledge Base, Old Base | Skriv en kommentar

PHP XML Parsing

<pre>

<?php
$file = "artikel.xml";
$depth = array();

function startElement($parser, $name, $attrs)
{
   global $depth;
   for ($i = 0; $i < $depth[$parser]; $i++) {
       echo "  ";
   }
   echo "$name ";

        if (sizeof($attrs))
        {
                while (list($k,$v) = each($attrs))
                {
//                      print "$k -> $v  --";
                }
                print $attrs['AUTHOR'];
        }

   echo "\n";
   $depth[$parser]++;
}

function endElement($parser, $name)
{
   global $depth;
   $depth[$parser]--;
}

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
if (!($fp = fopen($file, "r"))) {
   die("could not open XML input");
}

while ($data = fread($fp, 4096)) {
   if (!xml_parse($xml_parser, $data, feof($fp))) {
       die(sprintf("XML error: %s at line %d",
                   xml_error_string(xml_get_error_code($xml_parser)),
                   xml_get_current_line_number($xml_parser)));
   }
}
xml_parser_free($xml_parser);
?>

</pre>
Copyright(c) Unifix.org 2002-2011

 

Udgivet i Knowledge Base, Old Base, Programmering | Skriv en kommentar