JavaScript Code Smells by Elijah Manor

4 07 2015

HTML & CSS: Row with image and scrollable text having height adjusted to the image size

11 04 2015

I will show how, using CSS only, to set the height of the text in a row so it never exceeds the height of the image, and then if the long text exceeds the height, make it scroll. The image dimensions may vary and are not known at the implementation phase.

The goal

The thing I need to do is:

Row with height adjusted to the height of the image, with scrollable text

Row with height adjusted to the height of the image, with scrollable text

The solution

Please take a look here:

I wrapped the whole row in a table-row. The image and the text are the table-cells in it. The text’s table-cell has inline-block div with text inside. You can test it by manipulating the .image class size. Then the text field height will adjust. Here is the code:


<div class="container">
    <div id='first' class='img-div'>
        <img class="image" src=''/>

    <div class="outer-text">
        <div id='second' class='text-div'>Put a long text here...


    display: table-row;

.img-div {
    display: table-cell;
    float: left;

    display: table-cell;

    height: 100%;
    width: 190px;

    display: inline-block;

    height: 100%;

    overflow-y: auto;

To test it for custom various image sizes change the height of the image:

    height: 190px;

JSLint and JSHint helps to avoid terrible mistakes in JavaScript code

21 02 2015

Smashing Magazine and JavaScript Weekly are reminding all JavaScript coders that there are tools to validate the code: JSLint and JSHint. Those who are accustomed to compiled languages will find it helpful. But not only those…

Read Article at:

Tomcat – Java.Lang.OutOfMemoryError: PermGen Space

1 02 2015

If you see this, it means that your Tomcat server has not enough memory assigned for its Java Virtual Machine.

In a default configuration Tomcat even does not declare to require much momory. on my Windows 7 64-bit machine it was 86 Mb.

Using tips below you can adjust available memory as you need.

How to fix it [Linux]

To give Tomcat more memory navigate to ${tomcat-folder}\bin and create the file with params:

export JAVA_OPTS="-Dfile.encoding=UTF-8 -Xms128m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=1024m"

and restart Tomcat. setenv file will be automatically included in Tomcat startup script.

How to fix it [Windows]

To give Tomcat more memory navigate to ${tomcat-folder}\bin and create the setenv.bat file with params:

set JAVA_OPTS=-Dfile.encoding=UTF-8 -Xms128m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=1024m

and restart Tomcat. setenv file will be automatically included in Tomcat startup script.

Do JavaScript the right way

4 01 2015

Here are some great resources about JavaScript code style, best practices and tips and tricks. Worth to get familiar with them:

Configure SSL/HTTPS on Tomcat with Self-Signed Certificate

16 11 2014

Regarding security, the https with SSL is a minimum requirement. Moreover it has relatively low cost in implementation. Thanks to it your transport layer will be encrypted, preventing sniffing and main in the middle attack. Thanks to it your server validity will be verified with a certificate (In this tutorial I will use self-signed certificate. If you need trusted certificate, follow the trust agency instructions).

1. Generate keystore with self-signed certificate in it

You can generate keystore with java’s keytool. Open the windows command line or shell and check if you have keytool command in your path. If command is not recognized, find keytool app in your %java_home%\bin directory.

Execute this command:

keytool -genkey -alias keyAlias -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore myKeystore.p12 -validity 3650

The keytool will generate key (-genkey) with alias (-alias), PKCS12 storetype (-storetype), RSA algorthm 2048 bytes long stored under myKeystore.p12 file with validity equal to 3650 days (10 years).

Executing this command will ask you few identity questions:

Enter keystore password: keyPwd
Re-enter new password: keyPwd
What is your first and last name?
What is the name of your organizational unit?
  [Unknown]:  LooksOK!
What is the name of your organization?
  [Unknown]:  LooksOK!
What is the name of your City or Locality?
  [Unknown]:  Minsk Mazowiecki
What is the name of your State or Province?
  [Unknown]:  mazowieckie
What is the two-letter country code for this unit?
  [Unknown]:  PL
Is CN=, OU=LooksOK!, O=LooksOK!, L=Minsk Mazowiecki, ST=mazowieckie, C=PL correct?
  [no]:  yes

2. Check keystore contents – find your certificate in there

Issue list command to ensure that keystore contains certificate:

keytool -list -keystore keystore.p12 -storetype PKCS12

This is the output:

Keystore type: PKCS12
Keystore provider: SunJSSE

Your keystore contains 1 entry

keyalias, 2014-11-14, PrivateKeyEntry,
Certificate fingerprint (SHA1): 5A:3C:63:EC:CD:A9:AE:AA:D1:92:B3:3A:68:5A:95:C2:98:E3:69:01

So, the certificate is truly there!

3. Copy your keystore file to Tomcat dir

You can put your keystore file whenever you want, providing you will enter the path in tomcat config. I encourage you to put it under %Tomcat_home%/conf/myKeystore.p12.

4. Configure Tomcat

Tomcat configuration file is located in %Tomcat_home%/conf/server.xml. Find this section:

<!-- Define a SSL HTTP/1.1 Connector on port 8443
   This connector uses the BIO implementation that requires the JSSE
   style configuration. When using the APR/native implementation, the
   OpenSSL style configuration is required as described in the APR/native
   documentation -->

And uncomment the configuration below it. I will use the default 443 port (not the suggested 8443) and add four green lines specific to myKeystore:

<Connector port="443" protocol="org.apache.coyote.http11.Http11Protocol"
  maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
  clientAuth="false" sslProtocol="TLS" 

5. Test it

Start Tomcat and go to the:


Your browser will probably warn you about the untrusted certificate:


6. Verify the CN (Common Name)

The Common Name is the url I provided when creating keytool: If this particular address is used in a browser, the browser will not warn you. If you’ll open the


instead, the browser will warn you also that the url entered does not match the url provided on certificate creation.

Note: Don’t use Self_signed certificates in production! Use it only in test / dev environment

Did I help you?
I manage this blog and share my knowledge for free, sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!

Scalable and modular CSS

18 10 2014

CSS can be a mess. It needs to have standards and rules to avoid a mess. Here is a good speech with recomendations to follow:

Remember also about the css standards developed during the years of practice in wordpress. I mentioned them here:

Web development done well: WordPress web coding standards

11 10 2014

We all know that mess that grows in CSS, JavaScript and HTML files. There is no compilers as in static typed programming languages that will keep you from doing that mess bu there are Clean Code standards.

The team working on files should keep common standard and follow best practices. It is a failure if each team member has his own preferences and style and writes his parts with his own conventions. WordPress recommendation is:

"All code in any code-base should look like a single person typed it, no matter how many people contributed." – Principles of Writing Consistent, Idiomatic JavaScript

WordPress has its standards. Due to its opensource nature these are vital to keep an order in their web templates and sources. I follow most of their recommendations:

%d bloggers like this: