Monday 23 August 2010

query strings in LOBs

select * from TABLE where dbms_lob.instr(COLUMN, utl_raw.cast_to_raw('TEXT'),1,1) > 0

Thursday 19 August 2010

iconify & pop windows for long running batch jobs

When I start long running jobs, I lose context and working with something else and start. Then I forget whatever I was doing.

sudo apt-get install xwit

in /usr/bin create 2 files

iconifyw
-------------------
tmpwinid=`env|grep WINDOWID | sed 's/WINDOWID=\([0-9]*\)/\1/'`
xwit -iconify -id $tmpwinid
-------------------

popbw
-------------------
tmpwinid=`env | grep WINDOWID | sed 's/WINDOWID=\([0-9]*\)/\1/'`
xwit -pop -id $tmpwinid
aplay -q /usr/share/sounds/beep-1.wav
-------------------

the wav file has to be found somewhere

chmod a+x popbw
chmod a+x iconifyw


test with

> iconifyw ;sleep 5 ;popbw

Tuesday 27 July 2010

oracle audit

http://www.dba-oracle.com/security/application_users.html
from: http://miguelmoreno.net/post/Increase-your-VMWare-disk-size.aspx

Increase your VMWare disk size… Over the years I have used both Microsoft's Virtual PC and VMWare. As to which one I prefer and is better, that is a whole other post. In this post I wanted to write about increasing the size of a virtual hard drive of a VMWare machine.

When creating a new machine you are asked to define the size of your drive and when you choose 16Gb, you think you'll never use that much anyways, until, after a while, you realize you do need more. In that case, there are no options to increase the size of your C: drive. Ofcourse, you could always add a new drive (D or E), but that is just more files lingering around, as if VMware didn't create enough already....

With regards to your OS drive size, you are stuck with the size you chose. No menu options, dialogs, or wizards can increase it…

...unless you do this trick. Thanks to Paul Marshall for outlining these steps.

I have done this a couple of times and have found these steps work almost without fail. One observation, is that apparently the hard drive needs to be assigned a drive letter, or otherwise you cannot extend it. Here are the complete steps:

1: Create a new full clone of your VM machine you want to increase in size, ensuring it has no snapshots.
2: Open the folder containing your VM files and you should have only one vmdk file.
3: Open a Command Prompt and issue the following command, choosing your own size in Gigabytes, followed by the path to the vmdk file: vmware-vdiskmanager -x 20Gb vmdiskfile.vmdk
4: After several minutes, the process completes, however, the disk is not ready yet. 5: You have expanded it, but the newly added space has not been allocated yet and is thus unusable at this point. If the disk is the system volume you will need to mount the disk in a second VM and expand it from there. If its not a system volume do it within the virtual machine it belongs to.
6: Once you've mounted the disk in a different VM or booted up the VM it belongs to if its not the system volume, do the following: click on Start and then right-click on My Computer and select Manage
7: Click on Disk Management
8: Your second hard drive should show as available and the difference in space shows as unpartitioned.
9: Ensure this second hard drive has a drive letter, if not, assign it one.
10: Open a Command Prompt and type: diskpart
11: Then type list disk and ensure the disk you want to expand is indeed in the list.
12: Now type list volume
13: This will show you the drives, their volume number, capacity etc. You now need to select the volume you are about to expand, using the following command. Where n is equal to the number of the volume. select volume=n
14: Once selected, you can now expand it using the extend command. Type extend, and your hard drive is ready. Close your machine (without saving) and start up the VM that this drive is the system volume on and check the size.
by Miguel Moreno

Friday 23 July 2010

install grc

add match in /etc/grc.conf

add corresponding conf file in /usr/share/grc

for example log4j


#Colours are one of:
# none, default, bold, underline, blink, reverse, concealed,
# black, green, yellow, blue, magenta, cyan, white,
# on_black, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white
# beep
#
#count is one of words: once, more, stop, previous, block or unblock
#
# * once means that if the regexp is matched, its first occurrence is coloured
# and the program will continue with other regexp's.
#
# * more means that if there are multiple matches of the regexp in one line,
# all of them will be coloured.
#
# * stop means that the regexp will be coloured and program will move to the
# next line (i.e. ignoring other regexp's)
#
# * previous means the count will be the same as for the previous line
#
# * block marks a start of a multiline block of text, coloured with
# the same colour
#
# * unblock, obviously, marks the end of such a block

