Thursday, April 23, 2015

Linkedin Status Update Image not displayed

I was facing this problem when I was updating images from my site on linkedin. I even asked a question on stackoverflow (When using linkedin share api submitted-picture-url or sharing url via linkedin, particular url format doesnot work?) but never got a good response.

After that I did lots of experimentation to figure out few things about linkedin in status update image url. I would list them out below:


  1. Max size for image should be 100 MB (read somewhere, have not tried it myself.)
  2. Linkedin caches the images on its server for 7 days. So if the image on the url shared have changed, linkedin won't update it. A good workaround is to add a query parameter to the image url with some random string of the timestamp while sharing. So, this would make each image url unique.
  3. Set the correct mime-type on the servlet serving the image. I was using cdn and with my servlet acting at a proxy to cdn to serve the image. In the process I was missing out the mime-type in the response header. What this lead to was that linkedin was never displaying those images. So ideally linkedin caching mechanism makes a requests to the image url, reads the response header, if the header has a mime-type of image then downloads it and caches it other wise ignores it. So always set the correct mime-type.
  4. Obviously the image url should be reachable from open internet.
  5. Image should atleast be 80px by 150x to prevent it to be stretched.
I hope this list helps someone. Have a good day! Happy sharing!

Thursday, April 16, 2015

Email Validation Jquery Plugin.

Recently I wrote a jquery plugin which would allow you to validate an email address for:

  • Syntax checks (RFC defined grammar) 
  •  DNS validation
  • Spell checks 
  • Email Service Provider (ESP) specific local-part grammar (if available)
  •  MX Validation.
  • Free Email Service Check
  • Disposable Email Service check.
  • Sanatize email id based on service provider.
In future, I am planning to incorpoprate:
  • Corporate Company details.
If you have any suggestion then you can comment. 
You can download the plugin here.
Try a demo here.

Some screenshots of the demo are:






Monday, April 6, 2015

How to set Tomcat 7 source level to Java 7? Avoid "Resource specification not allowed here for source level below 1.7" error

I have been facing problem where whenever I was accessing jsp page which were using some Java 7 specific features, the compilation of such JSP pages use to fail with following error:

Resource specification not allowed here for source level below 1.7

To fix this I googled for hours and set up the JDK home correctly on my catalina.sh with env.sh to point to jdk7. But this never solved my problem.

Finally today I hit the gold while reading the apache tomcat jasper documentation. The JSP compiler had to be set to use 1.7 as target and source version.

To do this we need to add two extra init-params in the conf/web.xml file in the tomcat home.
 The JSP servlet configuration should have

     <servlet>
        <servlet-name>jsp</servlet-name>
        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
        <init-param>
            <param-name>fork</param-name>
            <param-value>false</param-value>
        </init-param>
        <init-param>
            <param-name>xpoweredBy</param-name>
            <param-value>false</param-value>
        </init-param>
          <init-param>
            <param-name>compilerSourceVM</param-name>
            <param-value>1.7</param-value>
        </init-param>
        <init-param>
            <param-name>compilerTargetVM</param-name>
            <param-value>1.7</param-value>
        </init-param>
        <load-on-startup>3</load-on-startup>
    </servlet>

Restart the server and boom it works.

NPM Install Failing with EROFS in npm-debug.log on VirtualBox shared Drive [Updated for ETXTBSY]

I have a set up where I use my IDE on my host system and build my code on an Ubuntu server and deploy there.

To achieve this I have used virtual box to install and run Ubuntu as a guest system. My host system is Windows.  I have shared a drive across to the guest. Every time my ubuntu comes up, I mount the drive using the command:

sudo mount -t vboxsf SHARE_NAME folder_to_mount_on

Things were working fine, with my Java server development. Now I decided to move my js and node environment to the same set up and BOOM! it failed.

Only hint was EROFS error on the npm-debug.log. Some googling and I find out that VirtualBox has a bug and it does not support sysmlink and since ubuntu by default support symlink creation, npm was failing at the time of creation of sysmlink.

My initial solution was to write a build script which rsynced my working directory to a level above and run the build command there. I worked but was slow and hacky.

Then I found out that we can switch on symlink on VirtaulBox and windows: To do so:

VBoxManage setextradata YOURVMNAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/YOURSHAREFOLDERNAME 1

Verify by running:

VBoxManage getextradata YOURVMNAME enumerate

Restart VirualBox and run it as administrator, and things starts working :)

UPDATE:
Another new error I cam across in the similar environment was stack: 'Error: ETXTBSY, 
for this I have to end up adding  --no-bin-links so that no soft links are created.