Categories
Git Technology

how to edit last commit message

Type git commit –amend and press Enter.

git commit --amend
reference:

https://github.com/git-tips/tips

Categories
Linux Shell Technology

Define Shortkey in the command line, Linux (Ubuntu)

For bash you have to do the following steps:

1) Open your .bashrc

sudo nano ~/.bashrc

2) Add new alias (at the end of the file)

alias phpstorm='cd ~/Downloads/phpstorm/bin/./phpstorm.sh'

3) Save and close the file

4) Source the .bashrc file

source ~/.bashrc

reference :

http://www.linfo.org/alias.html

Categories
Linux Shell Technology

Linux Crucial commands – Chmod Command in Linux (File Permissions)- part 2

See file permissions :

ls -l example.txt

#output
-rw-r--r-- 12 linuxize users 12.0K Apr  8 20:51 example.txt
|[-][-][-]-   [------] [---]
| |  |  | |      |       |
| |  |  | |      |       +-----------> 7. Group
| |  |  | |      +-------------------> 6. Owner
| |  |  | +--------------------------> 5. Alternate Access Method
| |  |  +----------------------------> 4. Others Permissions
| |  +-------------------------------> 3. Group Permissions
| +----------------------------------> 2. Owner Permissions
+------------------------------------> 1. File Type

What is chmod in Linux:

in UNIX OSes, chmod is a command to change files and directories permissions.

chmod stands for “change mode”.

one of the most important reasons for Linux to be on the list of safe OSes is that every user has their own permission for each file and folder.

Categories
devops Linux Shell Technology

Linux Vim commands

quit of editor without saving
:q!
Categories
devops Shell

Linux Crucial Commands – Part 1

To restart your machine :
sudo reboot
To see a list of files and folders in Directory simple:
ls
To see a list of files and folders in Directory with complete detail as list :
ls -la
To see a list of files and folders in Directory with complete detail as list :
ls -la
Categories
Programming Technology

Masoud’s notes about Golang – Part 2

when you want to run or build a go file it needs to be the main package (I’ll write more about packages in go later).

let’s div into example code

package main
import "fmt"

func main(){

	for i := 0 ; i <= 500 ; i++{
		s := ""
		
		if i % 7 == 0{
			s = "Haftaeiash"
		}
		if i % 3 == 0{
			s = "Setayi"
		}
		if s != "" {
			fmt.Println(s)
		}else{
			fmt.Println(i)
		}
	}
}

To run package :

go run masoud.go

To check out environments :

go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/masoud/.cache/go-build"
GOENV="/home/masoud/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/masoud/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/masoud/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3281051355=/tmp/go-build -gno-record-gcc-switches"

By default it prints the list as a shell script; however, if one or more variable names are given as arguments, it prints the value of each named variable.

$go env GOOS GOPATH
linux
/home/yourname
Categories
without category

Pivot table relation in laravel

for implementing many to many relations in laravel you need to define a function in mode :

imagine we have entity user and entity teacher, and of course, we have a pivot table (something like user_teachers table)

let’s implement relation to teacher from user mode :

    public function teachers()
    {
        return $this->belongsToMany(

// the class we want to set a relation -1 
            Teacher::class, 

// pivot table name -2
            'user_teachers', 

// the column refer to the class that we are write code in (user)
            'user_id',


// the column that refer to number 1
            'teacher_id',

// primary key in source table (user)
            'id',

// primary key in target table (techer)
            'id'
        );
    }
Categories
Introduce usefull links

Addyonmani.com

Addy is an engineering leader currently working on the Google Chrome web browser. He has worked at Google for ten years, focused on making the web fast. He previously worked at AOL and on Fortune 500 sites.

Engineering need soft skills too! Addy blog can help you currently in this way.

https://addyosmani.com/blog/software-engineering-soft-parts/

Categories
Best practice devops Programming Technology Web Development

Implement Rest APIs more efficient

Most web applications are implemented based on Rest Full APIs and as I researched huge part of them are not implemented based on best practices and clean code principles, so I decided to collect some points in a couple of posts to help make them more efficient APIs and Applications.

Let’s Look at other kinds of APIs

you can easily research and find out more about all of these kine of API design methodologies but here I’m going to just collect best part of them to create a document to implement Rest API in best practice.

Graphql

the best part of graphql is that you can design your API for the front end to just get whatever need, not more.

it can bring us better speed because less amount of packets is transferring over the network.

gRPC

Socket

Categories
Fix bugs and problem

Linux Manjaro screen recorder problem (record blank)

I’m using OBS Studio in Manjaro Gnome 40. Fix black screen in wayland session.

Open Terminal

sudo nano /etc/gdm/custom.conf

enter root password

looking at #WaylandEnable=false

and remove “#”

should be like this

WaylandEnable=false

Ctrl+x to save and exit
y for yes then enter

Restart the computer and start again OBS Studio

reference :https://forum.manjaro.org/t/screen-recording-problem/34983/11