CVS commit steps

CVS Commit steps
—————————————————————————–
zephid@dev# cvs upd
Check for “C” (Conflicts)
if any “C”‘s, poke bt :p
else
zephid@dev# cvs ci -m “What you have done …”

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

Fix html danish characters

grep å * | wc -l
grep æ * | wc -l
grep ø * | wc -l

sed -i -e ‘s/Ã¥/\å/g’ *.html
sed -i -e ‘s/æ/\æ/g’ *.html
sed -i -e ‘s/ø/\ø/g’ *.html

grep å * | wc -l
grep æ * | wc -l
grep ø * | wc -l

(I really hated the graphics guy that day)

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

Postgre quickguide

postgres@dev:~$ psql projektstyring
Welcome to psql 8.1.9, the PostgreSQL interactive terminal.

postgres@dev:~$ createdb projektstyring
CREATE DATABASE

projektstyring=# create user projektstyring with password ‘kode’;
CREATE ROLE

projektstyring=# GRANT ALL ON DATABASE projektstyring TO projektstyring;
GRANT

should be all that you need to continue from phppgadmin..

projektstyring=# create schema authorization projektstyring;
CREATE SCHEMA

projektstyring=# grant all on schema public to projektstyring;
GRANT

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

Xini file parser v1.0

<?
  
  # Xini parser v1.0 by MC Solutions 2007, all righs reserved
  
  /*
    Samlpe file:
    
    menu.xini:
    
    !Structure=Text,Url

    [Menu]
    Item="Om firmaet","about.php"
    Item="Kontakt firmaet","contact.php"

    [Menu2]
    Item="Bestil","order.php"
    Item="Log ind","login.php","nisse","fisk"


    [forside]
    Titel="Bla bla bla"
    BestilLink="Bla bla bla"
    
    
    EOF
    
    !Structure describes the name of the coma separated variables, used for generation an associative array.
    
    Lines starting with ; or # are ignores ie. comments
    
    The result of parsing the file ahead will be:
    
    Array
    (
        [Menu] => Array
    	    (
    	        [0] => Array
                (
                    [Text] => Om firmaet
                    [Url] => about.php
                )

    	        [1] => Array
                (
                    [Text] => Kontakt firmaet
                    [Url] => contact.php
                )

        	)

    		[Menu2] => Array
        	(
            	[0] => Array
                (
                    [Text] => Bestil
                    [Url] => order.php
                )

            	[1] => Array
                (
                    [Text] => Log ind
                    [Url] => login.php
                    [0] => nisse
                    [1] => fisk
                )

        	)

    		[forside] => Array
        	(
        	    [Titel] => Bla bla bla
          	    [BestilLink] => Bla bla bla
        	)

  )

  
  */
  

  
  class XiniParser
  {
    public function parse($file)
    {
      $data=preg_split("/\n/",file_get_contents($file));
      foreach ($data as $number=>$line)
      {
        $tokkens=preg_split("/=|\ /",$line,-1,PREG_SPLIT_NO_EMPTY);	
        if (($tokkens[0]=="") or ($tokkens[0][0]=="#") or ($tokkens[0][0]==";"))
        {
          // Tom Linie eller kommentar
        }
        else if ($tokkens[0]=="!Structure")
        {
          //print "NEW STRUC:$line\n";
          $struct=preg_split('/,/',$tokkens[1],-1,PREG_SPLIT_NO_EMPTY);
      
          
          $keys=$struct;
      
        } else if ($tokkens[0][0]=='[')
        {
          $block=preg_split('/\[|\]/',$line);
          $block=$block[1];		
        } else {
      
          $tokkens=preg_split("/=/",$line);
      
          $values=preg_split('/","/',$tokkens[1]);
      
          if (count($values)==1)
          {
            $value=substr($values[0],1,-1);	// Remove tailing and heading "
          } else {
            $values[0]=substr($values[0],1);
            $values[count($values)-1]=substr($values[count($values)-1],0,-1);
            unset($value);
            foreach ($values as $k=>$v)
            {
              if ($keys[$k]!="")
              {
                $value[$keys[$k]]=$v;
              } else {
                $value[]=$v;
              }
            }
        
          }	
            
          if ($tokkens[0]=="Item")
          {
            $ret[$block][]=$value;					
          } else {
            if (strpos($line,"="))
            {
              $ret[$block][$tokkens[0]]=$value;
            
              // Value Assignments	
            } else 
            {
              print "syntax error at line $number:`<i>$line</i>`<br>";
            }	
          }
        }		
      }
      return $ret;
    }
  }
  
  $xini=new XiniParser();
  
  print_r($xini->parse('menu.xini'));
  
