Categories
devops Technology

What is Docker?

This article is for you if you …

If you are a developer and you are going to start working with docker, and you already don’t know even the concepts of Docker, this article series is for you.

It was a little confusing for me when I started working with docker, so I decided to publish some articles for bits of help who are beginners to Docker or who want to review the concepts.

Overview of docker

Docker allows users to build independent and isolated development environments in the computer and run their software in a way that we call Container. For example, suppose you need a project with php8.1, but you only have php7.4 on your system(you need the php7.4 version to develop other projects).

In this use case, you can build a docker image that contains your PHP suitable version and your database and other environments and run it as a container by the side of another project in an isolated environment.

Another Docker use case

You are running a Linux environment with different PHP, database, composer, node.js, npm, and…

And your teammate is working on mac os with a completely different environment .

What is the solution?

How can you work on the same project simultaneously in a different environment?

How to deploy a project if the server can’t provide project requirements based on our development environment?

  • docker can solve this problem by build isolated environments in the server and provide exactly requirements of peject in the isolated space.

download and install docker :

  • https://www.docker.com/get-started/
Categories
Programming Technology

Masoud’s notes about Golang part 1

In this series article, I want to note some tips during watching Golang courses that are important for me.

Overall points :

  • golang is a compiled programming language
  • like as c and c++ it needs a main function
  • all built in functions are not available like as php and you need to import situble library
  • you cant define unused variable , function or even import unused library.
  • to print we need to import “fmt” library
  • it needs to specify variable type on definitions

some usefull commands:

go mod init mymodule

go run main.go

Golang Data types list

Masoud Hosseini | golang data types

Array and slice in golang

#array : 
var booking [50]string
or 
var booking = [50]string{"masoud"}

#slice 
var booking []string
or istead of "var" we can use ":="
booking :=[]string

add an index to a slice

append(booking, firstName + "- "+ lastName)

loop in Golang

we have just “for” loop in golang

to ignore a variable you dont want to use you can use “unser line” => “_”

so with Go you need to make unused variables explicit

for example :

firstNames := []string{}
		for _, bookingItem := range booking {
			var names = strings.Fields(bookingItem)
			firstNames = append(firstNames, names[0])
		}
Categories
without category

Docker Cheet sheet

Categories
Web Development

What is Graphql

I worked many years with Rest API, and because of a special situation, I had to work with Garphql in my projects.

After working with Graphql, I shared my experience and some valuable tips here.

  • what is Graphql?
  • where need to use Graphql?
  • Graphql or Rest ?

What is Graphql?

It was always a problem in projects to communicate between back-end and front-end using Rest APIs.

By using Rest API, you need to create an endpoint for every request or format data that the frontend needs.

But, by using Graphql, you prepare an endpoint, and the frontend will get the data with every format it wants.

After this explanation, like as other resources, we can say that: Graphql is a query language for the frontend which backend is organized.

Categories
English language

How to ask I want to sit alongside of drive?

Actually you can simply say “can sit of front “ or sth?

But if you would to impress Americans you can say :

I will be riding shotgun.

And it’s awesome.

Categories
English language

Difference of Sleep and Asleep

Something cool that I realized today was this, we have an “asleep” word in English and there are some differences between asleep and sleep :

while the word sleep refers to the act of going to sleep, the word asleep to the state of already being in a state of sleep (not awake).

the word sleep will be used as a noun or verb in a sentence while the asleep is used as an adjective and adverb in a sentence.

Categories
Movies

Force Majure Movie

Today as a holiday, I downloaded one of my movies list and start to watch (of course in the main language with English subtitle).

Categories
Programming Technology Web Development

Using Types in PHP is one of the least used features

Using Types in PHP is one of the least used features, but very powerful features available in PHP. This is a feature that can save you and other developers a whole lot of stress (if you work with a team).

Of course, you can write function descriptions, but it becomes quite a daunting task to write function descriptions for all your functions and variables in a large project.

When someone else wants to use your function or even you want to use it after a couple of weeks later, it needs to check the function’s body to recognize which types you should pass to the function while using, if you don’t specify arguments types.

Ex:

function getItem(array $item) {
return allItems()[$item[0]];
}

This will make sure that whatever is passed in here is the type needed. You can read more from www.php.net

For more tips:
https://lnkd.in/eWgvUVKS