Monthly Archives: December 2012

Replace Repeating NonAlphaNumeric symblos in Regex

To replace all symbols except numbers and letters use next:

final String REPLACE_PATTERN = "([^\\w\\d]){1,}";
final String VALUE_SEPARATOR = ",";

String input = "Hello18,,,, do44som; com77*@% and so 0n!...";
String result = input.replaceAll(REPLACE_PATTERN, VALUE_SEPARATOR);

WordPress upload add another file extensions

Just add the following code to you functions.php in theme:

add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes=array() ) {
  // add
  $existing_mimes['xpi'] = 'application/x-xpi';
  $existing_mimes['zip'] = 'application/x-zip';
  $existing_mimes['bat'] = 'application/x-bat';

  // remove
  unset( $existing_mimes['exe'] );

  return $existing_mimes;

Thanx to

Input text readonly attribute in JSF

JSF rocks!
If you want to use readonly property in h:inputText, using readonly=”true” attribute brings you in confusing, because value of this element is unrestorable after request will performed.

Javascript way works in Firefox only! Skip it, here just for ex.

 * Add readonly attribute to element
function addReadonly(obj){
	$(obj).attr('readonly', 'readonly');
	return false;

 * Remove readonly attribute to element
function removeReadonly(obj){
	return false;

// in element, add attrs
onkeydown="addReadonly(this);" onkeyup="removeReadonly(this);"

And to help us, use next JSF workaround.
Add property to bean:

     * Need for readonly properties processing
* Allows to restore value of input. */ public boolean isReadonly() { return FacesContext.getCurrentInstance().getRenderResponse(); }

In page add readonly attr:


Thanx to

Firefox new tab focus fix

After some update, like 17…etc, i’ve really discouraged cause by FF focus on address bar when new tab is opening. To fix issue in stall next add-on.


Thanx to