?>

 

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

Installing mailserver on Debian

### Install packages needed:
apt-get install apache2 mysql-server libapache2-mod-php5 php5-mysql postfix postfix-mysql courier-authlib-mysql courier-imap courier-pop

### Answers:
Create Web Based Configuration: NO
General type of configuration: Internet Site
Mail name: mail02.ar.mcn.dk

### Run this to edit /etc/postfix/main.cf:

postconf -e myhostname=mail02.ar.mcn.dk
postconf -e mydomain=mcn.dk
postconf -e mynetworks=127.0.0.0/8
postconf -e alias_maps=mysql:/etc/postfix/mysql-aliases.cf
postconf -e relocated_maps=mysql:/etc/postfix/mysql-relocated.cf
postconf -e local_transport=local
postconf -e ‘local_recipient_maps=$alias_maps $virtual_mailbox_maps unix:passwd.byname’
postconf -e virtual_transport=virtual
postconf -e virtual_mailbox_domains=mysql:/etc/postfix/mysql-transport.cf
postconf -e virtual_minimum_uid=1000
postconf -e virtual_gid_maps=mysql:/etc/postfix/mysql-virtual-gid.cf
postconf -e virtual_mailbox_maps=mysql:/etc/postfix/mysql-virtual-maps.cf
postconf -e virtual_alias_maps=mysql:/etc/postfix/mysql-virtual.cf
postconf -e virtual_uid_maps=mysql:/etc/postfix/mysql-virtual-uid.cf
postconf -e virtual_mailbox_base=/

### file mysql-aliases.cf:
# mysql-aliases.cf

user = mailsql
password = mypassword
dbname = mailsql
table = alias
select_field = destination
where_field = alias
hosts = 127.0.0.1

### file mysql-relocated.cf:
# mysql-relocated.cf

user = mailsql
password = mypassword
dbname = mailsql
table = relocated
select_field = destination
where_field = email
hosts = 127.0.0.1

### file mysql-transport.cf:
# mysql-transport.cf

user = mailsql
password = mypassword
dbname = mailsql
table = transport
select_field = destination
where_field = domain
hosts = 127.0.0.1

### file mysql-virtual-gid.cf:
#myql-virtual-gid.cf

user = mailsql
password = mypassword
dbname = mailsql
table = users
select_field = gid
where_field = email
additional_conditions = and postfix = ‘y’
hosts = 127.0.0.1

### file mysql-virtual-maps.cf:
#myql-virtual-maps.cf

user = mailsql
password = mypassword
dbname = mailsql
table = users
select_field = maildir
where_field = email
additional_conditions = and postfix = ‘y’
hosts = 127.0.0.1

### file mysql-virtual-uid.cf:
# mysql-virtual-uid.cf

user = mailsql
password = mypassword
dbname = mailsql
table = users
select_field = uid
where_field = email
additional_conditions = and postfix = ‘y’
hosts = 127.0.0.1

### file mysql-virtual.cf:
# mysql-virtual.cf

user = mailsql
password = mypassword
dbname = mailsql
table = virtual
select_field = destination
where_field = email
hosts = 127.0.0.1

### file mailsql.sql:
— phpMyAdmin SQL Dump
— version 2.11.1.2
— http://www.phpmyadmin.net

— Vært: localhost
— Genereringstid: 26. 11 2007 kl. 21:44:15
— Serverversion: 5.0.44
— PHP-version: 5.2.4_p20070914-pl2-gentoo

SET SQL_MODE=”NO_AUTO_VALUE_ON_ZERO”;


— Database: `mailsql`

— ——————————————————–


— Struktur-dump for tabellen `alias`

