Category Archives: Technology

Screen Capture Open Menus

I know I posted a link to this on SM the other day, but wanted to add the abbreviated version here for my reference.

If you’ve ever had the need to capture a screen shot, but also capture a menu that may be open (like File -> New…) you can still use the build-in Windows “Snipping Tool” to grab what you need.

  1. Run the “Snipping Tool”
  2. Press the Esc key
  3. Open the menu you want to screen shot
  4. Press Ctrl+PrtScr
  5. Click “New” on the “Snipping Tool” and pick what you want to grab

Here’s an example:

screen-capture-example

Please remember to subscribe to the newsletter or feed to stay up to date!

Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself.

DB2 Stats vs Actual

Ever have a DB2 query that all of a sudden went from performing just fine to being dog slow? If so, there may be an issue with the stats on one or more of the tables being used in the query. To check, run the SQL below replacing XX and TABLE_NM with your appropriate schema and table in 2 places…

-- What DB2 thinks the table count is
SELECT  'Stats' AS TYPE_X,
        CARD AS COUNT_NB,
        STATS_TIME AS UPDATED_TS
FROM    SYSCAT.TABLES 
WHERE   TABSCHEMA = 'XX' 
        AND TABNAME ='TABLE_NM'
    UNION
-- Actual table count
SELECT  'Actual' AS TYPE_X,
        COUNT(*) AS COUNT_NB,
        CURRENT_TIMESTAMP AS UPDATED_TS
FROM    XX.TABLE_NM
FOR READ ONLY WITH UR

… if the record counts are way off, have your DBA do a runstats on the table in question followed by a rebind of any stored procs that use the table.

Please remember to subscribe to the newsletter or feed to stay up to date!

Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself.

Do I have 32 or 64 bit Java Installed?

Hopefully by now you’re familiar with…

java -version

… to determine what version of Java you have installed, but sometimes you may want to know if you’re running a 32 bit or 64 bit version because you get an error like this…

Can't load AMD 64-bit .dll on a IA 32-bit platform

… to find out just run this variation of the command…

java -d64 -version

… if you have a 64 bit version you’ll get typical output. If not, you’ll get an error similar to this…

This Java instance does not support a 64-bit JVM.
Please install the desired version.
Please remember to subscribe to the newsletter or feed to stay up to date!

Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself.

DB2 Recursive Query

If you’ve ever had to do a recursive query in DB2 to get a hierarchy of records, feel free to use this as a starting point…

WITH LINKS (PARENT_ID, CHILD_ID, UPDATED_TS) AS 
    ( 
    SELECT  ROOT.PARENT_ID, ROOT.CHILD_ID, ROOT.UPDATED_TS 
    FROM    XX.EVENTS ROOT 
    WHERE   ROOT.CHILD_ID = '234ASDFASDF' 
        UNION ALL 
    SELECT  CHILD.PARENT_ID, CHILD.CHILD_ID, CHILD.UPDATED_TS 
    FROM    LINKS PARENT, XX.EVENTS CHILD 
    WHERE   PARENT.PARENT_ID = CHILD.CHILD_ID 
    ) 
SELECT  PARENT_ID, CHILD_ID, UPDATED_TS 
FROM    LINKS 
ORDER BY UPDATED_TS 
FOR READ ONLY WITH UR

… yes, newer versions of DB2 have this ability built in but you’re not always using the most recent version are you??

Thanks to this page for pointing me in the right direction.

Please remember to subscribe to the newsletter or feed to stay up to date!

Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself.

Remove Duplicate Lines in Notepad++

If you’ve ever had the need to remove the duplicate lines from a long list of entries like so…

hi
bye
hi
guy
bye
hi

… and are looking for this…

hi
bye
guy

You can use the find/replace feature in Notepad++ to do it if you use the regex funcationality. Here’s the find string…

^(.*?)$\s+?^(?=.*^\1$)

Just replace with a zero length string.

If you’d like to read up on the details I found this tip here

Please remember to subscribe to the newsletter or feed to stay up to date!

Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself.

Linux ls output colors

If you’ve used linux much and your terminal is set to display files and directories in color, you know how frustrating it can be to have dark blue text on a black background like so (I’ve seen it much worse too)…

dirColorBefore

If you would like to modify the output so the colors are a bit more readable, you can add the following to your .bashrc file…

alias ls='ls --color'
LS_COLORS='di=33:fi=36:ex=31'
export LS_COLORS

which will produce an easier to read version like so (with directories yellow, files a crayon/teal, and executable files red)…

dirColorAfter

As pointed out in this article

The first line makes ls use the –color parameter by default, which tells ls to display files in different colours based on the setting of the LS_COLORS variable.

The second line is the tricky one, and what I have worked out so far has been by trial and error. The parameters (di, fi, etc.) refer to different Linux file types. I have worked them out as shown

di = directory
fi = file
ln = symbolic link
pi = fifo file
so = socket file
bd = block (buffered) special file
cd = character (unbuffered) special file
or = symbolic link pointing to a non-existent file (orphan)
mi = non-existent file pointed to by a symbolic link (visible when you type ls -l)
ex = file which is executable (ie. has ‘x’ set in permissions).

