Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

hostmaster

« Newer Snippets
Older Snippets »
7 total  XML / RSS feed 

sort installed packages by size

// sort installed packages by size

rpm -qa --queryformat="%{size} %{name}-%{version}-%{release}\n" | sort -rn | less

script for migrating from UW-IMAP to Dovecot [PATCHED]

#!/bin/bash

# A script for migrating from UW-IMAP to Dovecot
#
# By Andrew Ziem
# Copyright (c) 2007 Springs Rescue Mission.  All rights reserved.
#
#
# Moves UW-IMAP mboxes from two locations to ~/mail so that Dovecot
# can easily convert mboxes to Maildirs.  Mailboxes with whitespace
# should be handled properly, and IMAP subscriptions should be preserved.
#
#


# Edit the below variables

#HOME_USERS=/home
HOME_USERS=/home/users

#MAIL_SPOOL=/var/mail
MAIL_SPOOL=/var/spool/mail



# to this function pass the user name
function move_mailboxlist
{
        if [ ! -d "$HOME_USERS/$1" ];
        then
                echo "Error: $HOME_USERS/$1 does not exist"
                return 0
        fi

        # make ~/mail
        cd "$HOME_USERS/$1"
        mkdir mail
        chown "$1" mail

        # find each mbox and move it to ~/mail
        if [ ! -f ".mailboxlist" ];
        then
                echo "Warning: .mailboxlist does not exist for $1"
                return 0
        fi
        
        # cat .mailboxlist | while read line; do mv "${line}" ./mail/; done
        cat .mailboxlist | tr '\n' '\0' | xargs -0 mv -t ./mail/

        # preserve subscriptions (to prevent manual resubscriptions)
        mkdir Maildir
        chown "$1" Maildir
        cp -a .mailboxlist Maildir/subscriptions
}

# move inbox from $MAIL_SPOOL to ~/mail/inbox
function move_inbox
{
        if [ ! -f "${MAIL_SPOOL}/$1" ];
        then
                echo "Error: ${MAIL_SPOOL}/$1 does not exist"
                return 0
        fi
        cp "${MAIL_SPOOL}/$1" "${HOME_USERS}/$1/mail/inbox"
        chown "$1" "${HOME_USERS}/$1/mail/inbox"
}

if [ $# -eq 0 ];
then
        echo "First, did you edit the directory names in the script?"
        echo "Then, if you want to do a dry run, prefix mv and cp with echo."
        echo "Then, invoke $0 by passing one or more user names."
        exit
fi

for user in $@
do
        echo "*** Processing user $user"
        move_mailboxlist $user
        move_inbox $user
done

V4L2 Webcam Software

Re: V4L2 Webcam Software?

luvcview — by Martin Rubli — last modified 2007-07-06 14:48
Small video capture program ideal for webcam testing and problem debugging.
Ekiga — by Martin Rubli — last modified 2007-07-06 14:48
Audio and video conferencing software supporting H.232 and SIP.
FFmpeg — by Martin Rubli — last modified 2007-07-06 14:48
Program suite to record and convert audio and video streams.
fswebcam — by Martin Rubli — last modified 2007-07-06 14:48
Command-line tool to capture webcam images.
GStreamer — by Martin Rubli — last modified 2007-07-06 14:48
V4L2 plugin for the GStreamer multimedia framework.
MJPG-streamer and UVC-streamer — by Martin Rubli — last modified 2007-11-19 00:26
Resource-friendly IP-based webcam streaming server
uvccapture — by Martin Rubli — last modified 2007-07-06 14:48
Command-line tool to capture webcam images.
UVC incompatible software — by Martin Rubli — last modified 2007-07-06 14:48
List of a few programs that have V4L2 support but do not work with the Linux UVC driver because of implementation limitations.
unicap and ucview — by Martin Rubli — last modified 2007-11-19 03:00
Video capture library with supporting GTK widgets

[SAMBA] exclude file/directory from shared folder

// i have shared a directory and in this directory is one
// which i dont want to share! how can i exclude this?

[myshare]
  path = /var/test
  veto files = /var/test/private


// where /var/test/private can be a file or directory.

Path MTU Discovery Black Hole

// Path MTU Discovery Black Hole (PPPoE)

iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN \
        -j TCPMSS --clamp-mss-to-pmtu  

backup files

// create backup copy

#!/bin/bash

filename=$1
date=`date +%Y%m%d`

usage () {
        echo "Usage: `basename $0` filename"
}

if [ -z "$filename" -a ! -f "$filename" ]; then
        usage
        exit 1
fi

rev=0
backup="$filename.$date.$rev"

while [ -f $backup ]; do
        let rev+=1
        backup="$filename.$date.$rev"
done

cp $filename $backup
exit $?

Python - Processing Large Text Files One Line At A Time

// process some very large text files one line at a time

fh = open('foo.txt', 'r')
line = fh.readline()
while line:
    # do something here
    line = fh.readline()


// Update

for line in open('foo.txt', 'r'):
    # do something here
« Newer Snippets
Older Snippets »
7 total  XML / RSS feed