Sunday, November 24, 2013

Extracting images from PDF and removing whitespace.

Two tools you need
  1. ImageMagick (convert) - http://www.imagemagick.org/script/binary-releases.php
  2. pdfimages - http://en.wikipedia.org/wiki/Pdfimages
Here the order:
  570  pdfimages ../../20120101.pdf 20120101
  571  convert *.ppm -fuzz 7% -trim ../20120101-%d.jpg

Tuesday, November 19, 2013

WLSTException: Error occured while performing save : Cannot call Edit functions when you are not in the Edit tree

I'm getting the following message for my weblogic script .... what to do next?
Create mbean Properties with name user
INFO: Saving domain
Problem invoking WLST - Traceback (innermost last):
File "/installables/met10.3/met/wdm/1_02/bin/configure_domain_9.py", line 81, in ?
File "", line 405, in save
File "", line 1744, in raiseWLSTException
WLSTException: Error occured while performing save : Cannot call Edit functions when you are not in the Edit tree.
Try wrapping your work in a session like this....
edit()
startEdit(-1,-1,'false')
..
...
..
save()
activate()

Thursday, October 24, 2013

Getting Wordpress Content without Theme and Raw Data only

I have this knowledge base stashed away in blog format on a wordpress site. I would like to use the contents in a support page external to this site using EXTJS. How do I get the Wordpress Content without Theme but just the content. You would think its easy however .... so here the end result. Plop this in the root directory of the wordpress installation (where the wp-config.php resides).
<?php
# load the wp system
require ('wp-config.php');
# create the original request from the client
$url = 'http://'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
# extract the post id
$page_id = url_to_postid($url);
echo '';
# fetch post and echo it to the outputstream.
$page_data = get_post($page_id);
echo $page_data->post_content;
?>
NOTE: make sure this new file content.php has permissions 744 chmodded otherwise it won't execute So now you can do the following:
  • For formatted output: http://mywordpress.org/?p=2049
  • For unformatted output: http://mywordpress.org/content.php?p=2049

Wednesday, July 24, 2013

Querying Oracle OID LDAP for the real serivce name and TNS details for JDBC

I have a wonderful cloud instance and a database, however on different segments and somehow dear firewall does not allow me to connect...
jdbc:oracle:thin:@ldap://oidprd.gss.mycompany.com:389/fxgdev65,cn=OracleContext,dc=mycompany,dc=com
At the boot of the weblogic server it sends a warning that the targeted jdbc pool cannot create a connection...
     
How to get the TNS name? Ever heard of curl.... thats the way to go (of course you would need openldap libraries loaded... which on my Mac OSX is the case)
$ curl -0 ldap://oidprd.gss.mycompany.com:389/cn=fxgdev65,cn=OracleContext,dc=mycompany,dc=com
DN: cn=fxgdev65,cn=OracleContext,dc=mycompany,dc=com
 objectclass: orclNetService
 objectclass: top

 orclnetdescstring: (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=fxgdev65.mycompany.com)(PORT=1527)))(CONNECT_DATA=(SERVICE_NAME=FXGDEV65.MYCOMPANY.COM)(SRVR=DEDICATED)))

 cn: fxgdev65
NOTE: you cannot just use the URI definition of the JDBC url, you need to add the cn= before the service you want to lookup So there you go ... now lets put that after the 'at' sign...
jdbc:oracle:thin://(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=fxgdev65.mycom.com)(PORT=1527)))(CONNECT_DATA=(SERVICE_NAME=FXGDEV65.MYCOMPANY.COM)(SRVR=DEDICATED)))

Saturday, July 13, 2013

WebLogic Password Encryption / Recovery

Put this in the startup in the JAVA_OPTIONS
-Dweblogic.system.RemoveBootIdentity=true -Dweblogic.management.username=weblogic -Dweblogic.management.password=weblogic -Dweblogic.system.StoreBootIdentity=false
$ java -cp /opt/weblogic/wl10.3.2/wlserver_10.3/server/lib/weblogic.jar -Dweblogic.RootDirectory=/opt/my/domain/here -Dweblogic.management.allowPasswordEcho=true weblogic.security.Encrypt Password: MY_PASSWORD

Wednesday, July 3, 2013

Wiring a combo box populating two fields by means of events.

We have a 'citycombo' with store attached that has a record with the name and the state where the city resides. For example: name : 'Springfield', state : 'MA'. The selection of Springfield, MA from the city combo will populate the state field (which is freeform). How to wire the events. Flow; catch the select event, lookup the state field by means of its id 'stateId' and set the value of the field found....
   }, {
     'xtype' : 'citycombo',
     'name' : 'city',
     'fieldLabel' : 'city',
     listeners : {
      "select" : function(k, rs) {
       console.log("%o %o", k, rs);
       if (rs.length) {
        me.getComponent('iState').setValue(rs[0].get('state'));
       }
      }

     },

   }, {
     'xtype' : 'textfield',
     'id' : 'iState',
     'name' : 'state',
     'fieldLabel' : 'state',

   },

Monday, July 1, 2013

Grid - Form and Filtering in ExtJS4 and record release.

Components we have ... [1] one grid - with table of query results [2] one form - for details when row is selected in the grid [3] one check - box The check box 'Incl' will apply a filter based on the checked value. If you selected a record and show it in the form there will be an error occuring on the handler when using the filtering on the store like this.
   }, {
     xtype : 'checkbox',
     boxLabel : 'Incl. Archive',
     handler :  function(_old, _new) {
       var filter = {};
       var _store_ = Ext.getStore('GridStore');
       // release any loaded record bound to form.
       if (!_new) {
        filter = { property : 'my_field', value : { '!=' : 'ARC'}};
        _store_.filter(filter);
       }
       else {
        _store_.clearFilter();
       }
     }
TypeError: record is undefined
createRelayer()ext-all-debug.js (line 11282)
fire()ext-all-debug.js (line 9677)
continueFireEvent(eventName="selectionchange", args=[Object { events={...}, views=[1], modes={...}, more...}, []], bubbles=undefined)ext-all-debug.js (line 11035)
fireEventArgs(eventName="selectionchange", args=[Object { events={...}, views=[1], modes={...}, more...}, []])ext-all-debug.js (line 11013)
fireEvent(eventName="selectionchange")ext-all-debug.js (line 10999)
maybeFireSelectionChange(fireEvent=true)ext-all-debug.js (line 92334)
doDeselect(records=[Object { raw={...}, modified={...}, data={...}, more...}], suppressEvent=undefined)ext-all-debug.js (line 92269)
deselect(records=Object { raw={...}, modified={...}, data={...}, more...}, suppressEvent=undefined)ext-all-debug.js (line 92155)
handler(_old=Object { xtype="checkbox", boxLabel="Incl. Archive", initialConfig={...}, more...}, 
The reason is that the form will "hold" the record that was selected in the grid. To solve this we need to deselect the record, but that's not all. We also need to prevent the 'selectionchange' event from occurring, hence suspending the events on the selection model would also need to be applied. The new handler code for the checkbox is:
     handler :  function(_old, _new) {
       var filter = {};
       var _store_ = Ext.getStore('TerritoryAddressStore');
       // release any loaded record bound to form.
       grid.getSelectionModel().suspendEvents();
       grid.getSelectionModel().deselect(form.getRecord());
       if (!_new) {
        filter = { property : 'my_field', value : { '!=' : 'ARC'}};
        _store_.filter(filter);
       }
       else {
        _store_.clearFilter();
       }
       grid.getSelectionModel().resumeEvents();
      
     }