msgbartop
A cronological documentation test project, nothing serious, really!
msgbarbottom

17 Nov 2009 Zimbra distribution list commands

This is just a short post describing Zimbra distribution list (mailinglist) commands.

These commands should be run as the zimbra user

# su - zimbra

List all distribution lists

# zmprov gadl

Print only members addresses of a distribution list

# zmprov gdl mailinglist@example.com | grep zimbraMailForwardingAddress: | awk {'print $2'}

Show if a list is member of another distribution list(s)

# zmprov gdlm mailinglist@example.com

Tags: ,

Posted by Hans-Henry Jakobsen

02 Nov 2009 Howto backup mysql stored functions and stored procedures

This is how you can backup you MySQL database(s) and stored procedures

# mysqldump --routines <dbname>

Or you can backup only the stored procedures

# mysqldump --no-create-db --no-create-info --no-data --routines <dbname>

Tags: , , ,

Posted by Hans-Henry Jakobsen

23 Oct 2009 mysql alternative to PHP substr_count function

The substr_count function in PHP counts the number of substring occurrences. This post describes how to create a mysql stored function to behave just like PHP’s substr_count function.

This function can be created from your mysql console

delimiter ||
DROP FUNCTION IF EXISTS substrCount||
CREATE FUNCTION substrCount(s VARCHAR(255), ss VARCHAR(255)) RETURNS TINYINT(3) UNSIGNED LANGUAGE SQL NOT DETERMINISTIC READS SQL DATA
BEGIN
DECLARE count TINYINT(3) UNSIGNED;
DECLARE offset TINYINT(3) UNSIGNED;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET s = NULL;

SET count = 0;
SET offset = 1;

REPEAT
IF NOT ISNULL(s) AND offset > 0 THEN
SET offset = LOCATE(ss, s, offset);
IF offset > 0 THEN
SET count = count + 1;
SET offset = offset + 1;
END IF;
END IF;
UNTIL ISNULL(s) OR offset = 0 END REPEAT;

RETURN count;
END;

||

delimiter ;

Usage

Example 1

SELECT substrCount('/this/is/a/path', '/') `count`;

`count` would return 4 in this case. Can be used in such cases where you might want to find the “depth” of a path, or for many other uses.
This function is great to count the content of mysql ENUM and SET field data types.

Example 2

SELECT substrcount(
                `tablename` , ','
        ) as tablename
        FROM `tablename`
        where substrcount(
                `tablename` , ','
        ); 

The content of table named tablename is a comma separated list generated from mysql ENUM datatype

2000/2001,2001/2002,2002/2003,2003/2004,2004/2005,2005/2006,2006/2007,2007/2008,2008/2009,2009/2010

In Example 2 the result from this query would be 9, telling us that there are 9 commas in this tablerow.

Source: Posted by Andrew Hanna on August 24 2006 8:04pm

Tags: , , ,

Posted by Hans-Henry Jakobsen

15 Sep 2009 chmod only files or folders

This post is just a personal note on how to chmod files or directories recursively

Recursive chmod only files within this folder

find . -type f -exec chmod 0600 {} ;

Recursive chmod only folders within this folder

find . -type d -exec chmod 0755 {} ;

Tags: ,

Posted by Hans-Henry Jakobsen

24 Jun 2009 Howto decompose a SWF Adobe Flash file

This post describes howto decompose a SWF Flash-file using linux and a program named swfextract. The post came to life because I had to do some changes to one of my flash presentations but I had deleted all the source files. After searching the Internet i doscovered swfextract.

SWF Tools is a collection of SWF (Flash) manipulation and creation utilities like pdf2swf, jpeg2swf, png2swf, gif2swf, font2swf, wav2swf, swfcombine, swfdump, swfstrings, swfbbox and swfc. But I’m only going to use swfextract in this post.

If you don’t have it installed on your system, download it and install the deb-package

# wget http://http.us.debian.org/debian/pool/main/s/swftools/swftools_0.8.1-2.1_i386.deb
# dpkg -i swftools_0.8.1-2.1_i386.deb

The swftools package depends on several packages like libgif4 libt1-5 and they should be installed before swftools

# aptitude install libgif4 libt1-5

I was interested in extracting the image files in my Flash presentation and did the following to determine what was in the presentation file

# swfextract flashfile.swf
Objects in file flashfile.swf:
 [-i] 5 Shapes: ID(s) 1, 3, 5, 7, 9
 [-j] 4 JPEGs: ID(s) 2, 6, 8, 10
 [-f] 1 Frame: ID(s) 0

As we see above there are 4 JPEG-files I'm interested in extracting and their IDs.

I did the following to extract the image files

# swfextract -i 2 -j 2,6,8,10 flashfile.swf

Result files

output.swf
pic10.jpg
pic2.jpg
pic6.jpg
pic8.jpg

If you don't use the -i switch you will end up with only one output.jpg file.

You are now ready to recreate the Flash presentation using the extracted image files.

Source
http://www.swftools.org
SWF Tools

Tags: , , , , , ,

Posted by Hans-Henry Jakobsen