regexp=\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\W\d{3}
colours="\033[1;38;5;16m"
count=more
=====
regexp=INFO\s+\[.+\]
colours=blue
count=once
=====
regexp=\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\W\d{3}\s+INFO
colours=on_blue
count=once
=====
regexp=DEBUG\s+\[.+\]
colours=green
count=once
=====
regexp=\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\W\d{3}\s+DEBUG
colours=on_green
count=once
=====
regexp=WARN\s+\[.+\]
colours=yellow
count=once
=====
regexp=\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\W\d{3}\s+WARN
colours=on_yellow
count=once
=====
regexp=ERROR\s+\[.+\]
colours=red
count=once
=====
regexp=\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\W\d{3}\s+ERROR
colours=on_red
count=once


Then use grc:

grc tail -300f x.log

this will trigger the log.conf file and colourize the tail output

Monday 5 July 2010

Use marathon ant and maven

Running marathon from an ant task is easy. To setup the classpath however is a pain. Marathon can either run in test or gui mode. Gui is used when you develop a test.

Start with installing the actual marathon application.

Create a pom with the artifact that contains the gui application. This is just so that the pom version is updated by a release.

Finally use this ant file to run marathon:
-------------------------------------------------------
<?xml version="1.0"?>

<project name="main" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">


<property name="m2_loc_repo" value="${user.home}/.m2/repository"/>

<!-- has its own pom so that we the version will change with the maven releases -->
<artifact:dependencies pathId="aqva_client.classpathId">
<pom file="pom.xml"/>
<localRepository path="${m2_loc_repo}"/>
</artifact:dependencies>

<taskdef resource="net/sf/antcontrib/antlib.xml"/>

<property file="aqva_marathon.properties"/>
<fail unless="marathon.home">
You need to add a file called aqva_marathon.properties with the following properties:

marathon.home (required): path to marathon downloaded from here http://www.marathontesting.com
aqva_url (optional): url to aqva server, default: http://localhost:8080/Aqva/
aqva_user (optional): user aqva server, default: roger
aqva_pwd (optional): password aqva server, default: helly
</fail>


<path id='marathon_classpath'>
<fileset dir="${marathon.home}">
<include name="marathon.jar"/>
<include name="marathon-python.jar"/>
<include name="marathon-ruby.jar"/>
<include name="marathon-runtime.jar"/>
</fileset>
<fileset dir="${marathon.home}/Support">
<include name="forms-1.2.1/forms-1.2.1.jar"/>
<include name="jaccess-1.3/jaccess.jar"/>
<include name="jedit-textArea.jar"/>
<include name="jline-0.9.93.jar"/>
<include name="junit3.8.2/junit.jar"/>
<include name="looks-2.2.0/looks-2.2.0.jar"/>
<include name="vldocking_2.1.5C.jar"/>
</fileset>
</path>


<property name='marathon.project.dir' value='.'/>

<!-- the default test i.e. all tests -->
<property name="test" value=""/>
<property name="aqva_url" value="xxx"/>
<property name="aqva_user" value="yyy"/>
<property name="aqva_pwd" value="zzz"/>

<!-- has a value that is used for all tests in run, use this to create unique data that is used
between tests in one run -->
<tstamp>
<format property="timestamp_val" pattern="yyyyMMdd_HHmmss_SSS" />
</tstamp>


<target name="test" description="runs test(s) in batch mode (wo gui) -Dtest= to run a specific test">
<property name="app_classpath" refid="aqva_client.classpathId"/>

