Showing posts with label Technical!. Show all posts
Showing posts with label Technical!. Show all posts

Saturday, March 18, 2017

How to add Navigation Tabs to your blog and seperate posts with labels? :)

When you create a blog it is easy for the readers if the posts are categorized into sections. The easy way to do it is to include separate navigation tabs to your blog. It will give easy access to the reader as well as you can properly manage your content.

1) Go to your blog and click Design from the top corner.



2) Click Layout from the side pane.



3) You will be directed to the Layout page.
From that select any place where you need to have your navigation tabs and click on one of the 'Add a Gadget' options. (Normally the navigation tabs are added to the 'Cross-Column area)
This will open the Add a Gadget pop-up window.

4) Select HTML/ Java Script option.



5) You can follow the below example code to add your tabs accordingly.
Add your code to the Content section and click the Save button.

e.g. : If you are thinking of adding the navigation tabs displayed in the first image of this post, the code will be as below.. Also you will be able to sort them out through labels.

<div id='navibar'>
<a href="http://castakai.blogspot.com/" class="navitabs" title="Home">HOME</a>

<a href="http://castakai.blogspot.com/search/label/Me" class="navitabs" title="Me:)">#Me</a>

<a href="http://castakai.blogspot.com/search/label/Technical!" class="navitabs" title="Technical!">Technical!</a>

<a href="http://castakai.blogspot.com/search/label/InterestingFacts" class="navitabs" title="Interesting Facts ;)">Interesting Facts ;)</a>

<a href="http://castakai.blogspot.com/search/label/Fancy" class="navitabs" title="Fancy">Fancy :D</a>

<a href="http://castakai.blogspot.com/search/label/Sports" class="navitabs" title="Sports">Sports!</a>

<div></div></div>



6) Before saving the whole layout you can see a preview by clicking the Preview button.
If you think the design is good to go, click Save Arrangement button.



7) The added navigation tabs will now be visible in your blog.



Simple as that you can add navigation tabs as much as you want to organize your blog :)

Saturday, May 23, 2015

How to keep a GitHub fork repository up to date?

You might come across many instances where you will have to fork a github repository and commit your changes as pull requests to the original master repository.

If you are to commit changes every now and then you need to make sure that your local repository is up to date with the master repository. Else if there are other commits made by users and you do not have the recent changes you might get commit conflicts once you make a pull request.

So to avoid this, you need to follow two steps.

1. Configure a remote pointing to the original repository.
2. Sync your local repository with original repo.

Configure a remote pointing to the original repository
You can configure a remote  like below.

1. Open the terminal and go to your local repository location.
Next type below command.
You can replace content with the url of your original repository.

git remote add upstream https://github.com/yourRepository.git

2. Next you can verify that a remote upstream repository got added, by giving following command.

git remote -v

  This command should list down the remote you added in previous step.

Sync your local repository with original repo
After you completed creating a remote upstream, now you can update your local repository by giving following commands.

1. Below command will fetch all the changes/updates of your original repository.

  git fetch upstream

2. Next checkout your local master branch.

 git checkout master

3. Next merge the changes of your upstream repo to your local repo.
This will sync your forked local repository without giving up your local changes.

git merge upstream/master


Monday, March 30, 2015

How to uninstall Applications from Mac?!

I had a problem when it comes to uninstalling an installed application in Mac. When I delete it from the application location this always left behind remainders. This was a huge headache when reinstalling some applications.

Then I found  CleanMyMac 2 as a solution!
This is a Mac Uninstaller which helps to keep your Mac clean and has tons of awesome features which you definitely want to use :)

Download the awesome Mac uninstaller
  • Click on the downloaded dmg.
  • You will get a pop up window as shown bellow.
  • Drag the CleanMyMac2 icon to the Application folder. Now you have installed CleanMyMac2.
  • Open the CleanMyMac 2

  • Go to Uninstaller section
  • Select the Application you want to uninstall

  • Then all the folders, files which got installed with the Application every where in your Mac will get selected.
  • Now what you have to do is simply click the Uninstall button.
    This will uninstall your application removing all the possible installed files and folders!
  • And if you have remaining items which were left out from your previously deleted Applications, you can check them too.
  • All you have to do is go to Uninstaller section and click on the Leftovers from the top pane.

 
  • If any files or folders are shown in the window, you just have to select them and click Remove button.

