Friday, January 10, 2014

ExtJs: more vtypes for validation .... vtype on a roll..

Ext.form.VTypes["hostnameVal1"] = /^[a-zA-Z][-.a-zA-Z0-9]{0,254}$/;
Ext.form.VTypes["hostnameVal2"] = /^[a-zA-Z]([-a-zA-Z0-9]{0,61}[a-zA-Z0-9]){0,1}([.][a-zA-Z]([-a-zA-Z0-9]{0,61}[a-zA-Z0-9]){0,1}){0,}$/;
Ext.form.VTypes["ipVal"] = /^([1-9][0-9]{0,1}|1[013-9][0-9]|12[0-689]|2[01][0-9]|22[0-3])([.]([1-9]{0,1}[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){2}[.]([1-9][0-9]{0,1}|1[0-9]{2}|2[0-4][0-9]|25[0-4])$/;
Ext.form.VTypes["netmaskVal"] = /^(128|192|224|24[08]|25[245].0.0.0)|(255.(0|128|192|224|24[08]|25[245]).0.0)|(255.255.(0|128|192|224|24[08]|25[245]).0)|(255.255.255.(0|128|192|224|24[08]|252))$/;
Ext.form.VTypes["portVal"] = /^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$/;
Ext.form.VTypes["multicastVal"] = /^((22[5-9]|23[0-9])([.](0|[1-9][0-9]{0,1}|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3})|(224[.]([1-9][0-9]{0,1}|1[0-9]{2}|2[0-4][0-9]|25[0-5])([.](0|[1-9][0-9]{0,1}|1[0-9]{2}|2[0-4][0-9]|25[0-5])){2})|(224[.]0[.]([1-9][0-9]{0,1}|1[0-9]{2}|2[0-4][0-9]|25[0-5])([.](0|[1-9][0-9]{0,1}|1[0-9]{2}|2[0-4][0-9]|25[0-5])))$/;
Ext.form.VTypes["usernameVal"] = /^[a-zA-Z][-_.a-zA-Z0-9]{0,30}$/;
Ext.form.VTypes["passwordVal1"] = /^.{6,31}$/;
Ext.form.VTypes["passwordVal2"] = /[^a-zA-Z].*[^a-zA-Z]/;


Ext.form.VTypes["hostname"]=function(v){
 if(!Ext.form.VTypes["hostnameVal1"].test(v)){
  Ext.form.VTypes["hostnameText"]="Must begin with a letter and not exceed 255 characters"
  return false;
 }
 Ext.form.VTypes["hostnameText"]="L[.L][.L][.L][...] where L begins with a letter, ends with a letter or number, and does not exceed 63 characters";
 return Ext.form.VTypes["hostnameVal2"].test(v);
}
Ext.form.VTypes["hostnameText"]="Invalid Hostname"
Ext.form.VTypes["hostnameMask"]=/[-.a-zA-Z0-9]/;


Ext.form.VTypes["ip"]=function(v){
 return Ext.form.VTypes["ipVal"].test(v);
}
Ext.form.VTypes["ipText"]="1.0.0.1 - 223.255.255.254 excluding 127.x.x.x"
Ext.form.VTypes["ipMask"]=/[.0-9]/;


Ext.form.VTypes["netmask"]=function(v){
 return Ext.form.VTypes["netmaskVal"].test(v);
}
Ext.form.VTypes["netmaskText"]="128.0.0.0 - 255.255.255.252"
Ext.form.VTypes["netmaskMask"]=/[.0-9]/;


Ext.form.VTypes["port"]=function(v){
 return Ext.form.VTypes["portVal"].test(v);
}
Ext.form.VTypes["portText"]="0 - 65535"
Ext.form.VTypes["portMask"]=/[0-9]/;

Ext.form.VTypes["multicast"]=function(v){
 return Ext.form.VTypes["multicastVal"].test(v);
}
Ext.form.VTypes["multicastText"]="224.0.1.0 - 239.255.255.255"
Ext.form.VTypes["multicastMask"]=/[.0-9]/;
Ext.form.VTypes["username"]=function(v){
 return Ext.form.VTypes["usernameVal"].test(v);
}
Ext.form.VTypes["usernameText"]="Username must begin with a letter and cannot exceed 255 characters"
Ext.form.VTypes["usernameMask"]=/[-_.a-zA-Z0-9]/;
Ext.form.VTypes["password"]=function(v){
 if(!Ext.form.VTypes["passwordVal1"].test(v)){
  Ext.form.VTypes["passwordText"]="Password length must be 6 to 31 characters long";
  return false;
 }
 Ext.form.VTypes["passwordText"]="Password must include atleast 2 numbers or symbols";
 return Ext.form.VTypes["passwordVal2"].test(v);
}
Ext.form.VTypes["passwordText"]="Invalid Password"
Ext.form.VTypes["passwordMask"]=/./;

Monday, January 6, 2014

perl: Data::Dumper dyld: lazy symbol binding failed: Symbol not found: _isWORDCHAR Referenced from: /perl5/Library/Perl/Updates/5.12.3/darwin-thread-multi-2level/auto/Data/Dumper/Dumper.bundle Expected in: flat namespace dyld: Symbol not found: _isWORDCHAR

When installing Data::Dumper package 2.143 on MacOSX with perl 5.12.3 as runtime I received test results that were bad on the Dumper.xs tests. SO I forced the installation.... bad idea... got these errors on some of the Dumper calls when debugging DBIx result sets.
dyld: Symbol not found: _isWORDCHAR
  Referenced from: /Users/me/perl5/Library/Perl/Updates/5.12.3/darwin-thread-multi-2level/auto/Data/Dumper/Dumper.bundle
  Expected in: flat namespace
Solution: manually get out there on CPAN and get 2.145
$ cd .cpan/build
$ wget http://search.cpan.org/CPAN/authors/id/S/SM/SMUELLER/Data-Dumper-2.145.tar.gz
$ tar pfvx Data-Dumper-2.145.tar.gz
$ cd Data-Dumper-2.145
$ perl Makefile.PL
$ make && make test && make install
And it starts working ... here context of my Dumper calls that failed.... hope this helps anyone!
Can't set DBI::db=HASH(0x7f819f7c4108)->{HASH(0x7f819d3eab58)}: unrecognised attribute name or invalid value at /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/DBI.pm line 720.
Can't get DBI::db=HASH(0x7f819f7c4108)->{HASH(0x7f819d3eab58)}: unrecognised attribute name at /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/DBI.pm line 720.
SELECT me.server_os_type_map_seq, me.created_by_nm, me.created_dt, me.updated_by_nm, me.updated_dt, me.server_type_seq, me.os_version_seq FROM (
  SELECT me.server_os_type_map_seq, me.created_by_nm, me.created_dt, me.updated_by_nm, me.updated_dt, me.server_type_seq, me.os_version_seq  FROM PMI_SCHEMA.SERVER_OS_TYPE_MAP me 
) me WHERE ROWNUM <= ?
: '100'
SELECT me.os_version_seq, me.created_by_nm, me.created_dt, me.updated_by_nm, me.updated_dt, me.os_version_desc FROM PMI_SCHEMA.OS_VERSION me WHERE ( me.os_version_seq = ? ) : '32'
dyld: lazy symbol binding failed: Symbol not found: _isWORDCHAR
  Referenced from: /Users/me/perl5/Library/Perl/Updates/5.12.3/darwin-thread-multi-2level/auto/Data/Dumper/Dumper.bundle
  Expected in: flat namespace

dyld: Symbol not found: _isWORDCHAR
  Referenced from: /Users/me/perl5/Library/Perl/Updates/5.12.3/darwin-thread-multi-2level/auto/Data/Dumper/Dumper.bundle
  Expected in: flat namespace

Monday, December 2, 2013

EXTJS substring errors on loading widgets.... fast debug in Chrome

So I'm wasting a lot of time with ExtJS refactoring on typos on widgets or paths that are misspelled. See the typical errors at the end of this post... and yeah yeah
  1. 1) I should be more careful,
  2. 2) should buy a tool,
  3. 3) buy new glasses...
