Posts

Export enviroment variable in linux

Image
For User & ApplicationThere are actully three files from the linux reads the enviroment variable

/etc/enviromet ~/.profile :~/.bashrc 
If your app depened on the enviroment variable then you have to store that variable inside this files otherwise those variable lost as soon as the terminal exits.

To export enviroment variable permanatly in linux follow this commands :

$ echo export variablename='path/value' >> ~/.profile
This will store the variable in the ~./profile


$ echo export variablename='path/value' >> ~/.bashrc
This will store the variable in the ~./bashrc

Now to make this change working you have to run this commands

$ source ~/.profile 
This will evaluate ~/.profile file

$ source ~/.bashrc
This will evaluate ~/.bashrc file


You can locate this files in you users Home folder


If you want to go GUI way you can find this files in your /home/[user] folder



For CronJob
This will not work if you have to use the enviroment variable in the cron job

If you want to set the…

golang intellij community setup

Image
I have used the phpstorm for 2 years. So intellj platform is now first need for development. There are many options available as golang development ide.
like Sublime and Atom etc.

If you are reading this means i don't have to give reasons why to use intellj for development. ( But if you are not familier with intellj platform you can check it out here. )


Intellj Community Version as Golang IDEI am assuming that you now how to setup the golang on your own spacific platform.
After you setup the golang
you need to download install intellj community version.
( Note that Community version is open source and free while other versions are commercial. Here is the comparision of Intellj Community version with commercial versions )

Here is the spacific link for the intellj communiy verions.
I would sugget to use the link provided here because i have felt early that golang plugin (which is essential to use golang inside the community version) is not compatible with the latest version.
https://www.jetb…

Easy way deploy and manage mysql database to linux server

Let assume that you have setup the linux server with mysql. Now you want to deploy the database to the server you have created on your developement enviroment. 

You development enviroment may be windows or mac or linux with the gui but server are run only cli.

So it is necessary to know the easy way to deploy database to the server with just cli


Importing the mysql database to mysql using the cli
1) Export the sql file of the database from your development enviroment.

2) Copy the sql file to the serve using the sftp.

3) Now import the sql file to you mysql using this comman snippet

    $ mysql -u [username] -p < [path/to/your/sql/file] 
    $ password : [your password ] [will be invisible on screen]
    $ 

After sucessfull import of sql file your database will ready to be used.

Note that if there is any error during the import than it will print the error on the screen but in case of successful import it will not generate any response.


Now to access the database deployed on the server you may…

golang secure api with jwt

Image
For jwt authnetication i am using the dgrijalva/jwt-go package with my golang project. 

First of all fetch packge from repository
go get github.com/dgrijalva/jwt-go

Now you are ready to use the jwt

I am sharing here  my basic code to create secure routes using jwt

Here you can see that we have used jwtcheck function as middleware. It processes the request before passing it forward. If request has a valid jwt token than that request get forwarded to the intended function otherwise that request does not forwarded.
Hope you find it usefull. If you have any question just ask in comments.

Open Source Assets Compiler For Projects

Image
I am from the laravel and actully now habitude to its process. It also reflected on assets ( scss/less/vuejs) compilation. I have tried multiple alternatives like preproce. But at last come to the laravel's built in packages. 


Laravel's Assets Compilers 
1) Laravel Elixir
2) Laravel Mix

Both of the projects are shown here are the gift from the laravel developer to us. By the way this projects are created to work for laravel but you can use this project stand alone for your projects. This projects are npm based so you have to install them using the node package manager ( npm) or yarn.

Some description about both

1) Laravel ElixriLaravel Elixir provides a clean, fluent API for defining basic Gulp tasks for your Laravel application. Elixir supports common CSS and JavaScript pre-processors like Sass and Webpack. Using method chaining, Elixir allows you to fluently define your asset pipeline.

It's documentation says for Laravel Application. But, You can use it for  any project even no…

Host Personal Cloud Torrent on VPS

Image
Host Personal Cloud Torrent 
This is the awesome project i found on the github.com.  projectjpillora/cloud-torrent
What it does is it asks for the torrent or magnet link. After getting the link it downlods the torrent file on the vps and than you can download the file via idm or downloader to your pc from the vps

This project is written in the go and uses go 1.9.1.
If you are a person who don't want the complication of the compilation or cross compilation of this project you can use the file that is precompiled.
here is the link for ubuntu binary cloud-torrent

Make sure to open the port 3000 on the server  for ubuntu to open port 3000 use this command
sudo ufw allow 3000
What you have to do us just copy the compile binary to the vps and open the port 3000 run the binray in background and your cloud torrent vps is ready to go

I am really impressed by this project

403 forbidden you don't have permission to modify this app

Image
Error During the Google App Engine Deployment
You might get this error during  the deployment.



It may be because of your old credentials or invalid credentails has been stored in you local enviroment.



To fix Remove fileWindows <windisk>:\Users\<Username>\.appcfg_oauth2_tokens





Mac Or Linux ~/.appcfg_oauth2_tokens