The *.rpm=90 parameter at the end tells ls to display any files ending in .rpm in the specified colour, in this case colour 90 (dark grey). This can be applied to any types of files (eg. you could use ‘*.png=35’ to make jpeg files appear purple.) As many or as few parameters as you like can go into the LS_COLORS variable, as long as the parameters are separated by colons.

Using trial and error (and a little bash script I wrote… my first one ever! 🙂 I worked out all the colour codes, at least my interpretation of them –

0 = default colour
1 = bold
4 = underlined
5 = flashing text
7 = reverse field
31 = red
32 = green
33 = orange
34 = blue
35 = purple
36 = cyan
37 = grey
40 = black background
41 = red background
42 = green background
43 = orange background
44 = blue background
45 = purple background
46 = cyan background
47 = grey background
90 = dark grey
91 = light red
92 = light green
93 = yellow
94 = light blue
95 = light purple
96 = turquoise
100 = dark grey background
101 = light red background
102 = light green background
103 = yellow background
104 = light blue background
105 = light purple background
106 = turquoise background

Please remember to subscribe to the newsletter or feed to stay up to date!

Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself.

NullPointerException – could not publish to server

Ok, so this is an obscure one, but if it saves anyone from multiple days of banging their head against the wall it’s worth it…

Recently I was working in eclipse, had created my component, compiled it, and had it pushed to our ivy repository. I then went to bring it into another (web) project when I started getting complaints about a NullPointerException. For kicks I tried running the web app and received the error “NullPointerException (could not publish to server)”. With all that useful information how could I not figure out what the problem was?

Fortunately another developer I spoke with had seen the issue before and pointed me in the right direction. In the utility component/jar you have to (see screen shot below too)…

  1. Go to Project -> Properties
  2. Click on “Project Facets”
  3. Check “Utility Module”

And then it will just magically work. Wasn’t that completely obvious?

EclipseUtilityMode

Please remember to subscribe to the newsletter or feed to stay up to date!

Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself.

How Much Space Is Being Used by 1 LOB / CLOB / BLOB in DB2

Building off of yesterdays lesson on how to determine how much space a table is using (including LOBs and Indexes), there may come a time when you need to determine how much space 1 or more specific records are taking up. To do that, use the LENGTH() function which will return you how many bytes the field is using. Simply do some math to get a more useful value (like KB).

SELECT length(LOB_DATA_X) BYTE_A, length(LOB_DATA_X) / 1024 KB_A
FROM XX.MY_TABLE
FETCH FIRST 10 ROWS ONLY WITH UR FOR READ ONLY;
Please remember to subscribe to the newsletter or feed to stay up to date!

Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself.

Get Space Used by LOB / CLOB / BLOB in DB2

If you have a DB2 table and want to get information as to how much space a particular table is using, you could try and deduce it from things like the row length, or you could just query the view via a table function and make your life a heck of a lot easier.

For instance, start with something like this…

SELECT * FROM TABLE(SYSPROC.ADMIN_GET_TAB_INFO('XX', 'MY_TABLE'));

Previous versions of this function include ADMIN_GET_TAB_INFO_V97 and ADMIN_GET_TAB_INFO_V95. The nice thing is that it appears you don’t have to be a DBA to query the info which is nice for us app developers out there!

Keep in mind that sizes returned are in KB, so you may want to convert the data to something more useful like so…

SELECT  TRIM(TABSCHEMA) || '.' || TRIM(TABNAME) AS TABLE_NM,
        DATA_OBJECT_P_SIZE / 1024 AS DATA_P_SIZE_NB, 
        LOB_OBJECT_P_SIZE / 1024 AS LOB_P_SIZE_MB, 
        XML_OBJECT_P_SIZE / 1024 AS XML_P_SIZE_MB, 
        LONG_OBJECT_P_SIZE / 1024 AS LONG_P_SIZE_MB, 
        (DATA_OBJECT_P_SIZE + LOB_OBJECT_P_SIZE + XML_OBJECT_P_SIZE + LONG_OBJECT_P_SIZE) / 1024 AS TOTAL_P_SIZE_MB,
        INDEX_OBJECT_P_SIZE / 1024 AS INDEX_OBJECT_P_SIZE_MB
FROM TABLE(SYSPROC.ADMIN_GET_TAB_INFO('XX', 'MY_TABLE'));

See also: this link

Please remember to subscribe to the newsletter or feed to stay up to date!

Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself.

Determine Default Java JVM HeapSize

In the life of a Java developer every now and then you’ll have one of your apps run out of memory. While this is usually due to poor coding (not closing resources, or managing large files) it helps to know exactly what the defaults are for your system. I had just this need today so went out looking for an answer.

What I found that was the most helpful was this page, but for quick reference here’s how to do it on Windows…

c:\>java -XX:+PrintFlagsFinal -version | findstr /i "HeapSize PermSize ThreadStackSize"
 
    uintx InitialHeapSize                          := 266634176       {product}
    uintx MaxHeapSize                              := 4267704320      {product}
    uintx PermSize                                  = 21757952        {pd product}
    uintx MaxPermSize                               = 85983232        {pd product}
     intx ThreadStackSize                           = 0               {pd product}
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)

Note that the values returned are in bytes so throw them into google to convert them into something useful 🙂

Please remember to subscribe to the newsletter or feed to stay up to date!

Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself.