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

12 Feb 2010 Logon to Norsk Tipping using Ubuntu 9.10

This post is a short howto how I managed to use my Ubuntu 9.10 (Karmic Koala) to log on to the web pages of Norsk Tipping using a USB CardMan 3121 buypass card reader and Firefox web browser.

First of all you need to install Java to login to Norsk Tipping webpages.

# aptitude install sun-java6-jre sun-java6-plugin

I got the following error message while trying to login “Feilreferanse 31503”.
Installing the following packages solved the problem and I am now able to use the webpages to Norsk Tipping just like I do in Windows.

# aptitude install libccid libpcsclite-dev pcscd libpcsclite-dev

Tags: , , , ,

Posted by

17 Nov 2009 Create a temporary “Site Down” notice in Apache

This post describes how to make a “Site down for maintenance” notice using Apache .htaccess and the mod_rewrite module.
I assume you know how to enable the Apache htaccess directive and the mod_rewrite module.

First you need to create a .htaccess file in your root level of your website.
Next you add the following lines to it

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/sitedown.html$
RewriteRule $ /sitedown.html [R=302,L] 

The .htaccess file should be “active” immediately and you should see the content of your sitedown.html file. If not, try clearing your browsers cache.

If you as a maintenance user would like to access the site without seeing the sitedown.html file, add the following line to enable IP address exception

RewriteCond %{REMOTE_HOST} !^192\.168\.0\.12
 

Remember to replace the IP address with your address.

The .htaccess file should now look something like this.

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/sitedown.html$
RewriteCond %{REMOTE_HOST} !^192\.168\.0\.12
RewriteRule $ /sitedown.html [R=302,L] 

Just delete the .htaccess file when you are done with your maintenance and your site will be available again.

Tags: ,

Posted by

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

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

12 Jun 2009 Replace specific HTML tags using sed and regular expression

In this post I would like to replace all <embed> HTML tags in a HTML file with a <strong> tag.

# sed -e 's/<embed[^>]*>/<strong>/g' filename.html > newfile.html

And if you would like to remove the <embed> tag altogether

# sed -e 's/<embed[^>]*>//g' filename.html > newfile.html

To remove all HTML tags in a file

# sed -e 's/<[^>]*>//g' filename.html > newfile.html

The result file newfile.html is now without any < HTML tags >.

Tags: , , ,

Posted by