tag:blogger.com,1999:blog-50157676475621851802024-02-19T16:32:26.950+01:00The Giampo Blogthis blog is intended to be a place to store code snippets, examples, notes...
in order to have them handy and to quickly find during the everyday workGiampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.comBlogger45125tag:blogger.com,1999:blog-5015767647562185180.post-1923807730526739422016-02-05T14:21:00.001+01:002016-02-05T14:21:45.553+01:00git commands<div dir="ltr" style="text-align: left;" trbidi="on">
<pre>
git remote rm origin
git remote add origin <url>
git pull
git checkout <checkout>
git diff
git stash save
git diff
git stash pop
git diff
git stash save
git checkout <branch>
git stash pop
git diff
git pull origin <local destination branch>
gir reset HEAD~2
</pre>
<br /></div>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-38534947731091464512012-06-04T17:54:00.001+02:002012-12-13T17:17:04.959+01:00print java stack tracethis is a Java static method that prints on the System.out the stack trace of a Throwable object. It goes recursively through the chain of Throwable objects, printing also the causing objects.
<pre class="prettyprint">
public static void printStackTrace(Throwable th) {
for (StackTraceElement ste : th.getStackTrace()) {
System.out.println("file " + ste.getFileName() + ", method " + ste.getMethodName() + ", line "
+ ste.getLineNumber() + ", " + th.getMessage());
}
if (th.getCause() != null) {
System.out.println("... cause ...");
printStackTrace(th.getCause());
}
}
</pre>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-54143857567846058522012-04-04T18:30:00.001+02:002012-06-04T17:55:09.160+02:00free space in tablespace<pre class="prettyprint">
SELECT /* + RULE */ df.tablespace_name "Tablespace",
df.bytes / (1024 * 1024) "Size (MB)",
SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
FROM dba_free_space fs,
(SELECT tablespace_name,SUM(bytes) bytes
FROM dba_data_files
GROUP BY tablespace_name) df
WHERE fs.tablespace_name (+) = df.tablespace_name
--AND df.tablespace_name LIKE 'UNDO%'
GROUP BY df.tablespace_name,df.bytes
UNION ALL
SELECT /* + RULE */ df.tablespace_name tspace,
fs.bytes / (1024 * 1024),
SUM(df.bytes_free) / (1024 * 1024),
Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 / fs.bytes), 1),
Round((SUM(fs.bytes) - df.bytes_free) * 100 / fs.bytes)
FROM dba_temp_files fs,
(SELECT tablespace_name,bytes_free,bytes_used
FROM v$temp_space_header
GROUP BY tablespace_name,bytes_free,bytes_used) df
WHERE fs.tablespace_name (+) = df.tablespace_name
--and df.tablespace_name LIKE 'UNDO%'
GROUP BY df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
ORDER BY 4 DESC;
</pre>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-65346940632801903122012-01-31T15:37:00.002+01:002012-04-04T18:30:38.717+02:00Oracle, resource-consuming queries<pre class="prettyprint">
SELECT DISTINCT p.Sql_Id AS Sql_Id,
CASE
WHEN p.Id = 0 THEN
Sq.Module
ELSE
NULL
END AS Module,
p.Id,
Lpad(' ', 4 * Depth) || p.Operation AS Operation,
p.Options AS "Access",
p.Object_Name AS "Object",
p.Cost AS "Cost",
Trunc(p.Cpu_Cost / 1000000, 2) AS "Cpu_Seconds",
p.Cardinality,
p.Io_Cost AS "IO Cost",
p.TIME,
p.Filter_Predicates,
p.Access_Predicates,
CASE
WHEN p.Id = 0 THEN
Sq.Sql_Text
ELSE
NULL
END AS Sql_Text,
CASE
WHEN p.Id = 0 THEN
Sq.Last_Active_Time
ELSE
NULL
END AS Last_Active_Time,
Filtro.Costosum
FROM V$sql_Plan p
INNER JOIN V$sql Sq
ON Sq.Sql_Id = p.Sql_Id
INNER JOIN (SELECT Filtro_Rownum.Sql_Id, Filtro_Rownum.Costosum
FROM (SELECT Tmp.Sql_Id, SUM(Tmp.Cost) AS Costosum
FROM (SELECT s.Sql_Text,
p.Sql_Id,
p.Plan_Hash_Value,
p.Cost
FROM V$sql s
INNER JOIN V$sql_Plan p
ON s.Sql_Id = p.Sql_Id
WHERE 1 = 1
AND Upper(s.Sql_Text) NOT LIKE
'%EXPLAIN PLAN%'
AND s.Last_Active_Time > SYSDATE - 0.3
AND upper(s.Module) <> Upper('PL/SQL Developer')
AND p.Cost IS NOT NULL
AND p.ID = 0
ORDER BY p.Cost DESC,
p.Cpu_Cost DESC,
p.Io_Cost DESC) Tmp
GROUP BY Tmp.Sql_Id
order by sum(tmp.cost) desc) Filtro_Rownum
WHERE Rownum < 200) Filtro
ON Filtro.Sql_Id = p.Sql_Id
ORDER BY Filtro.Costosum DESC, p.Sql_Id, p.Id
</pre>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-2609109935618804432012-01-05T09:14:00.002+01:002012-01-05T09:58:42.603+01:00Oracle profiling session<pre class="prettyprint">
SQL> select
2 u_dump.value || '/' ||
3 db_name.value || '_ora_' ||
4 v$process.spid ||
5 nvl2(v$process.traceid, '_' || v$process.traceid, null )
6 || '.trc' "Trace File"
7 from
8 v$parameter u_dump
9 cross join v$parameter db_name
10 cross join v$process
11 join v$session
12 on v$process.addr = v$session.paddr
13 where
14 u_dump.name = 'user_dump_dest' and
15 db_name.name = 'db_name' and
16 v$session.audsid=sys_context('userenv','sessionid');
Trace File
--------------------------------------------------------------------------------
C:\ORACLE\PRODUCT\10.2.0\ADMIN\ORCL\UDUMP/cfdev_ora_9576.trc
SQL> alter session set sql_trace = true;
Session altered.
SQL> -- your SQL or PL/SQL CODE
2 /
PL/SQL procedure successfully completed.
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Pr
oduction
With the Partitioning, OLAP, Data Mining and Real Application Testing options
C:\>
</pre>
then analyze C:\ORACLE\PRODUCT\10.2.0\ADMIN\ORCL\UDUMP/cfdev_ora_9576.trc with tkprof
<pre class="prettyprint">
tkprof C:\ORACLE\PRODUCT\10.2.0\ADMIN\CFDEV\UDUMP/cfdev_ora_9576.trc out.txt sys=no
</pre>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-48978812435117787942011-12-14T14:56:00.002+01:002012-02-07T10:43:28.542+01:00inspect Oracle active sessionsHere come queries useful to see the current running sessions, together with the sql being executed and the associated events
<pre class="prettyprint">
select u.username, ash.session_id, ash.session_serial#, ash.event, count(*), ash.SQL_ID, s.sql_text
from gv$active_session_history ash, v$sql s, V$SESSION u
where ash.sql_id=s.sql_id and u.user# = ash.user_id
group by ash.session_id, ash.session_serial#, u.username, ash.SQL_ID, ash.event, sql_text
order by 1;
select se.username, se.sid, se.serial#, sq.sql_fulltext
from V$SESSION se, v$sql sq
where se.sql_id = sq.sql_id
order by 1
</pre>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-27958794642755607812011-11-18T16:37:00.001+01:002011-11-18T16:38:20.671+01:00gathering statistics on Oracle DBHere comes a script to gather statistics on Oracle DB
<pre class="prettyprint">
begin
dbms_stats.unlock_schema_stats('SCHEMA');
dbms_stats.delete_schema_stats('SCHEMA');
dbms_stats.gather_schema_stats(ownname => 'SCHEMA',
estimate_percent => 40.0,
granularity => 'GLOBAL',
block_sample => TRUE,
cascade => TRUE,
degree => DBMS_STATS.DEFAULT_DEGREE,
method_opt => 'for all columns size 1');
dbms_stats.lock_schema_stats('SCHEMA');
end;
select t.owner, t.table_name, t.last_analyzed from dba_all_tables t
where lower(t.owner) = 'your_schema';
</pre>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-34600763866266497942011-11-18T16:35:00.001+01:002012-01-05T09:55:59.209+01:00foreign keys without indexesIn Oracle database a foreign keys without an index defined on it could lead to contention problems (enq: TM – contention wait event).
The following script retrieves foreign keys not having indexes
<pre class="prettyprint">
--the script finds the missing indexes on FK
SELECT * FROM (
SELECT c.table_name, cc.column_name, cc.position column_position
FROM user_constraints c, user_cons_columns cc
WHERE c.constraint_name = cc.constraint_name
AND c.constraint_type = 'R'
MINUS
SELECT i.table_name, ic.column_name, ic.column_position
FROM user_indexes i, user_ind_columns ic
WHERE i.index_name = ic.index_name
)
ORDER BY table_name, column_position;
</pre>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-60813406172332220512011-10-17T11:02:00.004+02:002011-11-18T16:37:00.144+01:00Oracle roles and privilegesThe following very useful scripts are taken out from http://www.adp-gmbh.ch/ora/misc/recursively_list_privilege.html (thanks to René Nyffenegger)
Users to roles and system privileges
This is a script that shows the hierarchical relationship between system privileges, roles and users.
<pre class="prettyprint">
select
lpad(' ', 2*level) || granted_role "User, his roles and privileges"
from
(
/* THE USERS */
select
null grantee,
username granted_role
from
dba_users
where
username like upper('%&enter_username%')
/* THE ROLES TO ROLES RELATIONS */
union
select
grantee,
granted_role
from
dba_role_privs
/* THE ROLES TO PRIVILEGE RELATIONS */
union
select
grantee,
privilege
from
dba_sys_privs
)
start with grantee is null
connect by grantee = prior granted_role;
</pre>
System privileges to roles and users
This is also possible the other way round: showing the system privileges in relation to roles that have been granted this privilege and users that have been granted either this privilege or a role:
<pre class="prettyprint">
select
lpad(' ', 2*level) || c "Privilege, Roles and Users"
from
(
/* THE PRIVILEGES */
select
null p,
name c
from
system_privilege_map
where
name like upper('%&enter_privliege%')
/* THE ROLES TO ROLES RELATIONS */
union
select
granted_role p,
grantee c
from
dba_role_privs
/* THE ROLES TO PRIVILEGE RELATIONS */
union
select
privilege p,
grantee c
from
dba_sys_privs
)
start with p is null
connect by p = prior c;
</pre>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-3434385576253029442011-09-28T15:24:00.001+02:002011-10-17T11:04:04.355+02:00search and replace in an Oracle CLOBHere comes a very useful function which replaces a string in a CLOB with another string
the function has been taken out from http://www.astral-consultancy.co.uk/cgi-bin/hunbug/doco.cgi?11080
<pre class="prettyprint">
-- The function accepts three parameters, the same as the standard REPLACE function.
--1. p_clob: The CLOB data
--2. p_what: The search string
--3. p_with: The replacement string
FUNCTION dfn_clobReplace
( p_clob IN CLOB,
p_what IN VARCHAR2,
p_with IN VARCHAR2 ) RETURN CLOB IS
c_whatLen CONSTANT PLS_INTEGER := LENGTH(p_what);
c_withLen CONSTANT PLS_INTEGER := LENGTH(p_with);
l_return CLOB;
l_segment CLOB;
l_pos PLS_INTEGER := 1-c_withLen;
l_offset PLS_INTEGER := 1;
BEGIN
--It first checks that the p_what string is not null, to save time checking the CLOB.
IF p_what IS NOT NULL THEN
--The function then begins the first of two loops. The outer loop splits the main CLOB into segments of 32K, so that the inner loop can process the data.
WHILE l_offset < DBMS_LOB.GETLENGTH(p_clob) LOOP
l_segment := DBMS_LOB.SUBSTR(p_clob,32767,l_offset);
LOOP --The inner loop then checks for the search string, p_what, in the segment of CLOB that is current being processed.
l_pos := DBMS_LOB.INSTR(l_segment,p_what,l_pos+c_withLen);
EXIT WHEN (NVL(l_pos,0) = 0) OR (l_pos = 32767-c_withLen);
--If the search string is not found it exits the loop to process the next segment.
--If the search string is found at the very end of the string, it moves on to the next segment to be processed,
--as the **** segments overlap by the length of the search string ****, so a search string occurring over a segment break does not get missed.
l_segment := TO_CLOB( DBMS_LOB.SUBSTR(l_segment,l_pos-1)
||p_with
||DBMS_LOB.SUBSTR(l_segment,32767-c_whatLen-l_pos-c_whatLen+1,l_pos+c_whatLen));
END LOOP;
--The segment is then rebuilt, from the data before the search string, the replacement string, then the data after the search string.
l_return := l_return||l_segment;
l_offset := l_offset + 32767 - c_whatLen;
--The processed segment is then added to the return CLOB and the offset for the segment is increased by 32K minus the search string length.
END LOOP;
END IF;
RETURN(l_return);
END;
</pre>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-47369314161108288902011-09-23T18:21:00.004+02:002011-09-28T15:38:04.635+02:00Multi-criteria search query in Oracle PL/SQL with dynamic SQLHow to implement a multi-criteria search query in PL/SQL with dynamic SQL.<br />
<br />
It is very frequent to implement a search form with multiple criteria, where each criteria can be independently enabled by the user, according to her needs.<br />
The application will then need to perform a query on the database, taking into account all the criteria choosen by the user, that is perform a dynamic query. Here comes an example of how to implement a dynamic query in PL/SQL, using dynamic SQL.<br />
<br />
The query could be implemented also with a static query, which takes into account all the possible criteria, and switch them on according to the value of some input parameters.<br />
This static query would sadly perform very bad, since it makes the optimizer choose access paths for unnecessary criteria.<br />
<br />
For example, given the following table<br />
<pre class="prettyprint">
CREATE TABLE SUBJECT
(
SUBJECTID NUMBER(38,0) NOT NULL ENABLE,
SURNAME NVARCHAR2(400),
NAME NVARCHAR2(400)
DATEOFBIRTH TIMESTAMP (6),
CONSTRAINT PK_SUBJECT PRIMARY KEY (SUBJECTID) );
</pre>the following procedure performs a static search for an user taking into account her surname, name and birthdate and putting results into ResCursor1.<br />
Each criteria is switching on in the query according to whether the corresponding input parameter is not null.<br />
<pre class="prettyprint">
create or replace
PROCEDURE SEARCHPHYSICALPERSONS (Surname in nvarchar2 default null,
Name in nvarchar2 default null,
BirthDate in date default null
ResCursor1 out sys_refcursor) is
pSurname Subject.Surname%TYPE := Surname;
pName Subject.Name%TYPE := Name;
pBirthDate Subject.Dateofbirth%TYPE := BirthDate;
begin
open ResCursor1 for
select distinct
a.subjectid,
surname,
name,
from Subject a
where (pSurname is null or TRIM(upper(a.surname)) like TRIM(upper(pSurname||'%')))
and (pName is null or TRIM(upper(a.name)) = TRIM(upper(pName)))
and (pBirthDate is null or a.Dateofbirth = pBirthDate);
end SearchPhysicalPersons;
</pre><br />
The following approach will instead optimize the search taking into account only the necessary criteria, building a dynamic sql query which is being parsed at runtime by the DB engine (the query will use binding variables, since they are necessary for optimal performances).<br />
<br />
<pre class="prettyprint">
create or replace
TYPE physicalPersonsType AS OBJECT
( subjectid NUMBER(38,0),
surname VARCHAR2(400 CHAR),
name VARCHAR2(400 CHAR),
dateofbirth TIMESTAMP(6),
);
CREATE OR REPLACE TYPE physicalPersonsTableType AS TABLE OF physicalPersonsType;
</pre><br />
<br />
<br />
<pre class="prettyprint">
create or replace
FUNCTION readSearchPhysicalPersons(cur_hdl int) RETURN physicalPersonsTableType
PIPELINED IS
subjectid SUBJECT.SUBJECTID%type;
surname SUBJECT.SURNAME%type;
name SUBJECT.NAME%type;
dateofbirth SUBJECT.DATEOFBIRTH%type;
BEGIN
dbms_sql.define_column(cur_hdl, 1, subjectid);
dbms_sql.define_column(cur_hdl, 2, surname, 400);
dbms_sql.define_column(cur_hdl, 3, name, 400);
dbms_sql.define_column(cur_hdl, 4, dateofbirth);
LOOP
-- fetch a row
IF dbms_sql.fetch_rows(cur_hdl) > 0 then
-- fetch columns from the row
dbms_sql.column_value(cur_hdl, 1, subjectid);
dbms_sql.column_value(cur_hdl, 2, surname);
dbms_sql.column_value(cur_hdl, 3, name);
dbms_sql.column_value(cur_hdl, 4, dateofbirth);
PIPE ROW (physicalPersonsType(subjectid, surname, name, dateofbirth));
ELSE
EXIT;
END IF;
END LOOP;
RETURN;
END;
</pre><br />
<br />
<br />
<pre class="prettyprint">
create or replace
PROCEDURE SEARCHPHYSICALPERSONS (Surname in nvarchar2 default null,
Name in nvarchar2 default null,
BirthDate in date default null,
ResCursor1 out sys_refcursor) is
pSurname Subject.Surname%TYPE := Surname;
pName Subject.Name%TYPE := Name;
pBirthDate Subject.Dateofbirth%TYPE := BirthDate;
stmt_str varchar2(4000);
cur_hdl int;
rows_processed int;
commaFlag boolean := false;
begin
cur_hdl := dbms_sql.open_cursor; -- open cursor
stmt_str := 'SELECT DISTINCT A.SUBJECTID, SURNAME, NAME, DATEOFBIRTH'
||' FROM SUBJECT A'
||' WHERE 1=1';
if pSurname is not null then
stmt_str := stmt_str || ' AND (TRIM(UPPER(A.SURNAME)) LIKE TRIM(UPPER(:pSurname ||''%'')))';
end if;
if pName is not null then
stmt_str := stmt_str || ' AND (TRIM(UPPER(A.NAME)) = TRIM(UPPER(:pName)))';
end if;
if pBirthDate is not null then
stmt_str := stmt_str || ' AND (A.DATEOFBIRTH = :pBirthDate)';
end if;
--uncomment this line to see the generated sql
--dbms_output.put_line(stmt_str);
dbms_sql.parse(cur_hdl, stmt_str, dbms_sql.native);
-- supply binds (bind by name)
if pSurname is not null then
dbms_sql.bind_variable(cur_hdl, ':pSurname', pSurname);
end if;
if pName is not null then
dbms_sql.bind_variable(cur_hdl, ':pName', pName);
end if;
if pBirthDate is not null then
dbms_sql.bind_variable(cur_hdl, ':pBirthDate', pBirthDate);
end if;
rows_processed := dbms_sql.execute(cur_hdl); -- execute
open ResCursor1 for
select * from table(readSearchPhysicalPersons(cur_hdl));
END;
</pre>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-64457602672176398542011-09-21T11:19:00.000+02:002011-09-28T15:37:02.742+02:00Oracle, get the current DB instance--this is a useful query to get the DB instance on which the current session is running, useful especially in RAC mode<br />
SELECT sys_context('USERENV', 'INSTANCE') AS instance#, sys_context('USERENV', 'INSTANCE_NAME') AS instance_name FROM dualGiampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-54167614721564378982011-09-13T22:43:00.003+02:002011-10-13T11:42:03.647+02:00Oracle export/importhere comes an example of data export:<br />
<br />
the export must be performed on the source db server, the import on the target db server, since a local directory is required for the Oracle db server to export/import data<br />
<br />
-- Create datapump directory<br />
CREATE OR REPLACE DIRECTORY DATA_PUMP_DIR AS 'D:\Backup\Oracle\DataPumpDir';<br />
GRANT READ,WRITE ON DIRECTORY DATA_PUMP_DIR TO myorauser;<br />
<br />
-- Check datapump directory<br />
SELECT * FROM ALL_DIRECTORIES;<br />
<br />
expdp myorauser/password@SID directory=DATA_PUMP_DIR DUMPFILE=myorauserDump.dmp SCHEMAS=myorauser<br />
<br />
impdp DIRECTORY=DATA_PUMP_DIR DUMPFILE=myorauserDump.dmp SCHEMAS=myorauser<br />
<br />
when you are asked credentials, don't use the SYS users, use another user with powerful privileges (as SYSTEM)<br />
-always check that indexes have been correctly created in the target db<br />
-the option CONTENT=DATA_ONLY imports only data<br />
-in the target db must be created a tablespace with the same name of the tablespace containing the Oracle schema in the source dbGiampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-41174420559245347482011-06-30T13:08:00.001+02:002011-06-30T13:13:43.055+02:00ssh tunnel set upserver:<br />
edit the file /etc/ssh/sshd_config<br />
<br />
check that port-forwarding has not been disabled server-wide in /etc/ssh/sshd_config verify that<br />
AllowTcpForwarding is set to yes (default setting is yes) <br />
<br />
client:<br />
use the following syntax<br />
ssh -L localPort:remoteHost:RemoteHostPort sshServerHostGiampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-84854366252679080842011-06-20T10:57:00.000+02:002011-09-28T15:26:01.703+02:00JVM monitoringthis is an example of how to monitoring the execution of a JVM running JBoss 4.2.3 GA under Solaris OS:<br />
<br />
1. set the following Java options in run.conf (if you are on Windows, set them in run.bat)<br />
JAVA_OPTS="....... -XX:+HeapDumpOnOutOfMemoryError -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djboss.platform.mbeanserver -Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl -Djava.rmi.server.hostname=<putHereTheIPofYourServer> ............"<br />
2. use jvisualvm.exe in your JDK to attach to the remote JBoss: Remote -> Add Remote Host -> add JMX connection -> <putHereTheIPofYourServer>:9999<br />
3. run the following script on the server, to get memory utilization percentages:<br />
<br />
pid=`<pathToJDK>/bin/jps -l | grep Main | awk {'print $1'<br />
}`<br />
<pathToJDK>/bin/jstat -gcutil $pid 2000Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-28555987963389236082011-06-16T12:44:00.000+02:002011-09-30T14:34:53.896+02:00extract Java stack traces from log4j logshere is described a solution to retrieve from a Windows machine any errors and stack traces in log4j log files saved on a Solaris machine.<br />
Results are filtered out by a given date, in this example 2011-06-16<br />
<br />
1. download plink.exe and put in a new folder<br />
2. in the same folder create a batch file with the following content<br />
<code><br />
@echo off<br />
plink.exe -v -ssh 127.0.0.1 -P 24 -l username -pw password -m cmd.txt > output.txt<br />
</code><br />
3. in the same folder create the file cmd.txt with the following content<br />
<code><br />
for file in `find logFolder -name "logfile.log*" -print`<br />
do<br />
echo $file<br />
awk '{ if(($1 == "2011-06-16") && ($4 == "ERROR")){print $0; gl = getline row; while(gl > 0 && row !~ /^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]/){print row; gl = getline row;}} }' $file<br />
done<br />
</code>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-12305012397810261892011-06-15T11:04:00.000+02:002011-09-28T15:26:23.710+02:00Oracle, table sizeThe following query (to be run as sys user) is useful to calculate the space used by all tables<br />
<br />
<code><br />
SELECT OWNER,<br />
OBJECT_NAME,<br />
OBJECT_TYPE,<br />
TABLESPACE_NAME,<br />
NUM_ROWS,<br />
SUM(KBYTES) KBYTES,<br />
TO_CHAR(DECODE(NUM_ROWS, 0, 0, SUM(KBYTES) / (NUM_ROWS)), '9999.99') KB_ROW<br />
FROM (SELECT LO.OWNER,<br />
LO.TABLE_NAME AS OBJECT_NAME,<br />
EX.SEGMENT_TYPE AS OBJECT_TYPE,<br />
EX.TABLESPACE_NAME,<br />
TS.NUM_ROWS AS NUM_ROWS,<br />
ROUND((SUM(EX.BYTES) / 1024)) AS KBYTES<br />
FROM DBA_EXTENTS EX<br />
JOIN DBA_LOBS LO ON (EX.OWNER = LO.OWNER AND<br />
EX.SEGMENT_NAME = LO.SEGMENT_NAME)<br />
JOIN DBA_TAB_STATISTICS TS ON (LO.OWNER = TS.OWNER AND<br />
LO.TABLE_NAME = TS.TABLE_NAME)<br />
GROUP BY LO.OWNER,<br />
LO.TABLE_NAME,<br />
LO.COLUMN_NAME,<br />
EX.SEGMENT_NAME,<br />
EX.SEGMENT_TYPE,<br />
EX.TABLESPACE_NAME,<br />
TS.NUM_ROWS<br />
UNION ALL<br />
SELECT EX.OWNER,<br />
EX.SEGMENT_NAME AS OBJECT_NAME,<br />
EX.SEGMENT_TYPE AS OBJECT_TYPE,<br />
EX.TABLESPACE_NAME,<br />
TS.NUM_ROWS,<br />
ROUND((SUM(EX.BYTES) / 1024)) AS KBYTES<br />
FROM DBA_EXTENTS EX<br />
LEFT JOIN DBA_LOBS LO ON EX.OWNER = LO.OWNER<br />
AND EX.SEGMENT_NAME = LO.SEGMENT_NAME<br />
JOIN DBA_TAB_STATISTICS TS ON EX.OWNER = TS.OWNER<br />
AND EX.SEGMENT_NAME = TS.TABLE_NAME<br />
GROUP BY EX.OWNER,<br />
EX.SEGMENT_NAME,<br />
EX.SEGMENT_TYPE,<br />
EX.TABLESPACE_NAME,<br />
TS.NUM_ROWS)<br />
WHERE OWNER LIKE 'CF%'<br />
GROUP BY OWNER, OBJECT_NAME, OBJECT_TYPE, TABLESPACE_NAME, NUM_ROWS<br />
ORDER BY KBYTES DESC;<br />
<code>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-10542110328842129352011-02-07T18:24:00.005+01:002011-02-09T09:45:08.767+01:00Windows, vb script to get the process datathis script prints the process start time<br />
<br />
it can be run in this way<br />
<b>cscript <scriptname>.vbs <processname></b><br />
for example, if this script has been saved as the file named procInfo.vbs, in order to inspect all running instances of notepad.exe, it can be run as<br />
<b>cscript procInfo.vbs notepad.exe</b><br />
<br />
<pre>procName = WScript.Arguments.Item(0)
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process Where Name = '" & procName & "'")
For Each item In colProcesses
WScript.Echo(WMIDateStringToDate(item.CreationDate) & ", cmdLine " & item.CommandLine)
Next
Function WMIDateStringToDate(dtmDate)
WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function
</pre>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-31859079800675611402010-06-04T19:58:00.005+02:002011-09-28T15:53:16.827+02:00Eclipse plugin development: running a plugin as an RCP application, custom problems viewThe Eclipse framework comes with extremely powerful and reusable tools.<br />
One of these is the problems view, which doesn't work (on Eclipse Galileo) when running the plugin as a RCP application.<br />
<br />
<br />
Here comes a custom problem view simple and minimal implementation, as a replacement of the original one, for RCP plugins.<br />
<a name='more'></a><span class="MsgBodyText"><br />
<br />
-----------<br />
the view<br />
<br />
</span><br />
<pre class="prettyprint">
package org.eclipse.gmf.helpDesigner.helpDesigner.diagram.part;
import java.util.List;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.part.ViewPart;
public class ProblemsView extends ViewPart {
public static final String ID = "org.eclipse.gmf.helpDesigner.helpDesigner.diagram.part.ProblemsView";
public TableViewer viewer;
private UpdateJob updateJob;
public void createPartControl(Composite parent) {
createViewer(parent);
updateJob = new UpdateJob("updateMarkers");
IEditorPart editorPart = getSite().getPage().getActiveEditor();
updateJob.setEditorPart(editorPart);
updateJob.setProblemsView(this);
updateJob.schedule();
viewer.setInput(updateJob.getMarkerList());
}
private void createViewer(Composite parent) {
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL | SWT.FULL_SELECTION);
createColumns(viewer);
viewer.setContentProvider(new MarkerContentProvider());
viewer.setLabelProvider(new MarkerLabelProvider());
}
// This will create the columns for the table
private void createColumns(TableViewer viewer) {
String[] titles = { "Description", "Location", "Type" };
int[] bounds = { 100, 100, 100 };
for (int i = 0; i < titles.length; i++) {
TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
column.getColumn().setText(titles[i]);
column.getColumn().setWidth(bounds[i]);
column.getColumn().setResizable(true);
column.getColumn().setMoveable(true);
}
Table table = viewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
}
/**
* Passing the focus request to the viewer's control.
*/
public void setFocus() {
viewer.getControl().setFocus();
}
public static Display getDisplay() {
Display display = Display.getCurrent();
// may be null if outside the UI thread
if (display == null)
display = Display.getDefault();
return display;
}
public void clearMarkers() {
getDisplay().syncExec(new Runnable() {
public void run() {
while (viewer.getElementAt(0) != null) {
viewer.remove(viewer.getElementAt(0));
}
}
});
}
public void addMarkers(final List<validationmarker> markers) {
getDisplay().syncExec(new Runnable() {
public void run() {
viewer.add(markers.toArray());
}
});
}
}
</pre>
which I've mapped in my plugin.xml of the diagram code generated by GMF with the following xml mapping<br />
<pre class="prettyprint">
<extension point="org.eclipse.ui.views">
<view
class="org.eclipse.gmf.helpDesigner.helpDesigner.diagram.part.ProblemsView"
id="org.eclipse.gmf.helpDesigner.helpDesigner.diagram.part.ProblemsView"
icon="icons\eview16\problems_view.gif"
name="Problems view">
</view>
</extension>
</pre>
the job updating the markers<br />
<pre class="prettyprint">
package org.eclipse.gmf.helpDesigner.helpDesigner.diagram.part;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.ui.IEditorPart;
public class UpdateJob extends Job {
public UpdateJob(String name) {
super(name);
}
private List<validationmarker> markerList;
private IEditorPart editorPart;
private ProblemsView problemsView;
public List<validationmarker> getMarkerList() {
return markerList;
}
public void setEditorPart(IEditorPart editorPart) {
this.editorPart = editorPart;
}
public void setProblemsView(ProblemsView problemsView) {
this.problemsView = problemsView;
}
protected IStatus run(IProgressMonitor monitor) {
try {
if (editorPart instanceof IDiagramWorkbenchPart) {
final IDiagramWorkbenchPart part = (IDiagramWorkbenchPart) editorPart;
int severity = IStatus.INFO;
EditPartViewer viewer = part.getDiagramEditPart().getViewer();
View view = part.getDiagram();
if (view == null) {
return Status.CANCEL_STATUS;
}
problemsView.clearMarkers();
for (Iterator it = view.eAllContents(); it.hasNext();) {
EObject next = (EObject) it.next();
if (next instanceof View) {
ValidationMarker[] markers = ValidationMarker
.getMarkers(viewer, ViewUtil
.getIdStr((View) next));
if (markers != null && markers.length > 0) {
markerList = new ArrayList<validationmarker>();
for (int i = 0; i < markers.length; i++) {
markerList.add(markers[i]);
}
problemsView.addMarkers(markerList);
}
}
}
}
return Status.OK_STATUS;
} finally {
schedule(2000); //runs every 2 seconds
}
}
}
</pre>
a couple of classes responsible for drawing marker properties in the table
<pre class="prettyprint">
package org.eclipse.gmf.helpDesigner.helpDesigner.diagram.part;
import java.util.List;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
public class MarkerContentProvider implements IStructuredContentProvider {
@Override
public Object[] getElements(Object inputElement) {
@SuppressWarnings("unchecked")
List<validationmarker> markers = (List<validationmarker>) inputElement;
return markers.toArray();
}
@Override
public void dispose() {
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
}</pre>
<pre class="prettyprint">
package org.eclipse.gmf.helpDesigner.helpDesigner.diagram.part;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
public class MarkerLabelProvider extends LabelProvider implements
ITableLabelProvider {
private static final Image ERROR = HelpDesignerDiagramEditorPlugin
.getBundledImageDescriptor("icons/obj16/error_tsk.gif")
.createImage();
@Override
public String getColumnText(Object element, int columnIndex) {
ValidationMarker marker = (ValidationMarker) element;
switch (columnIndex) {
case 0:
return marker.getMessage();
case 1:
return marker.getLocation();
case 2:
switch (marker.getStatusSeverity()) {
case Diagnostic.OK:
return "OK";
case Diagnostic.INFO:
return "Info";
case Diagnostic.WARNING:
return "Warning";
case Diagnostic.ERROR:
return "Error";
default:
throw new RuntimeException("Should not happen");
}
default:
throw new RuntimeException("Should not happen");
}
}
@Override
public Image getColumnImage(Object element, int columnIndex) {
if (columnIndex == 0) {
switch (((ValidationMarker) element).getStatusSeverity()) {
case Diagnostic.ERROR:
return ERROR;
}
}
return null;
}
}</pre>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com4tag:blogger.com,1999:blog-5015767647562185180.post-32390672208927670722010-06-03T11:13:00.002+02:002011-09-28T15:26:40.331+02:00Oracle database, Monitoring open cursors Another great article of Natalka Roshak<br />
<a href="http://www.orafaq.com/node/758">http://www.orafaq.com/node/758</a><br />
on how to monitor open (and cached) cursorsGiampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-18195182636699999652010-04-20T11:46:00.001+02:002011-09-28T15:26:52.468+02:00Java, monitoring memory allocationthe JDK comes with a couple of tools which enables to monitor the memory which is being allocated during the execution of JVM process.<br />
<br />
<b>jps </b>which shows the JVM process currently running on the machine, together with their process id<br />
<b>jstat </b>which print a dump of the memory consumption of a JVM process<br />
<br />
syntax <br />
jstat -gcutil <procid> <interval><br />
</interval></procid>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-2781039677175209602010-04-06T14:30:00.007+02:002010-04-28T11:24:08.257+02:00Alfresco in-production installation on WindowsSome tips about an in-production installation of Alfresco Community Release on a Windows 2003 server, 64 bit<br />
<ul><li>install a 64bit JVM</li>
<li>install MySql</li>
<li>download the Alfresco community edition (3.2r2 at the moment of writing), preconfigured Tomcat bundle version (available from the custom installs page):</li>
<ul><li>delete the mysql folder under the root folder</li>
<li>modify the startup script deleting the MySql start and stop sections</li>
</ul>
<li>download and install the Windows Server 2003 resource toolkit</li>
<li>create a srvany.exe windows service in order to get Alfresco running as a Windows Service</li>
<li>optional: migrate a dev Alfresco environment by copying the alf_data directory and exporting the alfresco db schema (IMPORTANT: after having stopped the Alfresco server on both the installations)</li>
<li>enable the CIFS file server, disabling the File and Printer Sharing for the local area network connection in use. Note that on win64x you may some issues related to the CIFS file server leading to a <disablenio>100% CPU consumption.</disablenio></li>
<li>use a script to take a daily backup (run as a scheduled activity), something like<br />
FOR /f "tokens=1,2,3,4 delims=/ " %%a IN ('date /t') DO (<br />
SET FileDate=%%c-%%b-%%a<br />
)<br />
<br />
echo executing backup in date %FileDate%<br />
<br />
echo off<br />
xcopy C:\alfresco-community-tomcat-3.2r2\alf_data\* C:\backup\Alfresco\%FileDate%\alf_data\ /E /Y<br />
mysqldump -uroot -proot alfresco > C:\backup\Alfresco\db_data\alfresco_db_data_%FileDate%.sql<br />
<br />
pause</li>
</ul>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-72155013076278048462010-04-02T13:35:00.003+02:002010-04-06T22:29:41.611+02:00create a Windows serviceHere comes an useful description on how to get a program executed as a Windows service<br />
<br />
http://support.microsoft.com/?scid=kb%3Ben-us%3B137890&x=10&y=8Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-24709451134745459292009-12-15T19:02:00.000+01:002009-12-15T19:02:12.453+01:00Open Office Macro Here comes a macro for Open Office Writer, written in StarBasic.<br />
It aims at realizing a sort of constraint logic between controls in a form.<br />
<br />
In the first part there is a data structure which specify all the constraints<br />
on three controls, where the first two a comboboxes and the last is a text area.<br />
<br />
In the second part there is the handler for the "onChange" event,<br />
which loads data according to the specifications in the data structure.<br />
<br />
<br />
REM ***** BASIC *****<br />
'------------------------------------------------------------------------<br />
'------------------------------------------------------------------------<br />
'------------------------------------------------------------------------<br />
'data block<br />
'------------------------------------------------------------------------<br />
'------------------------------------------------------------------------<br />
'------------------------------------------------------------------------<br />
' tabella dependenciesTable(objName, value, dependentObj, valueSetID)<br />
' Primary Key: objName, value, dependentOb<br />
' associa per ogni oggetto 'objName'<br />
' un oggetto dipendente 'dependentObj' che assumerà <br />
' il set di valori identificato da 'valueSetID' (vedere tabella valueSets)<br />
' quando l'oggetto 'objName' assumerà il valore 'value'<br />
Global dependenciesTable(2, 3) As String<br />
<br />
' tabella valueSets(valueSetID, value)<br />
' Primary Key: valueSetID, value<br />
' associa per ogni valueSetID un set di valori<br />
Global valueSets(6, 1) As String<br />
'------------------------------------------------------------------------<br />
Sub Init<br />
<br />
dependenciesTable(0, 0) = "cb1"<br />
dependenciesTable(0, 1) = "uno"<br />
dependenciesTable(0, 2) = "cb2"<br />
dependenciesTable(0, 3) = "1"<br />
<br />
dependenciesTable(1, 0) = "cb1"<br />
dependenciesTable(1, 1) = "due"<br />
dependenciesTable(1, 2) = "cb2"<br />
dependenciesTable(1, 3) = "2"<br />
<br />
dependenciesTable(2, 0) = "cb1"<br />
dependenciesTable(2, 1) = "tre"<br />
dependenciesTable(2, 2) = "cb3"<br />
dependenciesTable(2, 3) = "3"<br />
<br />
<br />
<br />
<br />
valueSets(0, 0) = "1"<br />
valueSets(0, 1) = "obj1ValPerUno1"<br />
<br />
valueSets(1, 0) = "1"<br />
valueSets(1, 1) = "obj1ValPerUno2"<br />
<br />
valueSets(2, 0) = "1"<br />
valueSets(2, 1) = "obj1ValPerUno3"<br />
<br />
valueSets(3, 0) = "2"<br />
valueSets(3, 1) = "obj1ValPerDue1"<br />
<br />
valueSets(4, 0) = "2"<br />
valueSets(4, 1) = "obj1ValPerDue2"<br />
<br />
valueSets(5, 0) = "2"<br />
valueSets(5, 1) = "obj1ValPerDue3"<br />
<br />
valueSets(6, 0) = "3"<br />
valueSets(6, 1) = "selezionato il valore tre"<br />
<br />
End Sub<br />
'------------------------------------------------------------------------<br />
'------------------------------------------------------------------------<br />
'------------------------------------------------------------------------<br />
'end of data block<br />
'------------------------------------------------------------------------<br />
'------------------------------------------------------------------------<br />
'------------------------------------------------------------------------<br />
<br />
'------------------------------------------------------------------------<br />
'------------------------------------------------------------------------<br />
'------------------------------------------------------------------------<br />
'engine block<br />
'------------------------------------------------------------------------<br />
'------------------------------------------------------------------------<br />
'------------------------------------------------------------------------<br />
Sub Main<br />
Init()<br />
End Sub<br />
'------------------------------------------------------------------------<br />
' ritorna nel parametro values il set dei valori <br />
' da assegnare a un oggetto dependentObj<br />
' quando l'oggetto ctrlName vale selectedVal<br />
' il set di valori ritornati dipendono da che valore ha assunto il controllo che ha scatenato l'evento<br />
' secondo le tabelle dependenciesTable e valueSets<br />
Sub getValueSet(ctrlName As String, selectedVal As String, dependentObj As String, values)<br />
Dim valueId As String<br />
<br />
Dim firstTime As Integer<br />
firstTime = 1<br />
<br />
Dim last As Integer<br />
last = 0<br />
<br />
'selezione dell'id dei valori, nella tabella valueSets<br />
For I = 0 To UBound(dependenciesTable)<br />
If dependenciesTable(I, 0) = ctrlName AND dependenciesTable(I, 1) = selectedVal AND dependenciesTable(I, 2) = dependentObj Then<br />
valueId = dependenciesTable(I, 3) ' id dei valori selezionato<br />
Exit For<br />
End If<br />
Next<br />
<br />
' ricerca dei valori in valueSets in base all'id<br />
For I = 0 To UBound(valueSets)<br />
If valueSets(I, 0) = valueId Then<br />
If FirstTime = 0 Then<br />
last = last + 1<br />
Redim Preserve values(last)<br />
End If<br />
values(last) = valueSets(I, 1)<br />
End If<br />
firstTime = 0<br />
Next<br />
End Sub<br />
'------------------------------------------------------------------------<br />
' ritorna nel parametro res l'elenco degli oggetti dipendenti<br />
' dal controllo ctrlName quando il suo valore è ctrlValue<br />
' i controlli di questo elenco dipendono da che valore ha assunto il controllo che ha scatenato l'evento<br />
' secondo la tabella dependenciesTable<br />
Sub getDependentObjsId(ctrlName As String, ctrlValue As String, res)<br />
Dim firstTime As Integer<br />
firstTime = 1<br />
<br />
Dim last As Integer<br />
last = 0<br />
<br />
For I = 0 To UBound(dependenciesTable)<br />
If dependenciesTable(I, 0) = ctrlName AND dependenciesTable(I, 1) = ctrlValue AND res(last) <> dependenciesTable(I, 2) Then 'last clause helps in preventing from inserting duplicates (not guaranteeing)<br />
If FirstTime = 0 Then<br />
last = last + 1<br />
Redim Preserve res(last)<br />
End If<br />
res(last) = dependenciesTable(I, 2)<br />
End If<br />
firstTime = 0<br />
Next<br />
<br />
End Sub<br />
'------------------------------------------------------------------------<br />
Sub OnChangeValue(oEvent)<br />
oControl = oEvent.Source.Model<br />
oForm = oControl.Parent<br />
Dim valueId As String<br />
<br />
Dim depObjs(0) As String<br />
<br />
'popola l'array depObjs con l'elenco dei controlli dipendenti dall'evento corrente<br />
getDependentObjsId(oControl.Name, oControl.Text, depObjs)<br />
<br />
Dim textVar As String<br />
<br />
For I = 0 To UBound(depObjs) ' per ogni elemento dipendente<br />
Dim listValues(0)<br />
listValues(0) = ""<br />
<br />
getValueSet(oControl.Name, oControl.Text, depObjs(I), listValues) 'valori<br />
<br />
For K = 0 to oForm.Count - 1<br />
If oForm.getByIndex(K).Name = depObjs(I) Then<br />
If hasProperty(oForm.getByIndex(K), "StringItemList") = 1 Then 'ComboBox<br />
oForm.getByIndex(K).StringItemList = listValues<br />
oForm.getByIndex(K).Text = ""<br />
Else 'altro caso<br />
textVar = ""<br />
For valIdx = 0 To UBound(listValues)<br />
textVar = "" & textVar & listValues(valIdx)<br />
Next<br />
oForm.getByIndex(K).Text = textVar<br />
End If<br />
Exit For<br />
EndIf<br />
Next K<br />
Next<br />
<br />
End Sub<br />
'------------------------------------------------------------------------<br />
Function hasProperty( oObj, prop )<br />
oIntrospection = createUnoService( "com.sun.star.beans.Introspection" )<br />
oObjInfo = oIntrospection.inspect( oObj )<br />
<br />
oProperties = oObjInfo.getProperties( com.sun.star.beans.PropertyConcept.ALL )<br />
<br />
For i = LBound( oProperties ) To UBound( oProperties )<br />
oProperty = oProperties( i )<br />
cPropertyName = oProperty.Name<br />
If cPropertyName = prop Then<br />
hasProperty() = 1<br />
Exit Function<br />
End If<br />
Next<br />
<br />
hasProperty() = 0<br />
<br />
End Function <br />
'------------------------------------------------------------------------<br />
'------------------------------------------------------------------------<br />
'------------------------------------------------------------------------<br />
'end of engine block<br />
'------------------------------------------------------------------------<br />
'------------------------------------------------------------------------<br />
'------------------------------------------------------------------------Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0tag:blogger.com,1999:blog-5015767647562185180.post-32756224225399013382009-12-12T14:34:00.001+01:002011-09-28T15:27:23.600+02:00Linux keyboard remapping on X server<ul><li>use xev to retrieve keycodes</li>
<li>use xmodmap <filename> to load a remapping file<br />
</filename></li>
<li>use the command setxkbmap to restore a keyboard setting, ex. <br />
the command "setxkbmap it<filename></filename>" restore the it keyboard<br />
</li>
</ul>Giampohttp://www.blogger.com/profile/03627171580133103635noreply@blogger.com0