Perl: SOAP problem with dateTime

The following error message was received by Perl application:
Unrecognized type ‘{http://www.w3.org/1999/XMLSchema}dateTime

The problem is caused by “dateTime” type: it was not supported in the 1999 XML Specification.
The solution is to switch to 2001 schema:

[cc lang=”Perl”]
my $soap = SOAP::Lite->uri( $NAMESPACE )->proxy( $PROXY_URL )->xmlschema (‘2001’);
[/cc]

Perl: Soap deserialization error

Sometimes the following error is displayed, if application uses the old version of CPAN SOAP module:
“Client Application failed during request deserialization: no element found at line 1, column 0, byte -1 at XML/Parser.pm”

The possilbe solution is to change SOAP::Transport::HTTP module (SOAP/Transport/HTTP.pm), function “handle”:

[cc lang=”perl”]
sysread( STDIN, $buffer, $length )
[/cc]

should be replaced by

[cc lang=”perl”]
read( STDIN, $buffer, $length )
[/cc]

AutoIt: script for hotkeys usage

This script allows You to define the global Windows hotkeys via the configuration file.

The syntax of the config file is simple:

Hotkey,Program,Parameters

Here “Hotkey” is the combination of the keyboard key with one of the identifiers:

^ Ctrl
! Alt
+ Shift
# Windows-Key

Example:

;Win+C – start calculator
#{c},calc.exe

;Win+Shift+N – start notepad
+#{n},notepad.exe

;Win+N – start notepad++ together with apploc.exe
#{n},%windir%\AppPatch\AppLoc.exe,”%ProgramFiles%\Notepad++\notepad++.exe” -nosession /L0419

Continue reading

Oracle: buffer overflow (ORU-10027)

Sometimes it’s necessary to show the output of the PL/SQL script.
Usually the dbms_output package is used:

[cc lang=”oracle8″]
set serveroutput on
declare
i number ;
begin
i:=0 ;
while i< 100000 loop i:=i+1 ; dbms_output.put_line('This is just test line #' || to_char(i) ) ; end loop ; end; / [/cc] After several thousands lines the following error message is displayed:

ORA-20000: ORU-10027: buffer overflow, limit of 20000 bytes
ORA-06512: at “SYS.DBMS_OUTPUT”, line 32
ORA-06512: at “SYS.DBMS_OUTPUT”, line 97
ORA-06512: at “SYS.DBMS_OUTPUT”, line 112
ORA-06512: at line 8

The error message means, that the internal buffer of dbms_output is full. How to increase it?
The following methods could be used:

[cc lang=”oracle8″]

dbms_package.enable(100000) ;

[/cc]

[cc lang=”oracle8″]

set serveroutput on size 100000

[/cc]

In Oracle 10gR2 the new addition “size unlimited” could be used:
[cc lang=”oracle8″]

set serveroutput on size unlimited

[/cc]

If these methods do not work, the temporary table could be used:
[cc lang=”oracle8″]
create sequence my_output_seq ;
create global temporary table my_output_table( my_row number, my_out varchar2(120) ) ;

insert into my_output_table values ( my_output_seq.nextval, ‘This is some string’ ) ;

select my_out from my_output_table order by my_row ;
drop table my_output_table ;
drop sequence my_output_seq ;
[/cc]

MS Word: put syntax highlighed code into the document

Here is the simple method to put the code with highlighting into the Word document:

    1. Download and install Notepad++. This is easy-to-use and yet very powerful text editor with a lot of features, support of the plugins etc.
    2. Put your code into the Notepad++ edit window
    1. Configure the language, if Notepad++ did not do this automatically:
      Language->your language
      npp language select
      If necessary the additional configuration could be done in the Style Configurator: Settings->Style Configurator…
    1. Export the highlighted text with help of NppExport plugin: Plugins->NppExport
      It has the following options:
      npp export options
    1. Select “Copy RTF to clipboard”
    2. Paste the content of the clipboard into the Word document
    3. Make any changes in the Word document if necessary

Oracle: how to clone profiles

Here is the simple script for cloning the Oracle profiles.
[cc lang=”oracle8″]
set serveroutput on

declare
cursor c_profiles is
select PROFILE, RESOURCE_NAME, LIMIT
from dba_profiles
order by profile, resource_name;

s_PROFILE dba_profiles.PROFILE%type ;
s_prev_PROFILE dba_profiles.PROFILE%type ;
s_RESOURCE_NAME dba_profiles.RESOURCE_NAME%type ;
s_LIMIT dba_profiles.LIMIT%type ;
begin

s_prev_PROFILE := ‘no_such_profile’ ;

dbms_output.enable(1000000);
open c_profiles;
loop
fetch c_profiles into s_PROFILE,s_RESOURCE_NAME,s_LIMIT ;
if ( s_prev_profile <> s_profile ) then
begin
dbms_output.put_line ( ‘–‘);
dbms_output.put_line ( ‘create profile “‘||s_profile||'” limit ‘ ||s_RESOURCE_NAME|| ‘ ‘ || s_LIMIT||’;’ ) ;
s_prev_profile := s_profile ;
end;
else
dbms_output.put_line ( ‘alter profile “‘||s_profile|| ‘” limit ‘ ||s_RESOURCE_NAME|| ‘ ‘ || s_LIMIT || ‘;’ ) ;
end if;
exit when c_profiles%NOTFOUND ;
end loop ;

close c_profiles ;

end;
/
[/cc]

Continue reading

Windows: local printer option is greyed out

Some time ago I need to add the local printer to the system, however, this option was greyed out in the “Add printer” wizard.
The problem was caused by local policy, preventing the adding of the new devices to the system.

The following should be done to enable “Add local printer” option

  1. Start the policy editor (Control Panel -> Administrative tools -> Local security policy)
  2. Select “Local policy” item
  3. Find the item “Devices: Prevent Users from Installing Printer Drivers” in the section Security Settings -> Security Options and change it to Enabled
  4. Go to “Security Settings -> User Rights Assignment” section and check, that “Load & Unalod Drivers” option contains the active user group. It important, that even if it has “All Staff” already, it still could miss “Administrators” group, so it’s necessary to add it manually.

Unix: print in color

This simple procedure takes 3 arguments as the parameters:

  • Text
  • Foreground color
  • Background color

It prints the text to the terminal in selected colors.

[cc lang=”bash”]
function print_color {
local text=$1
local fg=$2
local bg=$3
case “$fg” in
red) fg=”31m” ;;
green) fg=”32m” ;;
yellow) fg=”33m” ;;
blue) fg=”34m” ;;
white) fg=”37m” ;;
black) fg=”30m” ;;
*) fg=”37m” ;;
esac
case “$bg” in
red) bg=”41m” ;;
green) bg=”42m” ;;
yellow) bg=”43m” ;;
blue) bg=”44m” ;;
white) bg=”47m” ;;
black) bg=”40m” ;;
*) bg=”40m” ;;
esac
echo -en “\033[${fg}\033[${bg}${text}\033[0m”
}
[/cc]

Unix: rename files to lowercase

It’s very simple to rename the files to lowercase/uppercase using awk:

Lowercase
[cc lang=”bash”]
ls -1rt | awk ‘{ printf(“mv %s %s\n”, $0, tolower($0)) | “sh” } END { close(“sh”) }’
[/cc]

Uppercase
[cc lang=”bash”]
ls -1rt | awk ‘{ printf(“mv %s %s\n”, $0, toupper($0)) | “sh” } END { close(“sh”) }’
[/cc]