<java classname="net.sourceforge.marathon.Main" fork="yes">
<classpath refid="marathon_classpath"/>
<jvmarg value="-Dmarathon.application.classpath=${app_classpath}"/>
<jvmarg value="-Dpython.cachedir=${env.HOME}/.jycache"/>
<jvmarg value="-Dmarathon.project.file=marathon_test.project"/>
<!-- send in java exe -->
<jvmarg value="-Dmarathon.application.vm.command=${java.home}/bin/java"/>
<!-- send startup args -->
<jvmarg value="-Dmarathon.application.vm.arguments=-Daqva_url=${aqva_url} -Daqva_user=${aqva_user} -Daqva_pwd=${aqva_pwd} -Dtimestamp_val=${timestamp_val}"/>

<arg value="-batch"/>
<arg value="-reportdir"/>
<arg value="${marathon.project.dir}/reports"/>
<arg line="${marathon.project.dir}"/>
<arg line="${test}"/>
</java>
</target>

<target name="gui" description="run marathon gui for developing tests">
<!-- need to set the classpath in the project file-->
<property name="app_classpath" refid="aqva_client.classpathId"/>

<propertyregex property="app_classpath_fixed"
input="${app_classpath}"
regexp="\\"
replace="/"
global="true"
defaultValue="${app_classpath}"/>
<propertyregex property="JAVA_EXE_PATH_fixed"
input="${java.home}/bin/java"
regexp="\\"
replace="/"
global="true"
defaultValue="${java.home}/bin/java"/>
<copy file="resources/marathon_gui.project_TEMPLATE" tofile="temp/marathon_gui.project" overwrite="true">
<filterset>
<filter token="APP_CLASSPATH" value="${app_classpath_fixed}"/>
<filter token="JAVA_EXE_PATH" value="${JAVA_EXE_PATH_fixed}"/>
<filter token="APP_ARGS"
value="-Daqva_url=${aqva_url} -Daqva_user=${aqva_user} -Daqva_pwd=${aqva_pwd} -Dtimestamp_val=${timestamp_val}"/>
</filterset>
</copy>

<!--echo message="${app_classpath}"/-->
<java classname="net.sourceforge.marathon.Main" fork="yes">
<classpath refid="marathon_classpath"/>
<jvmarg value="-Xmx256m"/>
<jvmarg value="-Dmarathon.home=${marathon.home}"/>
<jvmarg value="-Dpython.cachedir=${env.HOME}/.jycache"/>
<jvmarg value="-Dmarathon.project.file=temp/marathon_gui.project"/>

<arg line="${marathon.project.dir}"/>
</java>
</target>

</project>

------

Monday 28 June 2010

exclude transitive dependencies in maven built ear

set: <defaultlibbundledir>..</defaultlibbundledir>
as in

<plugin>
<groupid>org.apache.maven.plugins</groupid>
<artifactid>maven-ear-plugin</artifactid>
<version>2.4.2</version>
<configuration>
<version>5</version>
<defaultlibbundledir>..</defaultlibbundledir>
<modules>
<jarmodule>
<groupid>antlr</groupid>
<artifactid>antlr</artifactid>
<includeinapplicationxml>true</includeinapplicationxml>
<bundledir>APP-INF/lib</bundledir>
</jarmodule>
</modules>
...
</configuration>
</plugin>

Friday 26 March 2010

android:
adb logcat - trace log
telnet localhost
gsm call 12345678

Friday 22 January 2010

FileInputStream input = new FileInputStream("/tmp/1.xml");
FileChannel channel = input.getChannel();

// Create a read-only CharBuffer on the file
ByteBuffer bbuf = channel.map(FileChannel.MapMode.READ_ONLY, 0, (int) channel.size());
CharBuffer cbuf = Charset.forName("UTF-8").newDecoder().decode(bbuf);

Tuesday 5 January 2010

vmware tools, ubuntu 9.10 minimal virtual machine

First:
sudo apt-get install build-essential linux-headers-`uname -r` gcc make

Follow: http://langui.sh/2009/10/05/ubuntu-9-10-in-vmware/

We use the virtual kernel package
cd /usr/src/
sudo dpkg -i --force-depends open-vm-modules-2.6.31-14-generic-pae_2009.07.22-179896-2+2.6.31-14.48_i386.deb

The steps above upgraded the kernel but the vmware tools is compiled for the older kernel. Follow
http://www.kunthar.com/blogs/kunthar.php/grub2-switching-boot-order

to do a default boot from the older