Hope those who had the same problem like me will get a solution now! Happy Uninstalling!!! ;)

 

Wednesday, March 25, 2015

How to use Selenium IDE?!

To start with you need to install the needed IDE.
You can refer to How to install Selenium IDE for more information.

This is very useful to automate user actions on a website, automate certain web administration actions, to automate bug reports, create automated test scripts that shows the bug report and attach that script i your bug report so that the developer can view it and see the flow
  • Open Firefox
  • Click Tools and click Selenium IDE
  • Selenium IDE will open
Now I will show you some simple steps how to work with Selenium.

How to Record a test flow?
  • When you open the IDE move the corser to the Red button. There you will see 'Now Recording. Click to Stop Recording'
    This means you are ready record.
  • Now you can load the web page you want to test and start recording the steps of the flow you want to execute.

    What I'll be doing is search Kala's World :) in Google and view How to install Selenium IDE?! post! For that I am doing the following steps.
  • When you do each of the above steps it will get recorded automatically in the Selenium IDE, one step at a time.
  • Click the Red button to stop recording
  • Save the Test Case (File > Save As > Give a file name > Click Save)
  • In the Table section you can see the saved steps
  • The Reference tab gives you the information what those commands in each step do
  • The Command column basically shows what action needs to be performed when testing
  • Target column shows where exactly that action has to be perform in the web site 
  • The Value column shows the value needs to be given to execute the command or some additional information. 
  • Selenium IDE saves the test cases as HTML. You can view it by clicking the Source section


    How to Run a recorded test case/suit?


  • Now lets run the recorded steps.
  • You can Click 'Play entire test suit' / 'Play current test case' button to run the whole flow.
  • Or click each and every step to run one step at a time.
  • There is a slider Fast Slow to adjust the speed of the execution if you want to look in to the steps more clearly. 
  • When you run you will see how it is been executed from the Log tab


  • Now let's see how this gives an error if there is a wrong step included.
I am going to edit the 3rd step click.
  • Click on the step
  • Go to the Target field change the name=btnG to name=btn  The step will be changed.
  • Now execute the test case again.
  • This test should get failed giving the bellow error in the Log tab.

How to stop the test from a particular step?
  • Right click on the step you want to stop the test run.
  • Select Toggle Breakpoint.


  • Now the execution should stop above the step you put the break point.
  • And if you want to move forward from that point onwards click Pause/Resume button. Then the remaining steps will be executed.
  • If you want to run through the steps after the break point one by one you can click Step button and execute the steps.


How to add more steps to the test case?
  • Go to the end of the test case.
  • Click on the empty space. 
  • Click the Record button.
  • Now you can add more steps as you want and save.
  • And if you want to add a step to the middle. Right click > Insert New Command
  • You can manually write the command without recording.
  • For that Right Click on the empty space and select 'Insert New Command'
  •  Now you can enter the values you need in the Command, Target, Value fields and add a new step to the test case.


  • And if you need help in adding the values to the Target field you can always go to the next step location from your browser.
    Right click and select 'Inspect Element'
  • It will show you the information needed about the field, drop down list ..etc.
    You can always use the 'id=' to identify the place you want.


How to enhance the test case by adding documentation?
This helps a user to understand what we do in the test case or may be we can divide the test case in to sections for our benefit or future reference.

  • Click on the place where you need to add a comment. Right Click > Insert New Comment
  • Now you can add you comments to make it more simple.
  • Save after doing the changes.


Hope you got the basic idea how you can use the Selenium IDE! Enjoy the work!


Tuesday, March 24, 2015

How to install Selenium IDE?!

What is Selenium IDE?

Selenium IDE is a fully featured Integrated Development Environment (IDE) that installs as a plugin for Mozilla Firefox. This enables developers to test their web applications through Selenium.
With the Selenium IDE, you can record user interactions with the web browser and play back to test for errors.
It is a good and powerful IDE where you can simply do the QA testing process and automate the testing flows.

* The Selenium IDE is currently available only on Firefox.