but honestly I would rather see a meaningful error on the Javascript so where do we put the break point (Chrome)

So in line ext-all-debug.js:5416 set a conditional breakpoint on that line for '!className'.

Uncaught TypeError: Cannot call method 'substring' of undefined ext-all-debug.js:5043
Ext.ClassManager.parseNamespace ext-all-debug.js:5043
Ext.ClassManager.get ext-all-debug.js:5151
Ext.ClassManager.instantiate ext-all-debug.js:5434
Ext.ClassManager.instantiateByAlias ext-all-debug.js:5416
Ext.apply.widget ext-all-debug.js:5701
Ext.define.create ext-all-debug.js:21751
Ext.define.lookupComponent ext-all-debug.js:37477
Ext.define.prepareItems ext-all-debug.js:37447
Ext.define.add ext-all-debug.js:37502
Ext.define.initItems ext-all-debug.js:37279
Base.implement.callParent ext-all-debug.js:4250
Ext.define.initItems ext-all-debug.js:50980
Ext.define.initComponent ext-all-debug.js:37262
Base.implement.callParent ext-all-debug.js:4250
Ext.define.initComponent ext-all-debug.js:50959
Base.implement.callParent ext-all-debug.js:4250
Ext.define.initComponent ext-all-debug.js:53582
Base.implement.callParent ext-all-debug.js:4250
Ext.define.initComponent ext-all-debug.js:126581
Ext.define.constructor ext-all-debug.js:29304
Base.implement.callParent ext-all-debug.js:4250
Ext.define.constructor ext-all-debug.js:33278
constructor ext-all-debug.js:4883
Ext.apply.widget ext-all-debug.js:5703
Ext.define.create ext-all-debug.js:21751
Ext.define.lookupComponent ext-all-debug.js:37477
Ext.define.prepareItems ext-all-debug.js:37447
Ext.define.add ext-all-debug.js:37502
Ext.define.initItems ext-all-debug.js:37279
Ext.define.initComponent ext-all-debug.js:37262
Base.implement.callParent ext-all-debug.js:4250
Ext.define.initComponent ext-all-debug.js:68865
Ext.define.constructor ext-all-debug.js:29304
Base.implement.callParent ext-all-debug.js:4250
Ext.define.constructor ext-all-debug.js:33278
constructor ext-all-debug.js:4883