CREATE TABLE IF NOT EXISTS `alias` (
`id` int(11) NOT NULL auto_increment,
`alias` varchar(42) NOT NULL default ”,
`destination` varchar(42) NOT NULL default ”,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;

— ——————————————————–


— Struktur-dump for tabellen `relocated`

CREATE TABLE IF NOT EXISTS `relocated` (
`id` int(11) NOT NULL auto_increment,
`email` varchar(42) NOT NULL default ”,
`destination` varchar(42) NOT NULL default ”,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;

— ——————————————————–


— Struktur-dump for tabellen `transport`

CREATE TABLE IF NOT EXISTS `transport` (
`id` int(11) NOT NULL auto_increment,
`domain` varchar(42) NOT NULL default ”,
`destination` varchar(42) NOT NULL default ”,
PRIMARY KEY (`id`),
UNIQUE KEY `domain` (`domain`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;

— ——————————————————–


— Struktur-dump for tabellen `users`

CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL auto_increment,
`email` varchar(42) NOT NULL default ”,
`clear` varchar(42) NOT NULL default ”,
`name` tinytext NOT NULL,
`uid` int(11) NOT NULL default ‘1101’,
`gid` int(11) NOT NULL default ‘1101’,
`homedir` tinytext NOT NULL,
`maildir` tinytext NOT NULL,
`quota` tinytext NOT NULL,
`postfix` enum(‘n’,’y’) NOT NULL default ‘y’,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;

— ——————————————————–


— Struktur-dump for tabellen `virtual`

CREATE TABLE IF NOT EXISTS `virtual` (
`id` int(11) NOT NULL auto_increment,
`email` varchar(42) NOT NULL default ”,
`destination` varchar(42) NOT NULL default ”,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;

### edit /etc/courier/authdaemonrc:

authmodulelist=”authmysql”

### file /etc/courier/authmysqlrc:
MYSQL_SERVER 127.0.0.1
MYSQL_USERNAME mailsql
MYSQL_PASSWORD mypassword
MYSQL_DATABASE mailsql
#MYSQL_CRYPT_PWFIELD crypt
MYSQL_USER_TABLE users
MYSQL_CLEAR_PWFIELD clear
MYSQL_LOGIN_FIELD email
MYSQL_HOME_FIELD homedir

### After creating the files run:
groupadd -g 1101 vmail
useradd -u 1101 -g 1101 -d /var/vmail -m vmail
mysqladmin create mailsql
mysql mailsql < mailsql.sql
echo “grant all privileges on mailsql.* to mailsql@localhost identified by ‘pass1234’;” | mysql
sed -i -e ‘s/mypassword/pass1234/’ /etc/postfix/mysql-* /etc/courier/authmysqlrc
/etc/init.d/postfix reload
/etc/init.d/courier-authdaemon restart
/etc/init.d/courier-imap restart
/etc/init.d/courier-pop restart

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

Creating PDF Files from PHP on debian

apt-get install php-fpdf

look for tutorials and documentation at: http://www.fpdf.org/

add fpdf to the include path, and save yourself the hazzle to edit it every time:

include_path = “.:/usr/share/php:/usr/share/php/fpdf”

(in php.ini (DUH!))

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

Generating java code from JavaDoc HTML

Cut’n’paste the method summary to the created class.

Use this search and replace in VS.NET:

Search:
^{[^\)]*}\) \n:b*{[^\n]*}$
Replace:
\n/**\n * \2\n */\npublic \1) { }

For interfaces use this replace:
\n/**\n * \2\n */\n\1);

Strip blank comment blocks with:

Search:
^:b*/\*\*:b*\n:b*\*:b*\n:b*\*/:b*\n
Replace:
\n

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

Get enums fra mysql in php

PRIVATE function GetEnums($table,$field)
{
$dat=mysql_fetch_array(mysql_query(“show columns from `$table` like ‘$field’;”,$this->MysqlResource));
return(preg_split(“/’|,|enum|\(|\)/”,$dat[‘Type’],null,PREG_SPLIT_NO_EMPTY));
}

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

SSH Mount in Ubuntu

I did the following, you might not need to do it all:

Create mount dir and chown it to the user who needs to access it.

Add the following line to fstab:
sshfs#USERNAME@SERVER:/PATH /mnt/MOUNTPOINT fuse defaults,noauto,user,uid=mike,gid=mike,allow_other,reconnect,transform_symlinks 0 0

For automated mounts add ssh keys.

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

Installing webserver on Debian

apt-get install apache2 mysql-server php5-mysql

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