Search This Blog

Friday, July 4, 2014

Solve Line encoding(unix/windows) problems in Git branches through Eclipse

There are some possibilities when people work on the same Git hub project in unix and windows. During this time most of us face the problem with Line encoding, Even though there are no changes to the branch, we will observe the entire file has been changed. This is so cumbersome to look at each and individual file and check what actual content is modified.

There are 2 fixes fir this;
  • Fix the IDE settings for file encoding and line delimiters
  • Configure Git to automatically do the conversion for you

Tuesday, June 10, 2014

Increase conversion time for xtext parsing - Time out error

When dealing with complex Xtext, some times you end up with the below error.
error(10): internal error: org.antlr.tool.Grammar.createLookaheadDFA(Grammar.java:864): could not even do k=1 for decision 135
Increasing the amount of memory available to the JVM is the first thing you will have to do when dealing with complex grammars. That however doesn't help in this case. That's because this error is due to a timeout inside the ANTLR generator (which converts xtext to antlr) which by default kicks in after 1000ms. After that ANTLR gives up on creating a DFA for your grammar and you may end up with the error message above.

Monday, June 2, 2014

Auto Merging of Git Branches through Jenkins

Two Git branches can be merged and pushed to remote as a part of the build process. This is possible with Jenkins Git plugin with just 2-3 steps configuration. Lets see that in detail.

  • Create/configure a job in Jenkins
  • In Source code management configure the git repository and the integration branch.
    • While merging Test4 branch into Test3 branch; integration branch is Test4 and the Branch to merge to is Test3

Thursday, May 29, 2014

Replace characters Using ANT

There is an inbuilt task given in ant library called 'replaceregexp'. This task is used to check about a specific pattern i.e. a regular expression and replace them with a different pattern in a single file or set of files.

Replace in a set of files

<replaceregexp match="test" replace="replacedTest" flags="gm" byline="false">
            <fileset dir="${sf.srcdir}" includes="*.txt" />
</replaceregexp>
The above task will look at all the files ending with extension 'txt' in the source directory given as 'sf.srcdir' in the properties file. In all those files, it tries to find the pattern 'test' and replaces with pattern 'replacedTest'

Fail an ANT build if a property is not set

Any number of properties can be used in ANT build.xml. They can be environment variables or variables set in a properties file.

There is an ability to check if required properties are set or not i.e. included or not in the properties file. Also we can match them to a regular expression to see of they are empty or matching as per the requirement. If they do not match the requirement, the build can be made to fail. There is a fail task provided by the ant library to fail the build. Add this as first task before adding any cutom tasks.

Including Properties File

You can include a properties file or environmental variables in build.xml in the below way
    <property file="build.properties"/>
    <property environment="env"/>


Tuesday, May 13, 2014

Copy files from Local to remote using ssh

In order to copy files from local to a remote system using ssh, there should be an  authorized user with a pem file. And also for that particular user in the remote system, there should be proper permissions for the destination.

Remote System

  • Login to the remote server using putty or through powershell.
  • Navigate to the destination folder
            > cd <destination>
  • Change the permissions using the below command
            > chmod -R 777 *

Monday, May 12, 2014

How to Restart Jenkins


  • Login to the Jenkins server using powershell or Putty
  • In order to check of the jenkins process is running or not; execute the below command; This will give you the process Id if it is running.
                        > ps -ef | grep jenkins
  • Jenkins service can be started/stopped/restarted only as a root user. So change to the root user and do the action as below
                        > sudo su
                        > sudo service jenkins start
  • If the service is not detected using this script; do the following
                       > /etc/init.d/jenkins start
  • The above command will start your jenkins server. Now open the Jenkins web page in browser and check for the status.


Thursday, May 8, 2014

Login through putty using pem file

Putty needs a private key to make an ssh call. Puttygen is used to generate the private key from the pem file.

PuttyGen is a key generation tool. This is an RSA and DSA key generation utility. This can be used to create new private keys or convert pem files to ppk(private keys).

To convert pem to ppk

  • Install Puttygen from Putty Download and run the exe.
  • Then select the type of key to be generated

Wednesday, May 7, 2014

VisualForce - Make Remote Action Call from Static Resource

Remote Action in Visual Force gives us the ability to make a call asynchronously to the salesforce controller and handle the response in a callback function without making the complete page refresh or waiting for an action. Basically in terms of HTML, this can be treated as an ajax call made through the script tags.

Controller

Lets check the controller now and assume that the namespace of the package is 'namespace'.
  1. global class ControllerName {
  2.    @RemoteAction
  3.     global static String MethodName(Paramters....)
  4.     {
  5.         return 'Hello';
  6.     }
  7. }
All the remote actions are annotated and static.

Tuesday, January 14, 2014

HTTP URL Validity Check in Nodejs

Http URL Validity can be checked in 2 ways.
  • Using a regular expression to check if the pattern matches
  • Ping to that URL and see if there is a response or not i.e. if it exists or not.
Some times, the pattern matches but the the required URL may be or may not be existing. In order to check this in NodeJs, 'request' module can be used. Both the steps can be done in a single call.