Posts

Git mistakes - 1

Git mistakes - 1 Hello Coders… I hope you are having a great weekend. Today I am going to talk about My Git mistake . I was working with a project where I tried to add opentracing to it (which is still not working properly). First I created a new branch from my development branch using : git checkout -b tracing Then tried to add opentracing to it, there were many errors and I was fixing one by one and committed all the codes properly. At certain point I had to revert my git branch to a previous commit I made. Then I was working on that. Didnt merge the commits back to original tracing branch. When I try to merge them with my tracing branch , I was getting a lots of errors. Tried to fix them ( merge conflicts ), but they were not working as expected. Finally I found a solution for this problem. This is kind of shortcut. Create a new branch from the current HEAD detached branch. Eg : git branch tmp git-hash-id Delete remote branch git push origin

Docker Development - Mistakes 1

Docker Development - Mistakes 1 Hello dear coders How had you been? I hope you all doing great. Today I am going to talk about my long (yet very small in total) development using docker experiences. First lets see a simple docker file from my recent hobby project. FROM golang:alpine RUN apk update RUN apk add git COPY . /go/src WORKDIR /go/src RUN set -e \ go get github.com/opentracing/opentracing-go \ && go get github.com/uber/jaeger-client-go \ && go get github.com/uber/jaeger-client-go/config RUN go build -o main . RUN chmod 755 main CMD [ "./main" ] This dockerfile based on golang:alpine and just add git to docker-image. Then copy current working directory to /go/src Set working directory and installing opentracing packages. Finally just build and running main go module. What is the so called docker mistake here? Here I didnt notice that, but when every time I run docker-compose up --build after changing the code opent

Youtube-dl cheatsheet

Youtube-dl cheatsheet Hello fellow coders… Today I am going to post something different. Its about a command-line based youtube downloader called youtube-dl . If you dont know about it, please go and check their homepage . This gives you instructions to install it correctly. So today I am going to post some cheats you will need to download best youtube videos quickly. One more important thing, there are no configuration settings to be done before or after installing youtube-dl . Downloading a single video When you need to download a single youtube video, you just type : youtube-dl youtube-video-url This will download the best quality video available. But if you can select specific video quality. I will describe it later. Downloading a playlist When you are interested about a certain youtube play list and want to download, youtube-dl gives an easy way to do it. You just have to use : youtube-dl -cit youtube-playlist-url Download specific videos from a

How to get MySQL data using sql.Query() in golang

How to get MySQL data using sql.Query() in golang Hello fellow coders… This is my first golang post here on blogger, I had been learning it for last a few months and now developing my own hobby project. Today I am going to share how to get data from MySQL table using sql.Query() function. First thing is connecting to MySQL database, to do so, I have used a separate function. func dbConn() (db *sql.DB) { db, err := sql.Open("mysql", "root:my_password@tcp(127.0.0.1:3306)/my_database") if err != nil { log.Println("Can not open database connection") } return db } And in my function where I need to connect with database, I use db := dbConn() defer db.Close() Always remember to close the database connection. And in this function, I am trying to get vehicle_ids from table. Here I have used a variable to hold the string query. It makes code more readable and clean. Here db.Query() returns a pointer to all available MySQL rows,

The Biggest MySQL mistake I made

Welcome file The Biggest MySQL mistake I made Ok, as usual I have broken my promise to keep writing post. Anyways, there is a good news too. I have been studying Golang for months now and developing some my own projects. But today I am going to share completly different thing I met recently. I was working with a MySQL table and wanted to delete a record from it. So I wrote delete from my_table.. before I put where clause accidentally I hit enter. So my terminal was like mysql> delete from my_table -> what I did was, just put ; and press enter. mysql> delete from my_table -> ; Query OK, 56 rows affected (0.09 sec) Boom, I have deleted all the records from my table. I had spent another hour plus to manually insert all the records back to table. Luckily I have printed all the records in that table. SO the lession I learn that day was, never use ; in unknown MySQL queries. If you make a mistake and came -> line, just hit CT

How to fix "username is not in the sudoers file" in debian

Hello fellow coders Recently I installed Debian-9 in my old laptop and tried to execute sudo command and I got above error saying that action will be reported. So today in this short post, I am going to tell you how to fix this problem. First, open your terminal and put su - Enter your password and then just type visudo This will openup a file with nano editor and it has few values, do not change any of them, just go to the line root ALL=(ALL:ALL) ALL and below it add a new line myuser ALL=(ALL) ALL save the file and then try to execute commands with sudo.. I hope this short post will save you a lots of times, in next blog I will bring you what are the meanings of these lines. Also a good Golang tutorial comming soon. Good Luck

A Go Journey - Part 1

Hello fellow coders, Merry Christmas and a Happy New Year!! I am about to start a fresh project with Golang. I will update the blog through out the project. Here I am going to create a simple blogging platform using Golang's micro-architecture just like I created using Laravel and Django . I just started Golang.  As I understood it sofar, we can call it as a combination of C and Python programming languages. It has the power of C with easy coding style like Python. For me, the most weirdest thing is variable/function declaration in Go. as an example, to define a string variable var myname string = "sachith" // function syntax func myfunction() string { return "Hello World" } a bit strange, isnt it? for variable definitions, there is a short method. myname := "sachith" Golang's capabilities and performances are the main attraction fo r this relatively new language. Golang is not considered as an O