OpenOffice Macros with Basic

Create new Macro
Extras > Makros > Makros verwalten > Makro...
Meine Makros > Standard > Neu
# open a external application (v1)
Sub Main
	item = ThisComponent.getCurrentSelection.String
	If len(item) > 0 then
		rem msgbox "Selection: " & item
		item = UCase(item)
		oService = createUnoService("")
		oService.execute("/media/programme/starter/scripts/", "item_id=" & item, 0)
End Sub
# open a external application (v2)
Sub Main
selectedRow = ThisComponent.CurrentSelection.getRangeAddress.StartRow
itemId = ThisComp

Install Oracle XE

# new version:
# fix
W: GPG error: unstable Release: The following signatures were invalid: KEYEXPIRED 1378511808 KEYEXPIRED 1378511808 KEYEXPIRED 1378511808
# add oracle repository
wget -O- | apt-key add -
cat <<EOF> /etc/apt/sources.list.d/oracle.list
deb unstable main non-free
# update repository
apt-get update
# install oracle
apt-get install -y oracle-xe
# configure

TARGET=/tmp/nl_$(date -I)
# create target directory
[ -d ${TARGET} ] || mkdir ${TARGET}
# convert images
for i in $@; do
        convert "${SOURCE}/${IMG}" -resize "x${MAX_HEIGHT}" -density "${DENSITY}x${DENSITY}" -sharpen "0x1" "${TARGET}/${IMG}"
        echo "${IMG}: $?"

Backup and block data copy with dump device (dd)

# save partition / disk to image
dd if=/dev/hda bs=16065b | gzip -9 > hda_backup.dd.gz
# restore partition / disk from image
gunzip -dc hda_backup.dd.gz | dd of=/dev/hda bs=16065b
# copy over network
netcat -l -p 1234 | dd of=/dev/hdc bs=16065b
dd if=/dev/hda bs=16065b | netcat TARGET_IP 1234
# backup mbr
dd if=/dev/hda of=mbr.img bs=512 count=1 
# restore mbr (better will by bs=446)
dd if=bs.img of=/dev/hda bs=512 count=1 

Get selected debconf answers

# view all manual selections
for PACKAGE in $(debconf-show --listowners); do
   echo ${PACKAGE}
   debconf-show ${PACKAGE} | grep "*"
apt-get install debconf-utils
# replace <TAB> with tabulator key
for i in $(debconf-show ${PACKAGE} | grep "*" | cut -d" " -f2 | cut -d":" -f1); do 
	debconf-get-selections | egrep "$i<TAB>";
debconf-get-selections  | grep -v "#"
debconf-show ddclient | grep '*'
apt-get install debconf-utils
sudo debconf-set-selections
# show installed packages
debconf-show  --listowners
debconf-show mysql-server-5.0 | grep "*" | cut -

Install stress test

# install
sudo apt-get install -y stress
stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 600s


# rsync only files matching pattern
rsync -avz --include "*_small.jpg" --exclude "*.jpg" dir1/ dir2/
rsync -avz --include "*/" --include "*.jpg" --exclude "*" dir1/ dir2/
rsync -avz --include "*/" --include "**.svn**" --exclude "*" just-checked-out/ old-and-modified/
# rsync over ssh
rsync -are ssh root@ /mnt/

Create LiveCD with Debian live-helper

# test
apt-get install live-helper cdebootstrap
cat <<EOF>> /usr/share/cdebootstrap/suites
Suite: hardy
Config: generic-ubuntu
Keyring: ubuntu-archive-keyring.gpg
# sed
mkdir ~/live && cd ~/live

Compile CTCS

sudo su
cd /usr/src/
apt-get install dpkg-dev lm-sensors dialog build-essential
echo "deb-src hardy main universe multiverse restricted" >> /etc/apt/sources.list
apt-get update
apt-get source linux-image-$(uname -r)
ln -sf /usr/src/linux-2.6.24/ /usr/src/linux
# 1.3.0
wget -P /tmp
tar xzf /tmp/ctcs-*.tgz -C /tmp
cd /tmp/ctcs-*/
make all
# 1.3.1
wget -P /tmp
tar xzf /tmp/ctcs-*.tgz -C /tmp
cd /tmp/ctcs-


DBMS_SCHEDULER.create_job (
    job_name        => 'update_snapshots',
    job_type        => 'STORED_PROCEDURE',
    job_action      => 'UPDATE_SNAPSHOT',
    start_date      => SYSTIMESTAMP,
    repeat_interval => 'freq=hourly; byminute=5',
    end_date        => NULL,
    enabled         => TRUE
-- 10xe
DBMS_SCHEDULER.create_job (
    job_name        => 'update_invoice_positions',
    job_type        => 'PLSQL_BLOCK',
    job_action      => 'K.INVOICE;',
    start_date      => SYSTIMESTAMP,
    repeat_interval => 'freq=hourly; byminute=0',
Syndicate content