If you don't have it already go to the SeleniumHQ page.
You can refer this for more details and read about Selenium.

And to download the Selenium IDE to Firefox click the Download section. Or straight away click here
There you can see sections for different Selenium tools.
  • Go to the Selenium IDE section.
  • Click on 'Download latest released version' link
  • Once it is clicked Firefox will display a message
  • Click Allow button. Then the installation will start.
  • Then you will be shown a window with the add-ons to install.
  • Click Install Now button.
  • After you will be asked to Restart the Firefox browser in order to install the add-ons.
  • When you click the Restart button the browser will  close and reopen with the add-ons installed.
  • Now when you go to the Tools > Selenium IDE option will be displayed there.
  • Or else you can check the add-ons by navigating to the Firefox Add-ons.
 
  • If the add-ons are installed it should be displayed as bellow


  • Now to open the installed IDE, Click Tools and click Selenium IDE
  • Selenium IDE will open as shown bellow



Now you are ready to use the Selenium IDE!




Sunday, March 22, 2015

Test scaling Logistic regression (ML classification algorithm) by partitioning data by Histogram [2]

Information about important classes..

Class
Description
GetMinMax.java
Calculate the min max values of each feature
HistogramEnsembler.java
Encapsulate partitioning data through creation of models for each group. Also the model ensembling logic is implemented.
HistogramHelper.java
This calculates the bin number and converting a given coordinate to a bin number.
HistogramTester.java
Analysis of the partitioned data using a Histogram
HistogramTree.java
Allow formulating and manipulation of the histogram.
IHistogramHelper.java
Defines the contract of the histogram.
LogisticRegresionTester.java
Analysis of the logistic regression with full data set.
Metrics.java
Efficiency calculation
RandomPartitionedEnSembler.java
Encapsulate random partitioning data through creation of models for each group. Also the model ensembling logic is implemented.
RandomPartitionTester.java
Analysis of the logistic regression with randomly partitioned data.


TestHistogramHelper.java
This does the unit tests of the HistogramHelper class. It tests the dimensions and the change axis order.
TestHistogramTree.java
This does the unit tests of the HistogramTree class. It tests the neighbouring bins and checks the grops are of equal sizes.

Testing and Evaluation



Technique Used
Accuracy (%)
Performance
Method 01
Logistic regression with full data set
74.2720201581548
training time : 52s
Prediction time: 12s
Method 02
Logistic regression with randomly partitioned data set
74.35145399566024
training time: 2min42s
Prediction time: 15s
Method 03
Logistic regression with partitioned data using histogram.
74.36789359939304
training time: 06min07s
Prediction time: 12s

Above table is being used to compare three different methods used to run logistic regression.
According to the statistics given in the table in terms of accuracy all three methods shows relatively similar accuracy levels. When comparing training times method 01 shows the best time of 52s whereas method 03 shows worst. however considering the prediction times method 01 and method 03 shows best of 12s.
 

Friday, March 20, 2015

How to manually generate your SSH Key in Mac OS X?!

  • Open the Mac OS X Terminal
  • (Finder > Applications > Utilities)
  • Double-click the Terminal application
  • The Terminal window opens with the command line prompt displaying the name of your machine and your username.

How to generate a SSH Key?

SSH key consists of a pair of files. One is the private key (which you should keep to your self. Do not share this key with anyone!) and the other is the public key (this will be used to log into other machines).
  • To start the key generation process        
                  ssh-keygen -t rsa
  • When you execute this command, the ssh-keygen utility prompts you to indicate where to store the key.
  • Press the Enter to accept the default location.
  • The ssh-keygen utility prompts you for a passphrase. (Here you can skip the step by pressing Enter without giving a passphrase)
    After you confirm the passphrase, the system generates the key pair.
  • Your identification has been saved in key.txt.
  • Your public key has been saved in key.txt.pub.
  • The key fingerprint will be shown as bellow :

