Wednesday, October 29, 2008

noSPAM hits SPAM counter

more evidence on financial problems in spam market.


Friday, October 17, 2008

noSPAM hits SPAM counter

Im really happy to announce, that today for the first time in three years my spam counter reversed upside down, its possibly related to "World’s largest spammer nabbed". Of course the dynamic firewall filter i added a few months ago began to give results too. Anyways, server has nothin to do anymore ;)

Tuesday, October 14, 2008

Lithuania votes 2008


To vote or not to vote?
Voting sucks, the whole political circus sucks. Im myself absolutely politically apathetic and happily introduce you to "Lithuania votes parliament 2008".

Wednesday, October 8, 2008

spamchk

The original spamchk filter used by postfix is described on http://www.akadia.com/services/postfix_spamassassin.html. Remebered to post some advanced settings i made, you find it usefull if you want to split email to spam, nospam and inbetween (lightspam).

#!/bin/sh
# -----------------------------------------------------------------
# File:        spamchk
# Purpose:     SPAMASSASIN shell-based filter
# Location:    /usr/local/bin
# Usage:       Call this script from master.cf (Postfix)
# Certified:   GENTOO Linux, Spamassassin 3.0, Postfix
# -----------------------------------------------------------------

# Variables
#SENDMAIL="/usr/local/postfix/sendmail/sendmail -i"
SENDMAIL="/usr/sbin/sendmail -i"
EGREP=/bin/egrep

# Exit codes from
EX_UNAVAILABLE=69

# Number of *'s in X-Spam-level header needed to sideline message:
# (Eg. Score of 5.5 = "*****" )
SPAMLIMIT=4.5
SPAMLIMITKILL=6.1

# Clean up when done or when aborting.
trap "rm -f /var/tempfs/out.$$" 0 1 2 3 15

# Pipe message to spamc
cat | /usr/bin/spamc -s 1024000 -u filter > /var/tempfs/out.$$

#----- advanced AWK filter by simakas --------------------------------
# 050915 AWK part and splitting method to light_spam & spam

STATUS=`more /var/tempfs/out.$$ | grep -m 1 X-Spam-Status | awk '{print $3}' | awk -F= '{print $2}'`
warn=$(LC_ALL=C  awk 'BEGIN{if('$STATUS'>='$SPAMLIMIT')print "SPAM";else print "NOSPAM"}')
kill=$(LC_ALL=C  awk 'BEGIN{if('$STATUS'>='$SPAMLIMITKILL')print "SPAM";else print "NOSPAM"}')

# Are there more than $SPAMLIMIT stars in X-Spam-Level header? :
#if $EGREP -q "^X-Spam-Level: \*{$SPAMLIMIT,}" < /var/tempfs/out.$$
if [ "$warn" = "SPAM" ]
then
  # Option 1: Move high scoring messages to sideline dir so
  # a human can look at them later:
  # mv out.$$ $SIDELINE_DIR/`date +%Y-%m-%d_%R`-$$
  # Option 2: Divert to an alternate e-mail address:
  # 050915 Drop mail if SPAMLIMITKILL is reached or deliver it to human recheck
  #  if $EGREP -q "^X-Spam-Level: \*{$SPAMLIMITKILL,}" < /var/tempfs/out.$$
     if [ "$kill" = "SPAM" ]
     then
       #Drop it like its hot
       #cp /var/tempfs/out.$$ /tmp/`date +%Y-%m-%d_%R`-$$
       rm -f /var/tempfs/out.$$
     else
       #Or deliver to trashbox for human action
       $SENDMAIL trash@svelita.lt  < /var/tempfs/out.$$
     fi
  # Option 3: Delete the message
  #rm -f /var/tempfs/out.$$
else
  $SENDMAIL "$@" < /var/tempfs/out.$$
fi
# Postfix returns the exit status of the Postfix sendmail command.
exit $?

Wednesday, September 10, 2008

PL/SQL digits to words in Lithuanian

A PL/SQL function to convert numbers to words in Lithuanian, may be adjusted to your language rules. Maximum number 999999,99; decimal sign is ",". Execution example:

select EBA_OLS_DIG_TO_WORD('Lt 999999,99') from dual;

Result:

devyni šimtai devyniasdešimt devyni tūkstančiai devyni šimtai devyniasdešimt devyni Lt. 99 ct.

Code:

create or replace function "EBA_OLS_DIG_TO_WORD"
(num in VARCHAR2)
return VARCHAR2
is
word VARCHAR2(1022); -- result variable
work VARCHAR2(20); -- given number converted to char
k NUMBER := 0; -- length
n1 VARCHAR2(20) := 'vienas'; -- digits
n2 VARCHAR2(20) := 'du';
n3 VARCHAR2(20) := 'trys';
n4 VARCHAR2(20) := 'keturi';
n5 VARCHAR2(20) := 'penki';
n6 VARCHAR2(20) := 'šeši';
n7 VARCHAR2(20) := 'septyni';
n8 VARCHAR2(20) := 'aštuoni';
n9 VARCHAR2(20) := 'devyni';
n0 VARCHAR2(20) := 'dešimt'; -- tens and thousands
nh VARCHAR2(20) := 'šimtas';
nhd VARCHAR2(20) := 'šimtai';
nt VARCHAR2(20) := 'tūkstantis';
ntd VARCHAR2(20) := 'tūkstančiai';
ntu VARCHAR2(20) := 'tūkstančių';
ty VARCHAR2(20) := 'asdešimt'; -- endings
c VARCHAR2(1); -- loop digit value
d VARCHAR2(1); -- 4th digit in 5 digit number (for ...teen numbers)
n NUMBER := 0; -- number variable, for other use cases
suf VARCHAR2(6) := ''; -- suffix value for cents (hundreds of money)
skip4 BOOLEAN := false; -- flag for skipping 4th digit in 5 digit number
BEGIN
work := substr(num,4); -- prefix "LT_" (3 digits, adjust if needed)
k := length(work); -- length
n := instr(work,','); -- looking for decimal
if (n > 0) then
suf := substr(work, n+1, k-n+1); -- reading cents
if (length(suf)=1) then -- ,8 to ,80 correction
suf:=suf'0';
end if;
work := substr(work, 1, n-1); -- number corection, skipping cents
k := length(work); -- length adjustment
end if;
FOR i IN 1..k -- loop
LOOP
c:=substr(work,i,1); -- next digit
if (skip4 = false) then -- skip this part for 4th digit in 5 digit number
case c
when '1' then if ((k-i+1 != 2)and(k-i+1 != 5)and(skip4 = false)) then word:=wordn1; end if;
when '2' then if ((k-i+1 != 2)and(k-i+1 != 5)) then word:=wordn2; else word:=word'dvi'; end if;
when '3' then if ((k-i+1 != 2)and(k-i+1 != 5)) then word:=wordn3; end if;
when '4' then word:=wordn4; -- gramma mess with 1,2 and 3 digits
when '5' then word:=wordn5;
when '6' then word:=wordn6;
when '7' then word:=wordn7;
when '8' then word:=wordn8;
when '9' then word:=wordn9;
--when '0' then word:=wordn0;
else null;
end case;
end if;
word:=word' '; -- space btw words

case (k-i+1) -- lets take a digits position
when 6 then begin -- X*****
if (c = 1) then -- singular
word:=wordnh' ';
elsif (c = 0) then -- nothing
null;
else
word:=wordnhd' '; -- plural
end if;
end;
when 5 then begin -- *X**** (difficult digit, may have teen numbers)
if (c = 1) then -- if its teen number (1*)
d := substr(work,i+1,1); -- next digit in teen numbers
case d
when '0' then word:=wordn0;
when '1' then word:=word'vienuolika';
when '2' then word:=word'dvylika';
when '3' then word:=word'trylika';
when '4' then word:=word'keturiolika';
when '5' then word:=word'penkiolika';
when '6' then word:=word'šešiolika';
when '7' then word:=word'septyniolika';
when '8' then word:=word'aštuoniolika';
when '9' then word:=word'devyniolika';
else null;
end case;
skip4:=true; -- skip 4th digit on the next loop
--exit; -- dont exit the loop
elsif (c = 0) then -- if its zero, do nothing
null;
elsif (c = 2) then -- gramma for "2*"
word:=trim(word);
word:=wordn0' ';
elsif (c = 3) then -- gramma for "3*"
word:=word'tris'n0' ';
else -- default thounsands
word:=trim(word);
word:=wordty' ';
end if;
end;
when 4 then begin -- **X***
if (skip4=true) then -- plural on teen numbers in 5th & 4th place
word:=wordntu' ';
elsif (c = 1) then -- singular
word:=wordnt' ';
elsif (c = 0) then -- plural
word:=wordntu' ';
else -- plural
word:=wordntd' ';
end if;
skip4:=false; -- stop skipping 4th digit
end;
when 3 then begin -- ***X**
if (c = 1) then -- singular
word:=wordnh' ';
elsif (c = 0) then -- nothing
null;
else -- plural
word:=wordnhd' ';
end if;
end;
when 2 then begin -- ****X* (same problem as with 5th digit)
if (c = 1) then -- if its teen number (1*)
d := substr(work,i+1,1); -- next digit in teen numbers
case d
when '0' then word:=wordn0;
when '1' then word:=word'vienuolika';
when '2' then word:=word'dvylika';
when '3' then word:=word'trylika';
when '4' then word:=word'keturiolika';
when '5' then word:=word'penkiolika';
when '6' then word:=word'šešiolika';
when '7' then word:=word'septyniolika';
when '8' then word:=word'aštuoniolika';
when '9' then word:=word'devyniolika';
else null;
end case;
exit; -- no more digits left, exit loop
elsif (c = 0) then -- nothing
null;
elsif (c = 2) then -- gramma with "2*"
word:=trim(word);
word:=wordn0' ';
elsif (c = 3) then -- gramma with "3*"
word:=word'tris'n0' ';
else
word:=trim(word); -- others
word:=wordty' ';
end if;
end;
else null;
end case;
END LOOP;
word:=word' Lt.'; -- add currency if needed
if (n > 0) then -- condition for suffix numbers
--word:=word' 'EBA_OLS_DIG_TO_WORD('ct 'suf)' ct.'; -- convert cents to words if preffered
word:=word' 'suf' ct.'; -- dont convert cents
end if;
return word; -- return
END;

Wednesday, September 3, 2008

Chrome vs Apex: old issues

When first popular Oracle ApEx versions (like 1.6, 2.0) came out, they had problems with displaying SQL Workshop Object Browser windows on some FF versions, just dont remember which exactly (imho 2.2). Here we are again having the same problem: red screen. This time its new Google browser Chrome. The same problem can be found on ApEx versions 3.0, 3.1 and 3.1.2, havent tested this on others. The common solution back then was to add a few directives to Oracle HTTP_Server's configuration file httpd.conf:
AddType text/xml xbl
AddType text/x-component htc
No luck this time. Anyway, Chrome is just beta, hoping to have a better functionality soon.

Chrome myth

Just downloaded new fancy G browser Chrome. It actualy uses more memory than FF does. Chrome just divides it between processess. My FF has 48 tabs opened, it uses 148M RAM, get your calculator and calc this image below, only 24 tabs...