Home Blog

How to Fix WSL Not Starting in Windows: 6 Easy Step-by-Step Solutions

0
WSL not starting in windows fix
WSL not starting in windows fix

If WSL (Windows Subsystem for Linux) is not starting in Windows, try these common fixes:

Video Tutorial:


🔧 1. Restart WSL Services

Open PowerShell as Administrator and run:

wsl --shutdown

Then try starting WSL again:

wsl

🔧 2. Ensure WSL is Installed

Run this in PowerShell:

wsl --list --verbose

If it shows “No installed distributions,” install one:

wsl --install ubuntu

🔧 3. Check Windows Features

Make sure these are enabled:

  • Virtual Machine Platform
  • Windows Subsystem for Linux

You can enable them using PowerShell:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

🔧 4. Update WSL

wsl --update

🔧 5. Reboot Your PC

After making the above changes, restart your system.


🔧 6. Error Message?

If you’re getting a specific error (like 0x8007019e), please share it for a more targeted solution.

Let me know your error message if these steps don’t fix it.

Getting Started with New Relic in Node.js Applications

0
How to Setup newRelic with NodeJS
How to Setup newRelic with NodeJS

Introduction to New Relic

For developers working with app building, New Relic is an essential tool that is been used for monitoring application performance. It gives you information on how well your application is performing like metrics, Logs, Traces & Alerts, which makes it easier to find & fix problems or issues in the Application.
The steps required for implementing New Relic into your Node.js application will be guided to you in this article.

Installing the New Relic Agent in Node Project

Assuming that you already have or know how to create a NodeJS Project.
To start using New Relic in Node.js, the first step is installing the New Relic Node.js agent or the package. You can do this easily install it by using npm install command as below. In your terminal, navigate to your project directory and run the following command:

npm install newrelic --save

Running the above command will add the New Relic package to your NodeJS project.

How to get NewRelic License Key

  1. Sign-In into newRelic
  2. Select the Platform or Framework or Language, In our case NodeJS
  3. Create a new Key.

how to get newrelic license key
how to get newrelic license key

Once you have successfully installed newrelic package, we need to configure the New Relic agent. In your project, create a file named newrelic.js at the root level. In this file, you’ll need to include your New Relic license key, which you can find in your New Relic account. Please check the video for quick understanding.

Basic Configuration of newRelic

Here’s a basic configuration example in newrelic.js file:

exports.config = {
    app_name: ['Application Service Name'],  // Replace with your app name
    license_key: 'YOUR_LICENSE_KEY',  // Replace with your New Relic license key
    logging: {
      level: 'info'  // You can adjust this level based on your needs (e.g., 'debug', 'info', 'warn', 'error')
    }
  };

Import the newRelic

Now we need to import it at the start on our nodejs i.e. we need to ensure that this file is included at the very top of your main application file (e.g., app.js) before any other require statements.

newRelic import statement

My Project Statement

newrelic project structure

Verifying Monitoring

To confirm that the monitoring is active, start your Node.js application and look for logs indicating that New Relic is initialized. You should see an entry in your New Relic dashboard shortly after your application begins running.

nodejs newrelic connected successfully
nodejs newrelic connected successfullly

That’s it! You have successfully set up New Relic in your Node.js application.

Mastering Docker: A Guide to Containerization & Basic Docker Commands

0
Mastering Docker: A Guide to Containerization & Commands' with a blue and white tech-inspired design, featuring the Docker whale logo, a container ship, and abstract cloud computing elements.
Mastering Docker: A Guide to Containerization & Commands' with a blue and white tech-inspired design, featuring the Docker whale logo, a container ship, and abstract cloud computing elements.

Introduction to Docker, What is Docker?

Docker is an environment which a advanced system that allows developers to do most of the deployment work automate and can easily help in , scaling, and maintenance of applications via containerisation. Unlike typical virtual machines, Docker containers offer lightweight, portable, and efficient environments that include everything required to run applications across different computers or servers.

Key Components of Docker

  1. Containers: A containerised system is Docker’s core unit, packaging a program and its dependencies to ensure consistency across development, testing, and production environments.
  2. Images: Docker images are lightweight, independent, executable bundles that contain everything required for running a container, including code, runtime, libraries, and configurations.
  3. Engine: Docker Engine is a service that executes and manages containers on an operating machine.
  4. Hub: Docker Hub is a cloud-based hub where all the developer can collaborate & distribute container images.
  5. Compose: In Docker Compose is a tool for creating and controlling multi-container Docker applications using a simple YAML configuration file.

Managing Docker Containers – Basic Docker Command’s

Starting, Stopping, and Removing Containers

  • Start a container: docker start <container_id>
  • Stop a container: docker stop <container_id>
  • Remove a container: docker rm <container_id>

Running a Simple Container

To verify Docker installation, use:

docker run hello-world

Accessing a Running Container’s Shell

docker exec -it <container_id> bash

Understanding Container Lifecycle

  1. Created: The container exists but has not started.
  2. Running: The container is actively executing processes.
  3. Paused: The container’s processes are temporarily suspended.
  4. Stopped: The container has been terminated.
  5. Deleted: The container is removed from the system.

Lifecycle Management Commands

  • Pause a container: docker pause <container_id>
  • Unpause a container: docker unpause <container_id>
  • Restart a container: docker restart <container_id>

Monitoring Containers

List all running and stopped containers:

docker ps -a

Managing Persistent Data with Docker Volumes

What are Docker Volumes?

Docker volumes allow data to persist beyond the container lifecycle. They store data in a dedicated directory on the host system.

Creating and Managing Volumes

  • Create a volume: docker volume create my_volume
  • List available volumes: docker volume ls
  • Inspect a volume: docker volume inspect my_volume

Using Volumes in Containers

To mount a volume:

docker run -d --name my_container -v my_volume:/app/data my_image

Bind Mounts vs. Docker Volumes

  • Bind Mounts: Directly map host directories to containers.
  • Docker Volumes: Managed by Docker and stored in /var/lib/docker/volumes.

Example Use Cases

  • Bind Mounts: Ideal for development environments requiring immediate code changes.
  • Docker Volumes: Best for persistent database storage and data sharing across containers.

Backing Up and Restoring Volumes

  • Backup a volume: docker run --rm -v my_volume:/volume -v $(pwd):/backup busybox tar cvf /backup/backup.tar /volume
  • Restore a volume: docker run --rm -v my_volume:/volume -v $(pwd):/backup busybox tar xvf /backup/backup.tar -C /volume

Writing Dockerfiles

Simple Dockerfile Example

FROM ubuntu:latest
RUN apt-get update && apt-get install -y python3
COPY . /app
WORKDIR /app
CMD ["python3", "app.py"]

Multi-Stage Build Dockerfile

FROM node:14 AS build
WORKDIR /app
COPY . .
RUN npm install && npm run build

FROM nginx:alpine
COPY --from=build /app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

Conclusion

Docker is a game-changer in application deployment, offering portability, efficiency, and scalability. By mastering Docker containers, volumes, and lifecycle management, developers can streamline workflows and optimize their applications for cloud and on-premise environments.

Understanding Docker: A Modern Approach to Containerization

0
A modern and visually appealing image about Docker. The design should include a blue and white color scheme, featuring the Docker whale logo
A modern and visually appealing image about Docker. The design should include a blue and white color scheme, featuring the Docker whale logo

Introduction to Docker

Docker is an environment which a advanced system that allows developers to do most of the deployment work automate and can easily help in , scaling, and maintenance of applications via containerisation. Unlike typical virtual machines, Docker containers offer lightweight, portable, and efficient environments that include everything required to run applications across different computers or servers.

Key Components of Docker

  1. Containers: A containerised system is Docker’s core unit, packaging a program and its dependencies to ensure consistency across development, testing, and production environments.
  2. Images: Docker images are lightweight, independent, executable bundles that contain everything required for running a container, including code, runtime, libraries, and configurations.
  3. Engine: Docker Engine is a service that executes and manages containers on an operating machine.
  4. Hub: Docker Hub is a cloud-based hub where all the developer can collaborate & distribute container images.
  5. Compose: In Docker Compose is a tool for creating and controlling multi-container Docker applications using a simple YAML configuration file.

Benefits of Using Docker Container

  • Portability: Containers can easily be used and any OS it basically removed the problem of machine dependencies
  • Efficiency: Optimizes resource utilization by leveraging the host OS kernel, consuming fewer resources than traditional VMs.
  • Scalability: Easily scale applications up or down in response to changing demand.
  • Faster Deployment: Reduces the time necessary to set up development and production environments..

Docker and Popular Technologies

Docker integrates with various technologies such as:

  • Two well-known Linux distributions that are frequently used as container bases are Debian and Ubuntu.
  • Two popular application frameworks that function well in Dockerized environments are Tomcat and PHP.
  • MySQL and Java are frequently used in containerised microservices systems together.
  • Alpine Linux: A compact Linux distribution that’s suitable for security-conscious and minimalist containers.

Conclusion

Docker revolutionised software development by providing a consistent and scalable platform for application deployment. Whether you’re using PHP, Java, MySQL, or cloud-based services, Docker streamlines workflows, improves collaboration, and boosts performance. The use of Docker in modern software engineering offers efficiency, flexibility, and strong application administration.

How to Add Dependencies in Flutter

0
Add Dependencies in Flutter
Add Dependencies in Flutter

As you all know the Flutter is a powerful framework using which we can build cross-platform applications for Mobile/Web. When a popular frameworks comes to the Technical market the ability to integrate third-party packages or dependencies becomes easily & al to enhance functionality.

Hi Guy’s Welcome to Proto Coders Point. In this Article, Let’s us talk and make you walk through the process how easily it is adding dependencies in Flutter, managing versions, and updating them properly.


What are Dependencies in Flutter?

So Dependencies in Flutter are basically a pre-defined code of code or an external packages also called as libraries that a developer can freely use and add functionalities to an up coming app. These packages are freely available on pub.dev website, which is the official package manager for Dart and Flutter.

Just by download and using dependencies, you can easily make use of freely features like:

  • Networking (e.g., HTTP requests)
  • State management (e.g., Provider, Riverpod, Bloc)
  • UI components (e.g., animations, charts)
  • Database and storage (e.g., SQLite, Firebase)

    This is just an example, In pub.dev there are lots of package that published by just like us developer.

Steps to Add a Dependency in Flutter

1. Open pubspec.yaml

In root directory of your flutter project there should be a file by name: pubspec.yaml that is metadata or information of flutter app it also contain dependencies that are used by the project. You need to add your dependencies here.

2. Search for a Package

Visit pub.dev & search for the package you are interested in. For example, let say I want to make a HTTP call for that I need http dependencies for making API requests, in pub.dev search for http.

flutter http dependencies

Here go to Installing tab.

3. Add the Dependency

Once you find the package in our case it http, copy the dependency line (http: ^0.13.6 ) from the installation section & paste it in your flutter project under the dependencies: section in pubspec.yaml just like shown below.

Example:

dependencies:
  flutter:
    sdk: flutter
  http: ^0.13.6

4. Run flutter pub get

Now once you added the required dependency you need to run a command in the terminal to fetch/download the package make sure you are connected to internet:

flutter pub get

by running above command it will downloads all the listed dependencies in our case it only one i.e. http and then makes it available for use in your project.

5. Import & use the Package

Then Now, once your required dependencies is successfully downloaded, you can use it by just importing the package in your Dart file where required.

Example:

import 'package:http/http.dart' as http;

void fetchData() async {
  var response = await http.get(Uri.parse('https://jsonplaceholder.typicode.com/posts'));
  print(response.body);
}

Managing Dependency Versions

In some situation you might need a specify dependency versions:

  1. Specific Version: http: 0.13.6 This installs the exact version.
  2. Caret Syntax (^): http: ^0.13.6 This installs the latest compatible version within 0.x.y.
  3. Latest Version (any): http: any This installs the latest available version.
  4. Git Dependencies: dependencies: my_package: git: url: https://github.com/username/repository.git This fetches a package from a Git repository.
  5. Path Dependencies: dependencies: my_local_package: path: ../my_local_package This is useful for local packages.

How to update the flutter Dependencies

It’s very easily to update the flutter dependencies, just run upgrade command as below:

flutter pub upgrade

To check outdated dependencies, run command outdated:

flutter pub outdated

To update a specific dependency, just check the dependencies version from pub.dev and then modify pubspec.yaml then run:

flutter pub get

Removing Dependencies

If you no longer need a package and want to completely delete it from the flutter project, follow below steps:

  1. Remove the dependency from pubspec.yaml.
  2. Run: flutter pub get This removes the package from the project.

How to store data locally in Flutter – 5 Ways

0
5 Ways to Store Data in Flutter App Offline/Locally
5 Ways to Store Data in Flutter App Offline/Locally

Hi Guys, Welcome to Proto Coders Point. In this article on Flutter Dart let us know all the ways by which we can store data offline locally in Flutter App itself. Let’s get Started.

There are n number of scenarios where the best practice is storing data locally on users devices rather than relying on remote cloud servers or APIs, if we store frequently used data from API call then it can also lead to increase server cost, so it’s better to store as a cache into local database in flutter app . For Example, your flutter app might want to store data between app sessions or download a language dictionary from the internet for offline access.

Flutter SQLite

SQLite is a lightweight, fast, self-contained, and reliable SQL database engine written in C. It is embedded in all mobile devices and is commonly included in many applications used daily.

For beginners, SQLite queries might seem complex, but it simplifies operations like INSERT, READ, UPDATE, and DELETE basicallyt using SQLite we can perform CRUD operation locally in mobile devices.

Key Note:

Flutter SQLite library is very small, I means the The library size (engine that runs SQLite) is 400–500 KB and the data storage capacity depends on the memory size the mobile device is allocated.

Example of Flutter SQLite

In Futter, We have a package/Plugin using which you can work with SQLite DB i.e. sqflite


Hive Database in flutter

Hive Database is built using pure DART language, Hive DB is a lightweight & fast key-value NOSQL Database. Which is similar to MongoDB, HIVE DB can be used as best alternative of SQLite Database.

To make use of HIVE Database in Flutter we must download 2 package Hive & hive_flutter

More Implementation details you can check the article: Link

Hive make use of box in which we can store the data we need by using put or get method

Example:

var box = Hive.box('myBox'); // Create a box
box.put('name', 'Rajat'); // store the data in key-value pair
var name = box.get('name');  //retrive the data using get by passing key
print('Name: $name'); // Rajat

Shared Preferences Storage in flutter

Shared Preferences is the most widely used plugin as a simple storage medium. It make use of NSUserDefaults on iOS and macOS and SharedPreferences on Android. While data can be saved to disk asynchronously, it is not guaranteed that writes will persist immediately.

Shared Preferences is best to use for non-critical data storage, may be to keep user logged into the app, user settings or small key-value pairs.

Syntax Example:

SharedPreferences prefs = await SharedPreferences.getInstance();

// Reading data
String name = prefs.getString('name');
   
// Updating
await prefs.setString('name', 'Some Value');

Read our Tutorial about how to use Shared Preferences in Flutter App

Flutter Sharedpreferences Alternative | GetX Storage | keep user loggedIn
Shared preferences to keep user logged in flutter app


ObjectBox in flutter

ObjectBox is basically a dart-native key-value database, which is some what similar to Hive. It is designed for speed query , enhancing the data response times and ObjectBox also supporting real-time applications. In Flutter Dart ObjectBox Highly compatible with OS like: Android, iOS, macOS, Linux, and Windows, offering built-in support for object links and relationships.

Although it delivers excellent performance, But as ObjectBox is still new in database market it required time to mature and prove its reliability in large-scale projects.

A Quick Example on ObjectBox in Flutter Dart:

@Entity()
class PersonData {
  int id;

  String firstName;
  String lastName;

  PersonData({this.id = 0, required this.firstName, required this.lastName});
}

final store = await openStore(); 
final box = store.box<PersonData>();  // Creation on ObjectBox Box

var personObj = PersonData(firstName: 'John', lastName: 'Doe');

final id = box.put(personObj );  // Create

personObj = box.get(id)!;       // Read or simple get the data stored in Object

personObj .lastName = "Doe Doe Doe";
box.put(personObj );             // Update the lastname

box.remove(personObj .id);  

Realm Database in flutter

Realm is an open-source free to use Database, mobile-first database designed to store offline data persistence in Flutter applications. Developed by the same company behind MongoDB, Realm in Flutter offers a NoSQL key-value structure, making it a powerful tool for mobile app development.

To add Realm to your Flutter project, simply run:

flutter pub add realm

Here is an Example on Realm is object-oriented data model, The Data Structure is Data Model is Defined as below:

import 'package:realm/realm.dart';  
part 'app.g.dart'; 

// define a data model class named _User
@RealmModel() 
  class _User {
    late String emal;

    late String name;

    int? age = 18;
}

Then you need to generate a RealMObject Class, To do that just run execute below command:

flutter pub run realm generate

Then now you can create and save the new user into your RealM Database as below:

var config = Configuration.local([User.schema]);
var realm = Realm(config);

var userOne = User("hello@kindacode.com", "Mr. Hello", age: 100);
  realm.write(() {
    realm.add(userOne);
});

Consultion

In this article we check different way by which we can store data locally/Offline into Mobile device using Mobile Storage.