7d:4d:bb:5c:d1:45:01:ae:a3:19:ff:7b:dd:8c:28:b3 NAME@MAC.local
The key's randomart image is:
+--[ RSA 2048]----+
|                        ..o+|
|                        .   o|
|                          ....|
|                     .  .o ..|
|                  S..o. o .|
|                     =... o |
|                  o . .ooo|
|                    o o ..+|
|                   E+ oo  |
+---------------------+
  • Your private key is saved to the id_rsa file in the .ssh directory.
     
  • Your public key is saved to the id_rsa.pub file.
Using the Public Key

You have to give the public key to the server admin or the connection you are going to access.

Using the Private Key (Do not reveal this to anyone)
  • Open the file you keep the Private Key with the text editor. Name you file with a name you want. For this I am calling it privateKey.txt.
    Paste in the private key and save the file.
  • If you are using the terminal:    vim privateKey.txt
    When the empty file is opened, press i in your keyboard to get into insert mode, paste the key, press ESC and then :wq to write/save and exit from the open file.
  • After saving the file change the permissions to 600 or 400. (this is a must)
                           chmod 600 deployment_key.txt
  • Now log in using the SSH client. 
  • Load the key in file privateKey.txt to log in to the user (UserName) to IP (xxx.xxx.xx.xx)
                           ssh -i privateKey.txt UserName@xxx.xxx.xx.xx
  • Now you will be asked whether you are sure to connect. Type yes and press Enter.
    Then you will be asked to enter a password for your key (if you have one).
    After the step you will be logged in to the server.


Saturday, March 14, 2015

How to create a LDAP from Apache Directory Studio?

To start creating a LDAP you need to have ApacheDS, Apache Directory Studio downloaded and installed.

You can download and install them from ApacheDS and Apache Directory Studio.
  • Open Apache Directory Studio.
  • From the left side bottom corner click 'Show view as a fast view' icon

  •  A drop down menu will appear. You can select and add the item you want from that.
  • Go to LDAP server section. 
  • Click the New Server icon. New LDAP server window will appear.
    In this I will be selecting the new version and click Finish.
     
     
  • The ApacheDS 2.0.0 will be added as shown in the image.
  • You can create a LDAP servers as you want (Click New > New Server) by selecting the versions.

  • Select the created server and click the Run button to start the server.
  • Create a connection to the server.
    Right click > Create a Connection. Give a name as you prefer.

(Default instance of the Apache DS is : user name is ‘uid=admin, ou=system’ and Bind password is: ‘secret’)

  • Go to the Connections and double click the name of the new connection you created.
  • If it is properly created, you should see an outline of the Directory Information Tree (DIT) in the LDAP Browser.



  • Now you can create the structure of the LDAP as you want it to be.
  • Right click on the  node dc or ou and select New > New Entry. The New Entry wizard appears.


  • Entry Creation Method window will appear. Select the Create entry from scratch radio button and click Next.

  • Find the organizationalUnit object. Select it and click Add button.
    Click Next.
  • In the RDN field type ou.
    In the value field type Groups.
    Click Next.
  • The Attributes window will appear. You can see the added values.
    Click Finish.
  • Now you can see the ou=Groups is displayed in the Browser pane.
  • To add ou=Users do the same steps as above.

    Adding users

  • Right click the ou=users entry. Select New. Select New Entry.
  • Entry Creation Method window will appear. Select the Create entry from scratch radio button and click Next.
  • Find inetOrgPerson object. Select it then click Add button.
    Click Next.
  • In the RDN field type cn. In the value field type the user name you want to add.

  • Click Next. The Attributes window will appear.
  • Under the sn attribute, enter Weerawardana (sn stands for Surname)
  • We need to add a username for this user.
    Right-click on the same window. Select New Attribute. The Attribute Type window will appear.
  • In the 'Attribute type' field, type uid. (This will serve as the username of the person)
    Click Next, then click Finish.
  • You will be directed back to the Attributes window.
  • For the uid attribute value, type kweerawardana
  • Now we should add a password for this user.
  • Right click on the same window. Select New Attribute. The Attribute Type window will appear.
  • In the 'Attribute type' field, type userPassword. This will serve as the password of the person.
    Click Next, then click Finish.
  • You will be asked to enter a password. Enter pass as the new password.
  • Keep the value for the Select Hash Method field as you prefer. As Plaintext, SHA etc..
    Click OK.
  • A new entry will be added under the ou=users. The new entry is cn=Kala Weerawardana.
  • You can add more users by following the same steps as above.

 

