Syed Sayem blog

Connect to Windows 10 Docker Daemon from Ubuntu Bash

I’m assuming you already have Docker and Ubuntu Bash installed in you’re Windows 10 System. If you haven’t done it already, or if you need some guidance on how to install Ubuntu Bash or Docker in your Windows system, just do a Google search “Enable Ubuntu Bash in Windows 10” or “Docker for Windows” and you’ll find plenty of tutorials on how to install Docker and Ubuntu Bash for Windows 10.

After you installed Docker and Ubuntu Bash,

Open the Start Menu and search for ‘Ubuntu’. Now click on the orange circle of doohoo Ubuntu logo to launch Bash on Ubuntu on Windows!

Add your computer name into /etc/hosts file

sudo nano /etc/hosts

Example,

127.0.0.1 localhost SAYEM-PC

Now download Docker for Linux,

$ wget https://get.docker.com/builds/Linux/x86_64/docker-1.13.0.tgz

Extract it,

$ tar -xzvf docker-1.13.0.tgz

Make ~/bin folder and move everything in the ~/bin folder

$ mkdir ~/bin
$ mv docker ~/bin

Open .bashrc and add the following statement

export DOCKER_HOST=localhost:2375
export PATH=$PATH:~/bin

Install docker-compose

$ sudo apt-get install python-pip bash-completion
$ sudo pip install docker-compose

And Bash completion.

$ curl -L https://raw.githubusercontent.com/docker/docker/master/contrib/completion/bash/docker > /etc/bash_completion.d/docker
$ curl -L https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose

Done!

Selenium Page Object in Golang

Recently I started learning Golang and I want to share with you how I taught myself to program in Golang and created a selenium page object project in Golang. The first thing I did to teach myself to program in Go was to take the Tour of Go

The tour is a great interactive tutorial that helps you get your feet wet with the language. It works right inside your web browser, so you do not have to install anything to get going right away with learning go.

Next, I started reading “Go Programming Language by Alan Donovan”. This really helped me learn how to write code in go. The book teaches you Go in an incremental fashion using simple exercises that build upon each other. It is one of the best ways to learn Go right now.

Once you have some idea on how to program in Go, its time to start writing small a project like Selenium test.

When writing selenium tests, a common pattern is to use Page Objects. Page Objects help you write cleaner tests by encapsulating information about the elements on your application page. A Page Object can be reused across multiple tests, and if the template of your application changes, you only need to update the Page Object.

Selenium doesn’t have any official language binding for Golang, so we will use one of the selenium third-party library for golang.

To get the third-party selenium library, open the terminal and run the following command:

$ go get github.com/tebeka/selenium

Next, install any WebDrivers you plan to use. For Mac OS X (using Homebrew):

$ brew install phantomjs
$ brew install chromedriver
$ brew install selenium-server-standalone

For Arch Linux (using Pacman/Yaourt):

$ yaourt -S selenium-server-standalone
$ yaourt -S chromedriver

Clone the git repo:

$ go get github.com/sayems/golang.webdriver

Project structure

golang.webdriver/
      +- pages/
            +- page.go
            +- home_page.go
            +- login_page.go
            +- men_page.go
            +- women_page.go
      +- tests/ 
            +- base_test.go
            +- register_test.go
            +- login_test.go
            +- other_test.go
  +- .gitignore
  +- Dockerfile
  +- LICENSE
  +- README.md
  +- docker-compose.yml
  +- pom.xml

home_page.go

package pages

type HomePage struct {
	Page Page
}

var account = "#header ..."
var myAccount = "#header-account ..."

func (s *HomePage) GoToAccountPage() *AccountPage {
	s.Page.FindByCss(account).Click()
	s.Page.FindByCss(myAccount).Click()
	return &AccountPage{Page:s.Page}
}

func (s *HomePage) GoToMenPage() *MenPage {
	return &MenPage{Page:s.Page}
}

func (s *HomePage) GoToWomenPage() *WomenPage {
	return &WomenPage{Page:s.Page}
}

