Skip to main content

Posts

Showing posts from September, 2017

Access GitHub Repositories with SourceTree and 2FA (2 Factor Authentication)

Many developers and organizations use GitHub as code repository. Similarly, many prefer to commit code in GitHub repositories using various commands. I personally think that using any kind of user interface for committing code and performing various GIT operations is much more simpler and productive. SourceTree is one such Atlassian product. SourceTree is a free Git client and provides beautiful GUI that offers a visual representation for various Git repositories. For added security, you can enable 2FA (i.e. 2 Factor Authentication) for your GitHub account. Configuring GitHub with SourceTree is very very simple. Here are the steps on MAC OS (steps on Windows OS are similar): If you have not enabled 2FA: Open SourceTree and go to Preferences Select Accounts Click on Add button to add account On the pop-up window, select Host as "GitHub" Select Auth Type as "Basic" Type your GitHub username (not email) Type your password Select Protocol as HTTPS

Sublime Text 3 - Pertty Format JSON

You must be looking for some easy options to pretty format JSON data. Well, there are many websites which provides this capability and you can pretty format JSON data in browser. I use Sublime Text 3 text editor, and I was trying to see if I can pretty format JSON within the text editor itself. You can follow these simple steps: Open Sublime Text 3 text editor If you are using MAC OS Press Command + Shift + P Then select "Install Package" Search for "Pretty JSON" Install If you are using Windows OS Press CTRL + Shift + P Then select "Install Package" Search for "Pretty JSON" Install Once the installation is complete, select JSON string If you are using MAC OS Press Command + Control + J If you are using Windows OS Press CTRL + ALT + J Thats it! Now you don't have to copy your JSON string from Sublime Text 3, paste in your browser, format it, then copy formatted JSON from browser and paste it back in your Sublime

MAC OS - Set JAVA_HOME

While running Java applications, sometimes you may have to set JAVA_HOME environment variable. Here are the instructions to quickly set JAVA_HOME on your MAC OS. Open Terminal To Confirm if you have Java Type command: "which java" Hit Enter/Return button The command should return something like this: /usr/bin/java To get location of Java (detailed steps are documents here ) Type command: /usr/libexec/java_home Hit Enter/Return button The command should return something like this: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home To Set JAVA_HOME for single session Type command: export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home Hit Enter/Return button Type command to verify: echo $JAVA_HOME To Set JAVA_HOME permanently  Type command: vi ~/.bash_profile This will open bash_profile file Go to the end, and add following lines JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home export JA

MAC OS - Find Java Location

Do you need to find out location of Java in your MAC? Its simple: Open Terminal Type the command: /usr/libexec/java_home Hit Enter/Return button If Java is available, then you will see results like this OUTPUT: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home Need to find specific version? Open Terminal Type the command: /usr/libexec/java_home -v 1.7 Hit Enter/Return button If Java is available, then you will see results like this OUTPUT:   /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home What happens when specified version is not available? Open Terminal Type the command: /usr/libexec/java_home -v 1.8 Hit Enter/Return button If Java is available, then you will see results like this:  OUTPUT:   Unable to find any JVMs matching version "1.8". /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home P.S. Click here to access my other posts.

Couchbase - Clone Records and Update Document Key

Couchbase is one of the best NoSQL database. I have used this for one of the project and recently came across a scenario for which I had to do some research but straightforward solution was not available. So, I just thought of documenting various steps so that other can be benefited. So, in my scenario, I had to select some X records from one couchbase bucket and migrate them to another bucket. This was really easy. I wrote a N1QL query, added some WHERE clauses, and thats, done! All the selected records were migrated from one bucket to another. Here comes the complexity. Someone updated the requirements, and now I was asked to update the " key " of the document. I was searching, searching and searching for correct and quick solution but found that we cannot update document "key" using N1QL . So, now I had to find some work around, and this is what I came up with (someone may have better solution for this scenario): 1. Create a "tmp" bucket and

MuleSoft - Static IP Addresses and Multiple Workers

Did you just realize that your Mule Application requires horizontal scalling ? Well, thats easy - just go to CloudHub Runtime Manager, select your application and change the "Workers" count from 1 to either 2, 3 or 4. If numbers are grayed out, then you might have to adjust the "Worker Size", or purchase additional capacity from MuleSoft. So, what is the issue then? At the time of the blog post, based on Mule documentation, if you are using only 1 worker and if you want to apply static IP, then you can simply navigate to "Static IPs" section in Runtime Manager and allocate the static IP address. The issue is when you want to apply Static IP addresses for more than 1 workers for various reasons including IP whitelisting. Based on Mule documentation you cannot apply static IPs if you are using more than 1 worker. From Mule Documentation: "Static IPs are not supported for private IP addresses inside a CloudHub VPC and it is only supported for app

MuleSoft - JSON Schema Validation with Dynamic Schema Location

While working on a Mule Application project, if you a planning to validate JSON payload against some JSON schema , and more importantly if you want to pass schema location dynamically, then this post will be benificial for you. Mule provides JSON Schema Validator as out of the box feature. From mule documentation , evaluates JSON payloads at runtime and verifies that they match a referenced JSON schema. You can match against schemas that exist in a local file or in an external URI. If the validation fails, an exception is raised with feedback about what went wrong and a reference to the original invalid payload. Above code works but here is the catch, in my scenario, the schema location was dynamic. Let's say the schema location is present in the database. Once the schema location value is retrieved from database, it is stored in a flow variable. For simplicity, I am creating a flow variable with hard-coded value. In actual application, the flow variable value will be the va

Decompiler for Eclipse and MuleSoft Anypoint Studio

Decompilers are one of the most important tool for developers. Many Java developers use Eclipse IDE and many MuleSoft developers use Anypoint Studio (just another flavour of Eclipse) for their development work. We can easy configure decompiler for these IDEs. Here are the simple steps (for both IDEs): Download update site archive from here . Unzip the archive and note the location/path Open Eclipse or MuleSoft Anypoint Studio  Click on "Help" Select "Install New Software..." Click on "Add..." button On the pop-up, type name as "Java Decompiler" (or any other name) Click on "Local..." button Select the unzip location (Step 2) Click "OK" button to close the pop-up Select checkbox: Java Decompiler Eclipse Plug-in Click on "Next" Select "Yes" for the agreement Select "Finish" Restart Eclipse or MuleSoft Anypoint Studio Now, Eclipse or MuleSoft Anypoint Studio can decompile Java .