Add the Authorization Levels

  • Right click the ou=groups entry. Select New > New Entry.
    The Entry Creation Method window will appear.
  • Entry Creation Method window will appear. Select the Create entry from scratch radio button and click Next.
  • Find the groupOfUniqueNames object. Select it then click Add button.
    Click Next.
     
  • In the RDN field type cn. In the value field type User
    Click Next. The Attributes window will appear.
     
  • There will be an uniqueMember attribute.
    One uniqueMember attribute will represents one user.
     
  • So if you have more to add,
    Right-click on the same window. Select New Attribute. The Attribute Type window will appear.
     
  • On the Attribute type field, enter uniqueMember.
    Click Next, then click Finish.
     
  • In each entry you add the dn of each user.
    ex : cn=Kala Weerawardana,ou=Users,dc=wso2,dc=com
     
  • Click Finish after adding all.
     
  • A new entry has been added under the ou=groups. The new entry is cn=User.

If you want to add an admin user,
  • Right click the ou=groups entry. Select New > New Entry.
    The Entry Creation Method window will appear.
  • Entry Creation Method window will appear. Select the Create entry from scratch radio button and click Next.
  • Find the groupOfUniqueNames object. Select it then click Add button.
    Click Next.
  • In the RDN field type cn. In the value field type Admin
    Click Next. The Attributes window will appear.
     
  • There will be an uniqueMember attribute.
    One uniqueMember attribute will represents one user.  You can follow the previous steps.
     
  • Click Finish after adding all.
  • A new entry has been added under the ou=groups. The new entry is cn=Admin.

* If you wish to work with tenants in a product, you can add ou=Tenants to this structure as well by simply following the previous steps.
By adding ou=Tenants you can organize your structure well in the tenant creation flows without messing up the directory structure.

You are now done with creating a sample structure :)


If you want to view the data in your structure you can view that in the created LDIF.
  • Right click on your entry.
  • Click Export > LDIF Export
     
  • Data To Export window will pop up. Click Next.
  • Click Browse button. Give a name for the file and the location to be added.
     
  • Click Save.
    Click Finish.

You can modify data in this file as well to make changes to your created structure.


Friday, March 6, 2015

How to use WSO2 Developer Studio to develop an application in WSO2 App Factory?!

To get an idea you can download and try out WSO2 App Factory from here.


Log in to the App Factory and create a new application.
       Refer Create an Application from Scratch 


Install WSO2 Developer Studio in your environment.
        Refer this to see how to install. 

  • After the installation is done, open the Developer Studio. 
  • Select the dashboard from the top pane.
  • From the view click Switch to App Cloud / App Factory perspective.
  • Click the Login icon as shown.
Login icon view
  • A Login window will appear.
  • In that click the App Factory option.
  • Give the App Factory URL and the credentials that you used to log in to the App Factory.
  • The App Factory perspective will open.
  • Details of the currently remaining applications appear.
  • To check out your code and modify, right click on your application and click Open.
  •  The available branches of the application appear under it.
     
  • Right-click on the main branch and click Check Out and Import.
  • The application opens in the Project Explorer.
  • Do your modifications and save.
     
  • Right click on the project in the Project Explorer 
  • Click Team > Commit
    Team > Commit
  • If prompted for credentials give your Git credentials. (It is the same as used to log in to the App Factory)
***************************************************************************
If your view does not have Team > Commit options you can follow the bellow steps to have it in your setup:
  • Go to the Home of your machine
  • View the hidden files (If you are using Mac OS you can follow this to show and hide the hidden files)
  • Delete the .git file
  • Add Apache Maven home path to the .bashrc file
       export M2_HOME=/Users/KalaCW/apache-maven-3.2.5
****************************************************************************
  • Enter a commit message in the pop up window.
  • Select the files you want to commit and click Commit and Push. 
  • This will add the changes you did in WSO2 Developer Studio to the files in the repository.
  • Go to the the Repos & Builds page in App Factory and click the Launch button associated with the master repository to run the application.

Now you have your developed Application Launched in WSO2 App Factory :)