Monday, November 25, 2013

KeyRemap4MacBook implement XWindows auto select with Mouse Gestures.

I love the Xwindows feature that you can auto copy selected text from a cursor selection. So this is the scenario, when I select a piece of text I would like it to be stored in the buffer/clipboard with control-C after I lift my mouse button. I don't need the paste function however could easily be implemented as well.
With KeyRemap4MacBook your can rearrange your input events. Here the snippet I use for the TERMINAL application to do just so:
  <item>
   <name>Autoselect Copy</name>
   <identifier>private.autoselect_copy</identifier>
   <only>TERMINAL</only>
   <autogen>
    __PointingButtonToKey__
    PointingButton::LEFT, ModifierFlag::NONE,
    KeyCode::VK_MODIFIER_EXTRA1,

    Option::KEYTOKEY_BEFORE_KEYDOWN,
    KeyCode::VK_MOUSEKEY_LOCK_BUTTON_LEFT,
    KeyCode::VK_LOCK_EXTRA2_FORCE_ON,
    <!-- VK_LOCK_EXTRA2 is necessary for Middle Button to Command+Tab (Switch 
     Applications) -->

    Option::KEYTOKEY_AFTER_KEYUP,
    KeyCode::VK_MOUSEKEY_LOCK_BUTTON_ALL_FORCE_OFF,
    KeyCode::C, ModifierFlag::COMMAND_L,
    KeyCode::VK_LOCK_EXTRA2_FORCE_OFF
   </autogen>
  </item>

After this I can paste the text... in this example my stickies.

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