Monday, May 27, 2019

Replacing non-ascii characters with their ascii equivalent or removing them

Let say you have this:

var name = "ÄBÖ";

and you want to convert it to

name = "ABO";

The following snippet will do it in Java. IT also will remove the characters that don't have any alternative in ASCII characters such as ß.

String subjectString = "öäü";
subjectString = Normalizer.normalize(subjectString, Normalizer.Form.NFD);
String resultString = subjectString.replaceAll("[^\\x00-\\x7F]", "");

Thursday, April 13, 2017

JavaScript is evolving into a true Object Oriented Language

New OOP features of JavaScript

Working Sample

class Human {
  constructor(name, gender) {
    this.name = name;
    this.gender = gender;
  }
 
  static getGenderFemale() {
    return "female";
  }
 
  static getGenderMale() {
    return "male";
  }
}

class MaleHuman extends Human {
  constructor(name) {
    super(name, Human.getGenderMale());
  }
}

class FemaleHuman extends Human {
  constructor(name) {
    super(name, Human.getGenderFemale());
  }
}

var jack = new Human("Jack", Human.getGenderMale());
console.log(jack);

var peter = new MaleHuman("Peter");
console.log(peter);

var sarah = new FemaleHuman("Sarah");
console.log(sarah);

Friday, May 10, 2013

MySQL Ring Replication Configurations

my.cnf / my.ini



[mysqld]
server-id = 1
replicate-same-server-id = 0
auto-increment-increment = 10
auto-increment-offset = 1
log-bin = mysql-bin
log-slave-updates


SQL

ON MASTER

FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;
UNLOCK TABLES;

ON SLAVE

CHANGE MASTER TO
    MASTER_HOST='master_host_name',
    MASTER_USER='replication_user_name',
    MASTER_PASSWORD='replication_password',
    MASTER_LOG_FILE='recorded_log_file_name',
    MASTER_LOG_POS=recorded_log_position,
    MASTER_CONNECT_RETRY=10;

Friday, March 22, 2013

MyPasswords 2.94

MyPasswords 2.94 released.

This version new feature: Customization of icons for tags in tree view.
Simple put a png icon with the same name of any tag in the icon folder to have it in the tree view.


Download here: http://www.mypasswords7.com

Friday, December 28, 2012

Make VIM More Coder Friendly

Add these to ~/.vimrc

set tabstop=2
set shiftwidth=2
set expandtab
set autoindent
set number

Friday, November 23, 2012

Numeric Password Dictionary File

Today I wondered how big will be a dictionary file containing all numeric passwords of 8-digit numbers (with padding zeros).

So I created one using a simple Java program and amazingly it is a 900mb file.

You can download it here: http://goo.gl/yRmz6


Sunday, July 22, 2012