func (s *HomePage) GoToAccessoriesPage() *AccessoriesPage {
	return &AccessoriesPage{Page:s.Page}
}

func (s *HomePage) GoToSalePage() *SalePage {
	return &SalePage{Page:s.Page}
}

home_test.go

package main

import (
	"testing"
	"github.com/sayems/golang.webdriver/selenium/pages"
)

func TestSelenium(t *testing.T) {

	login := pages.HomePage{Page:page}
	login.GoToAccountPage().
		CreateAnAccount().
		Register()

}

You can see the full source code in this repository

Setup Swift and Clion on Arch Linux

In this blog post, I’ll show you how to get started with Swift programming language on Arch Linux. This tutorial includes installation of Swift in Arch Linux and set up Clion IDE by JetBrains.

Open the terminal and run the following command to install: swift

$ yaourt -S swift

Now, run the following command to install: Clion

$ yaourt -S clion

Create a swift project

$ mkdir SwiftProjects && SwiftProjects
$ mkdir Hello && cd Hello

Now run the swift package’s init command with executable type:

$ swift package init --type executable

Compile the package by running the swift build command:

$ swift build

After the command finishes, the built products will be available in the .build directory. Run the Hello program with the following command:

$ .build/debug/Hello
Hello, world!

Now, we’re going to import Hello project to Clion IDE

Open CLion, Select “Import Project from Sources” and then navigate to “SwiftProjects” and then select Hello

first-screenshot

Navigate to Hello project second-screenshot

Make sure all the box are check third-screenshot

If you get this error message, you’ll need to modify CMakeLists.txt. fourth-screenshot

Replace the following code in CMakeLists.txt

cmake_minimum_required(VERSION 3.6)
project(Hello)

add_custom_target(Hello
        COMMAND swift build
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
        SOURCES Package.swift Sources/main.swift)

You can learn more about swift-plugin from JetBrains blog post.

Now, Open File > Settings, and search for Swift

  • Setup SDK Home to /usr/bin
  • Enable Use Swift debugger

fifth-screenshot

Now, search for CMake and select CMAKE. Under Build, Execution, Deployment

  • Change Build output path to .build/debug

sixth-screenshot

Now, go to Run > Edit Configuration

  • Target to Hello
  • Configuration to Debug
  • Executable to Hello

seventh-screenshot

Now, Run the Hello program by going to Run > Run eight-screenshot

Hello, World!
woof

Congratulations! You have just finished writing your first Swift Application in Clion.

Happy Coding :-)

Android Basics Nanodegree Certificate

Today, I graduated with an Android Basics Nanodegree by Google. The course was co-created by Google and Udacity. Over the last 2 months, I have learned an incredible amount about developing Android app. Not only did I complete the projects neccessary for graduation, but I also created more projects on the side to learn more skills. Over the course of those 2 months, I built 10 Android apps. While I have learned a ton during this period, there is still so much to learn about Android Development.

first-screenshot

I decided to start the Android Basics Nanodegree at Udacity because I wanted a guided way of learning by industry professionals. It also helped that they were partnered with a lot of big companies and offered code reviews for all of your projects. While there are a lot of online options for bootcamps, Udacity was by far the cheapest and offered an environment that was more tailored to my style. With great reviews for the course, I signed up for the Nanodegree.

Overall, it was wonderful experience taking Android Basics Nanodegree by Google and graduating successfully. I would highly recommend any beginner or intermediate developer to take the Android Basics Nanodegree on Udacity.

Android Nanodegree scholarship

A few days ago I participated in a competition to get scholarship from Udacity, an online learning platform. The competition is runned until December 31st or until there’s 100 people who finished Android Basic Nanodegree program.

first-screenshot

Whoever finished the program from 1st to 100th participant will get full scholarship from Udacity for Android Developer Nanodegree sponsored by Google.

second-screenshot

After struggling for a few days to finished the Nanodegree as soon as I can, I got positioned number 128. Which mean I will not get the scholarship but I am happy that I finish the program.

third-screenshot