Thursday, March 14, 2019

Useful GIT Commands

Git is a distributed version-control system for tracking changes in source code during software development. 
# delete local tag 'v2.0.1'
git tag -d v2.0.1

# delete remote tag 'v2.0.1' (eg, GitHub version too)
git push origin :refs/tags/v2.0.1

# alternative approach
git push --delete origin v2.0.1
git tag -d v2.0.1

Wednesday, March 6, 2019

"Invalid type String, expected Array for value" in RAML file in Anypoint Studio

While i was following the MuleSoft Developer Fundamental course I encoutered the "Invalid type String, expected Array for value" error during the import of RAML file from  Anypoint Platform to Anypoint Studio to generate API Flows. Due to this error I was not able to generate the API flow in Anypoint Studio.

This is due to some error in RAML file which was not flagged in the Anypoint Platform API Designer. Below is the fix that i used to make it work.


In your RAML, replace all usage of:
  1. examples: !include examples//AmericanFlightExample.raml
With this:
  1. examples:
  2. output: !include examples/AmericanFlightExample.raml

Reference:

Sunday, January 27, 2019

Migrate SVN repository to GIT

These are the steps that i followed during the SVN migration to GITHUB repository. svn2git is the utility that i used for this migration.


Prerequisites


 1. You should have git, git-svn and ruby installed. To verify execute below command

sudo apt-get install git-core git-svn ruby
  
2. Install svn2git using following command.

sudo gem install svn2git

Usage:
  • Checkout your svn repository to your local machine by executing below command. 
svn checkout 'repoName' --username 'userName'

  • Execute below command to extract the list of sub version committers. 
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt

  •  Run svn2-git utility (Pass the authors-transform.txt file)
svn2git 'repositoryName' --username 'username' --authors authors-transform.txt

 Note:  If the svn repository is a standard layout of (trunk, branches, tags) at the root level. So doesn't require any addional parameters while using svn2git command.  
  • Once the above command completes you shoud get a local git repository similar to your svn repository. 
  • Add remote origin using below command. 
git remote add origin git@github.com:Company/RepoName.git
  • Push master, all the other branches.
git push origin master
git push origin --all
  • Push Tags to remote git repository by execuing following command. 
git push origin --tags

Sunday, February 18, 2018

Use of contain non-ASCII characters like à, è, ù in an IIS URL

Allow High Bit Characters in IIS

This feature either allows or rejects all requests to IIS that contain non-ASCII characters. The UrlScan equivalent is AllowHighBitCharacters.
There are two approaches to achieve this 
Suppose you want to allow high bit characters for entire server. Then follow below steps: 
1. Click on Request filtering 
2. Then go to Edit feature settings 
3. Tick the allow high-bit characters 
Suppose you want to allow high bit characters for one application but not for the entire server.
Set the allowHighBitCharacters="false" in the ApplicationHost.config file; but within the application root, create a Web.config file that allows that single application to accept non-ASCII characters. In the Web.config file, use:
<configuration> <system.webServer> <security> <requestFiltering allowHighBitCharacters="true" > </requestFiltering> </security> </system.webServer> </configuration>

Thursday, March 17, 2016

Converting Timezone-Specific Times in MySQL

Use below MySQL function to convert one timezone to another timezone.

Ex:

SELECT CONVERT_TZ(now(),'UTC','Europe/paris') as d;

SELECT CONVERT_TZ(now(),''US/Eastern','US/Central') as d;

Wednesday, March 9, 2016

LOAD DATA INFILE Error Code : 13 - When using mysqlimport command in ubuntu

mysqlimport: Error: 29, File '/CSVFile' not found (Errcode: 13 - Permission denied), when using table: TableName


  • This error occurs due to the permission issue. 
  • I used following steps to resolve this issue. 

1. Execute sudo aa-status command to check MySQL's profile is in enforcing mode.Because in recent Ubuntu server editions ship with AppArmor and MySQL's profile might be in enforcing mode by default.
What is AppArmor?
("Application Armor") is a Linux kernel security module that allows the system administrator to restrict programs's capabilities with per-program profiles. Profiles can allow capabilities like network access, raw socket access, and the permission to read, write, or execute files on matching paths.
# sudo aa-status
5 profiles are loaded.
5 profiles are in enforce mode.
   /usr/lib/connman/scripts/dhclient-script
   /sbin/dhclient3
   /usr/sbin/tcpdump
   /usr/lib/NetworkManager/nm-dhcp-client.action
   /usr/sbin/mysqld
0 profiles are in complain mode.
1 processes have profiles defined.
1 processes are in enforce mode :
   /usr/sbin/mysqld (1089)
0 processes are in complain mode.
If mysqld is included in enforce mode, then it is the one probably denying the write. Entries would also be written in /var/log/messages when AppArmor blocks the writes/accesses. What you can do is edit /etc/apparmor.d/usr.sbin.mysqld and add /data/ and /data/* near the bottom like so:
I have added  /home/charith/* r,   entry in to the file. Upload the csv file to the /home/charith/ directory and 
...
/usr/sbin/mysqld {
    ...
    /var/log/mysql/ r,
    /var/log/mysql/* rw,
    /var/run/mysqld/mysqld.pid w,
    /var/run/mysqld/mysqld.sock w,
    /data/ r,
    /data/* rw,
 /home/charith/* r,  
}
And then make AppArmor reload the profiles.
# sudo /etc/init.d/apparmor reload
WARNING: the change above will allow MySQL to read and write to the /data directory. We hope you've already considered the security implications of this.

Import CSV File Into MySQL Table in Ubuntu server

These are the steps that i followed to import a CSV data file to MySQL database


  • Create a table in MySQL database. CSV file name should be equivalent to the table name that you are going to import.  
EX: Table name is : PS_EMPLIDS
  • Execute following command  

Command to import csv file to MySQL :
mysqlimport --user=mysqlUsername --password=mysqlPassword --ignore-lines=1 databaseName ~/PS_EMPLIDS.csv


References:
http://dev.mysql.com/doc/refman/5.6/en/mysqlimport.html

Wednesday, January 27, 2016

Solution for [RuntimeException] The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly - AWS Elastic beanstalk

Recently we got this error while we deploying our PHP Symfony2 application to AWS via elastic beanstalk environment.

Root cause for this issue

  • Composer have made a change in which they have deprecated COMPOSER_HOME
Solution 1:

The quick fix is to COMPOSER_HOME to HOME.

commands:
  01_update_composer:
    command: export HOME=/root && /usr/bin/composer.phar self-update

option_settings:
  - namespace: aws:elasticbeanstalk:application:environment
    option_name: HOME
    value: /root


Solution 2: 

Another option on a new instance is to lock the composer version.

Here is an example ebextension:

commands:
  01_update_composer:
    command: export HOME=/root && export COMPOSER_HOME=/root && /usr/bin/composer.phar self-update 1.0.0-alpha11

option_settings:
  - namespace: aws:elasticbeanstalk:application:environment
    option_name: COMPOSER_HOME
    value: /root
  - namespace: aws:elasticbeanstalk:application:environment
    option_name: HOME
    value: /root