Sunday, December 27, 2020

Flutter - Setup - Linux Desktop Development

If you have installed flutter from snap previously. Please remove it:

1 sudo snap remove flutter


 For Linux desktop development, you need the following in addition to the Flutter SDK:

  1. Clang

  2. CMake

  3. GTK development headers

  4. Ninja build

  5. pkg-config

  6. libblkid

  7. liblzma

Step 1: Pls install these dependencies using:

1 sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev libblkid-dev liblzma-dev

Also, check for the existence of open jdk 8:

1 2 3 4 $ java -version openjdk version "1.8.0_275" OpenJDK Runtime Environment (build 1.8.0_275-8u275-b01-0ubuntu1~20.04-b01) OpenJDK 64-Bit Server VM (build 25.275-b01, mixed mode)

If Open Jdk is not available install it using:

1 2 sudo apt-get install openjdk-8-jdk sudo update-alternatives --config java

After running “sudo update-alternatives --config java” we have to select the number which contain jdk-8.

Export the environment variable - JAVA_HOME as follows:

1 export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"

Also, add the above line as the last line in the file: ~/.bashrc


Step 2: Change directory to /usr/local:

1 cd /usr/local

Step 3: Get the Flutter repo from Github using the following command:

1 sudo git clone https://github.com/flutter/flutter.git

Step 4: Check the current user using the command:

1 2 $ whoami ubuntu

Since, Our login user is: ubuntu

Step 5: Change the ownership of the flutter repo directory to current user: ubuntu

1 sudo chown -R ubuntu:ubuntu /usr/local/flutter

Step 6: Add the following line to the file ~/.bashrc atthe end of the file

1 2 3 vi ~/.bashrc ### add below line at the end of the file export PATH="$PATH:/usr/local/flutter/bin"

Step 7: Update the Path Variable in the current terminal:

1 export PATH="$PATH:/usr/local/flutter/bin"

Step 8: Change the current branch to master and upgrade:

1 2 flutter channel master flutter upgrade -f

Step 9: Run the following command to see if there are any dependencies you need to install to complete the setup

1 flutter doctor

Step 10: Optionally, pre-download development binaries:

The flutter tool downloads platform-specific development binaries as needed. For scenarios where pre-downloading these artifacts is preferable (for example, in hermetic build environments, or with intermittent network availability), iOS and Android binaries can be downloaded ahead of time by running:

1 flutter precache

Step 11: Enable Linux Deskop

1 2 flutter config --enable-linux-desktop

Step 12: Step a directory to store flutter projects:

1 2 mkdir /opt/flutter-projects/ cd /opt/flutter-projects/

Step 13: Create our first flutter app using the command:

1 2 flutter create myapp cd /opt/flutter-projects/myapp

Step 14: Run our flutter app:

1 2 flutter create . flutter run -d linux


 References:

Tuesday, May 5, 2020

JavaScript - LocalStorage


Methods available by localStorage Instance:


  • localStorage.setItem(key,value)
  • localStorage.getItem(key)
  • localStorage.removeItem(key)
  • localStorage.clear()

Saturday, April 4, 2020

Git - Installation

To install GIT - visit the following link for instructions:
https://git-scm.com/download/

For installation on Linux follow instuctions at the following link:
https://git-scm.com/download/linux

Monday, March 30, 2020

Git - 3 main states of artifact

Modified - Artifact is undergoing user modifications.
Staged - User had marked the modified file to go to the next stage. The is achieved by add command.
Commited - The artificat is safely stored in the local git database. This is acheived by commit command.



Thursday, March 12, 2020

Rust - Install Ubuntu Linux

To Install Rust in Ubuntu. Follow the instructions at the link:
https://www.rust-lang.org/tools/install

Step 1: Run the curl command.

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
info: downloading installer

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

It will add the cargo, rustc, rustup and other commands to
Cargo's bin directory, located at:

  /home/ubuntu/.cargo/bin

This can be modified with the CARGO_HOME environment variable.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /home/ubuntu/.rustup

This can be modified with the RUSTUP_HOME environment variable.

This path will then be added to your PATH environment variable by
modifying the profile file located at:

  /home/ubuntu/.profile

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2020-02-27, rust version 1.41.1 (f3e1a954d 2020-02-24)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
 12.0 MiB /  12.0 MiB (100 %)  11.1 MiB/s in  1s ETA:  0s
info: downloading component 'rust-std'
 17.7 MiB /  17.7 MiB (100 %)  11.2 MiB/s in  1s ETA:  0s
info: downloading component 'rustc'
 58.0 MiB /  58.0 MiB (100 %)  11.2 MiB/s in  5s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 12.0 MiB /  12.0 MiB (100 %)   8.5 MiB/s in  1s ETA:  0s
info: installing component 'rust-std'
info: installing component 'rustc'
 58.0 MiB /  58.0 MiB (100 %)  13.4 MiB/s in  4s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable'

  stable installed - rustc 1.41.1 (f3e1a954d 2020-02-24)


Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH
environment variable. Next time you log in this will be done
automatically.

To configure your current shell run source $HOME/.cargo/env
$

Step 2: Check for Rust:
$ which rustc

Step 3: Since, it resulted in no output. That means Rust compiler is notavailable

Step 4: On running the source command the rust compiler is available.

$ source $HOME/.cargo/env
$ which rustc
/home/mhc/.cargo/bin/rustc

Wednesday, January 22, 2020

Docker - Install nginx


Download, install and start a container running NGINX

$ sudo docker run --detach --name web nginx:latest
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
8ec398bc0356: Pull complete
dfb2a46f8c2c: Pull complete
b65031b6a2a5: Pull complete
Digest: sha256:80a88760216ae16b13d9a9ce0267740d2de3506cbf1cab29072b1532dedd1ecb
Status: Downloaded newer image for nginx:latest
11292f469c3db9b1a1ec66cf46d5133803be823bbd89e91613d39133757436a1



Check if nginx process has started

$ ps aux | head -1; ps aux | grep nginx
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      7632  0.1  0.0  10632  5540 ?        Ss   12:18   0:00 nginx: master process nginx -g daemon off;
systemd+  7691  0.0  0.0  11088  2664 ?        S    12:18   0:00 nginx: worker process







Check Docker running Process:

$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
11292f469c3d        nginx:latest        "nginx -g 'daemon of…"   2 hours ago         Up 2 hours          80/tcp              web