Get me outta here!

Thursday, February 6, 2025

Process for updating Edmx on Entity Framework

  • Update in Dto
  • Update in Main Table
  • Add Scalar Property in Edmx Table
  • Open Edmx in xml format and add the property
  • Then go to table mappings and map the added field

Monday, September 9, 2024

Auth-Session Vs JWT

 


Monday, August 19, 2024

Class/Record/Struct

 

FeatureClassRecordStruct
TypeReference TypeReference Type (since C# 10, can be record struct)Value Type
Memory AllocationTypically allocated on the heap.Typically allocated on the heap.Typically allocated on the stack (or heap if used as part of a class or array)
Default ConstructorCan have a parameterless constructor, and can be explicitly defined.Implicit parameterless constructor is not allowed; parameters are required.Parameterless constructor is provided by default and initializes all fields to default values.
InheritanceSupports inheritance (can inherit from other classes and be inherited).Supports inheritance (can inherit from other records but not from classes).Does not support inheritance (cannot inherit from or be inherited by other types).
EqualityUses reference equality by default, can override Equals and GetHashCode for value-based equality.Uses value-based equality by default (based on all properties). Automatically implements Equals, GetHashCode, and ToString.Uses value-based equality by default (based on all fields). Automatically implements Equals, GetHashCode, and ToString.
MutabilityMutable by default; properties can be changed after object creation.Immutable by default; properties are readonly and set via constructor.Immutable by default (properties are typically readonly and initialized in the constructor).
DeconstructionNot supported by default.Supports deconstruction with tuple-like syntax.Supports deconstruction with tuple-like syntax.
ConstructorCan have multiple constructors with various parameters.Primary constructor is defined with positional parameters; can also have additional constructors.Constructor must initialize all fields; no parameterless constructor allowed unless provided by the compiler.
Default ValuesFields initialized to default values if not explicitly set.Properties are initialized via the constructor.Fields are initialized to default values (e.g., 0, null).
Use CasesUsed for complex objects with behavior and mutable state.Ideal for immutable data models, DTOs, and scenarios where value-based equality is important.Ideal for lightweight, immutable data structures where copying and stack allocation are beneficial.

Friday, May 17, 2024

Angular Basics

Intro

    package.json

     (list of dependencies)

    package-lock.json

     (details list of that dependencies)

    angular.json

     (map everything here: assets, scripts etc)

    tsconfig.json

     (typescript configuration file)

    polyfills.ts

     (compatibility file)

 

Components

    Modules must be declared in the imports

    Components must be declared in the declarations

    Standalone components are not dependent in any modules and it must be declared in imports

    and Pipes are doing the transformation over text


Bindings - Two Way, Property, Event


Routing

    Basic Routing

      Routes for mapping path & component

      routerLink navigate to different routes

      router-outlet for displaying matched route

    Child routing

     Activated Route (const routeId = route.snapshot.paramMap.get(id);)

    Module Routing

     const routes : Routes

    Lazy Loading

     Load when required (loadChildren then import)


Directives

    Add additional behavior to elements

    Components works as a directive

    Attribute Directive

ngClass (Binding Classes)

ngStyle (Binding Styles, Only accept objects s = {})

ngModel (Two Way Binding)

    Structural Directive

*ngIf

*ngFor

*ngSwitch


Services

    Defined with @Injectable

    All are in observable format and without subscribe it wont work (Rxjs feature)


FormType

    TDF handle in html file

     ngForm

    Reactive handle in ts file

     FormGroup


Guard

    used to control access in particular route

    canActivate

    canActivateChild

    canDeactivate

    canLoad


Interceptor

    Used for token login

    Declares in app.module [Providers]


Rxjs

    Observable and Operators

    Promise (then, then, finally)    

Monday, March 4, 2024

Reactive Programming

🔎Definition---

JavaScript Promises are objects used to represent the eventual completion (or failure) of an asynchronous operation. They are widely used in modern JavaScript to handle asynchronous tasks in a more readable and manageable way, compared to traditional callback-based approaches. A Promise can be in one of three states:
Pending: Initial state, neither fulfilled nor rejected.
Fulfilled: The operation completed successfully.
Rejected: The operation failed.

On the other hand, RxJS (Reactive Extensions for JavaScript) is a library for reactive programming using observables. An observable represents a stream of data that can be observed over time. It provides powerful tools for handling asynchronous and event-based programming.

🔩Conversion---

Converting a Promise to an Observable is a common operation in RxJS when integrating with libraries or APIs that return Promises. RxJS provides the from function to convert various data sources, including Promises, into Observables.

Converting an Observable to a Promise is useful when you need to work with Promise-based APIs or when you want to consume Observables in a Promise-based context. RxJS provides the toPromise() operator to convert an Observable into a Promise.

🔚Conclusion---

Promises are simpler and more straightforward for handling single asynchronous operations that produce a single value or error.

Observables are more powerful and suitable for handling multiple asynchronous values over time, supporting cancellation, and offering a wide range of operators for transforming and combining streams of data. When you promise you can't cancel and for cancelling you have to use another library. But you can Unsubscribe to cancel in observables. Also you have to unsubscribe every time that means writing same code couple of times when working on a  big project but in Promises it will go on rejected state.

Saturday, June 10, 2023

Run React Globally

 If you have problems running create-react-app in text editors but the package is installed globally. So here is the SOLUTION-------------

  1. Open PowerShell as an administrator. You can do this by right-clicking on the Windows Start button and selecting "Windows PowerShell (Admin)".

  2. In the PowerShell window, run the following command to check the current execution policy:

    powershell
    Get-ExecutionPolicy
  3. The output will be one of the following:

    • Restricted: This means that script execution is disabled. You need to change it to a more permissive policy.
    • AllSigned or RemoteSigned: These policies allow script execution but require digitally signed scripts. If you encounter this, you can skip changing the execution policy and try using the npx create-react-app command instead of create-react-app.
  4. To change the execution policy to allow script execution, run the following command:

    powershell
    Set-ExecutionPolicy Unrestricted
  5. You will be prompted to confirm the change. Type Y and press Enter.

  6. After changing the execution policy, you should be able to use the create-react-app command without encountering the "running scripts is disabled" error.

  7. Once you've finished using create-react-app, it's recommended to set the execution policy back to a more secure value. Run the following command:

    powershell
    Set-ExecutionPolicy Restricted

By following these steps, you should be able to resolve the script execution error and use create-react-app globally in any text editor.

Sunday, May 7, 2023

Logical Shifting COA

 

SHR stands for "Shift Right" and it is used to shift the bits in a register or memory location to the right. When a number is shifted to the right using SHR, the least significant bit (LSB) is replaced by a zero, and the most significant bit (MSB) is shifted out and lost. The other bits are shifted to the right by the specified number of positions. For example, the instruction "SHR AL, 1" will shift the bits in the AL register to the right by 1 position. SAR stands for "Shift Arithmetic Right" and it is used to shift the bits in a register or memory location to the right while preserving the sign bit. When a number is shifted to the right using SAR, the least significant bit (LSB) is replaced by a zero, and the most significant bit (MSB) is shifted out and lost. However, unlike SHR, SAR preserves the sign bit by shifting it into the vacated MSB position. This ensures that the sign of the number is preserved after the shift. For example, the instruction "SAR BL, 1" will shift the bits in the BL register to the right by 1 position while preserving the sign bit.

SHL stands for "Shift Left" and it is used to shift the bits in a register or memory location to the left. When a number is shifted to the left using SHL, the most significant bit (MSB) is replaced by a zero, and the least significant bit (LSB) is shifted out and lost. The other bits are shifted to the left by the specified number of positions. For example, the instruction "SHL AX, 1" will shift the bits in the AX register to the left by 1 position. SAL stands for "Shift Arithmetic Left" and it is also used to shift the bits in a register or memory location to the left. The operation performed by SAL is identical to SHL, and both instructions can be used interchangeably. The only difference is that the Intel documentation recommends using SAL when performing arithmetic shifts, to emphasize that the sign bit is shifted along with the other bits. IN summary, the main difference between SHL and SAL is that SHL performs a logical shift, while SAL performs an arithmetic shift. However, in practice, the two instructions are identical and can be used interchangeably for left shifts.

ROL: The ROL instruction performs a left rotation of the bits in a register or memory location. Each bit is shifted one position to the left, with the carry flag being shifted into the least significant bit (LSB) and the most significant bit (MSB) being shifted into the carry flag. This effectively shifts all bits one position to the left, including the carry flag. For example, the instruction "ROL AL, 1" will rotate the bits in the AL register one position to the left.• ROR: The ROR instruction performs a right rotation of the bits in a register or memory location. Each bit is shifted one position to the right, with the carry flag being shifted into the most significant bit (MSB) and the least significant bit (LSB) being shifted into the carry flag. This effectively shifts all bits one position to the right, including the carry flag. For example, the instruction "ROR BH, 1" will rotate the bits in the BH register one position to the right. Both ROL and ROR are circular shifts, which means that the shifted bits are rotated around to the opposite end of the register or memory location. The carry flag plays a key role in this operation, as it is shifted into the least significant bit (LSB) during a left rotation and into the most significant bit (MSB) during a right rotation.



Some COA Summaries

 
















Thursday, March 2, 2023

How to Absorb Books

 


  • [1] Flip through each page
  • [2] End of chapter-looking for question
  • [3] Read the bold prints
  • [4] First and last sentence of each paragraph
  • [5] Then start reading

Tuesday, January 3, 2023

Python Libraries

 






Saturday, September 24, 2022

Microprocessor, Microcontroller & Embedded Systems

 microcontroller is a small computer on a single integrated circuit chip. A microcontroller typically contains one or more processor cores, along with additional peripherals (memory, serial interface, timer, programmable I/O peripherals, etc.) on the same chip.

microprocessor is a computer processor that incorporates the functions of a central processing unit (CPU) onto just a few (and often only one) integrated circuits. 

Microprocessor and Microcontroller Architecture Explained

Microprocessors and microcontrollers perform relatively similar functions, but if we look specifically at the architecture of each type of chip, we'll see just how different they are.

The defining characteristic of a microcontroller is that it incorporates all of the necessary computing components onto a single chip. The CPU, memory, interrupt controls, timer, serial ports, bus controls, I/O peripheral ports, and any other necessary components are all present on the same chip and no external circuits are required. 

In contrast, a microprocessor consists of a CPU and several supporting chips that supply the memory, serial interface, inputs and outputs, timers, and other necessary components. Many sources indicate that the terms "microprocessor" and "CPU" are essentially synonymous, but you may also come across microprocessor architectural diagrams that depict the CPU as a component of the microprocessor.  You can think of a microprocessor as a single integrated circuit chip that contains a CPU. That chip can connect to other external peripherals such as a control bus or data bus that provide binary data inputs and receive outputs from the microprocessor (also in binary).

The key difference here is that microcontrollers are self-contained. All of the necessary computing peripherals are internal to the chip, where microprocessors deal with external peripherals. As we'll soon see, each of these architectures has its own unique advantages and disadvantages.

Microprocessor and Microcontroller Applications Explained

Microprocessors and microcontrollers are both ways of implementing CPUs in computing. So far we've learned that microcontrollers integrate the CPU onto the chip with several other peripherals, while a microprocessor consists of a CPU with wired connections to other supporting chips. While there may be some overlap, microprocessors and microcontrollers have relatively separate and distinct applications. 

Microprocessors depend on interfacing a number of additional chips to form a microcomputer system. They are often used in personal computers where users require powerful, high-speed processors with versatile capabilities that support a range of computing applications. The use of external peripherals with microprocessors means that components can be upgraded easily - for example, a user might replace their RAM chip to benefit from additional memory. 

Programmable microcontrollers contain all of the components of a microcomputer system on a single chip that runs at low power and performs a dedicated operation. Microcontrollers are most commonly used in embedded systems applications where devices are expected to execute basic functions reliably and without human interference for extended periods of time.

Three Key Differences Between Microcontrollers and Microprocessors

Cost

Generally speaking, microcontrollers tend to cost less than microprocessors. Microprocessors are typically manufactured for use with more expensive devices that will leverage external peripherals to drive performance. They are also significantly more complex, as they are meant to perform a variety of computational tasks while microcontrollers usually perform a dedicated function. This is another reason why microprocessors require a robust external memory source - to support more complex computational tasks.

With a microcontroller, engineers write and compile the code intended for the specific application and upload it into the microcontroller, which internally houses all of the necessary computing features and components to execute the code. Due to their narrow individual applications, microcontrollers frequently require less memory, less computing power, and less overall complexity than microprocessors, hence the lower cost.

Speed

When it comes to overall clock speed, there is a significant difference between industry-leading microprocessor chips and high-quality microcontrollers. This relates back to the idea that microcontrollers are meant to handle a specific task or application, while a microprocessor is meant for more complex, robust, and unpredictable computing tasks. 

One of the key design advantages associated with microcontrollers is that they can be optimized to run the code for a specific task. That means using just the right amount of speed and power to get the job done - no more and no less. As a result, many microprocessors are clocking speeds of up to 4 GHz while microcontrollers can operate with much lower speeds of 200 MHz or less.

At the same time, the close proximity of on-chip components can help microcontrollers perform functions quickly despite their slower clock speed. Microprocessors can sometimes operate more slowly because of their dependence on communicating with external peripherals.

Power Consumption

One of the key advantages associated with microcontrollers is their low power consumption. A computer processor that performs a dedicated task requires less speed, and therefore less power, than a processor with robust computational capacity. Power consumption plays an important role in implementation design: a processor that consumes a lot of power may need to be plugged in or supported by an external power supply, whereas a processor that consumes limited power could be powered for a long time by just a small battery. 

For tasks that require low computational power, it can be much more cost effective to implement a microcontroller versus a microprocessor that consumes much more power for the same output.

Embedded Systems and Microcontrollers

Microcontrollers include many features that make them suitable for application in embedded systems:

  • They are self-contained, including all of the necessary peripherals on a single integrated circuit chip
  • They are designed to run a single dedicated application
  • They can be optimized (software and hardware) for a single dedicated application
  • They exhibit low power consumption and may include power-saving features, making them ideal for applications that require the processor to function for long periods of time without human interference
  • They are relatively inexpensive when compared to CPUs, mainly because the entire system exists on a single chip

While microprocessors may be more powerful, that additional power comes at a cost that makes microprocessors less desirable for embedded systems applications: larger size, more power consumption, and greater cost.


How Do Embedded Systems Work?

An embedded system is a hardware-and-software system that performs a dedicated function within a larger mechanical or electrical system. Embedded systems are typically designed to deal with real-time computing constraints, and are controlled by a real-time operating system (RTOS) that can process data as soon as it is received without buffer delays. Most embedded systems today are based on programmable microcontrollers, small computers with integrated memory housed on a single integrated circuit. We can think of embedded systems as having three main components: the hardware component, the software component, and the real-time operating system.

Embedded Systems Hardware

Embedded systems are small embedded computers that live inside other mechanical or electrical systems. Embedded systems can be programmed to fulfill a variety of functions, but each one must include the basic components of a computer:

  • Processor - Embedded systems are built around a microprocessor or microcontroller. Microcontrollers include one or more processors (CPUs), along with integrated memory and programmable input/output peripherals. Most automatically controlled products or devices use microcontrollers , including office machines, power tools, and automobile engine control systems.
  • Power Supply - Embedded systems have significantly lower power requirements than a standard computer due to their small size and comparatively low processing power. Embedded engineers should choose a power supply that offers a stable and smooth output of power to the microcontroller with adequate output current to drive the load and stable performance in a variety of environments.
  • Memory - If an embedded system is powered by a microcontroller, the system's memory is already available on the chip. If using a microprocessor, a memory chip should be added to the system. Embedded systems use read-only memory (ROM) to store the software program used to operate the microcontroller and random access memory (RAM) to temporarily store data that is received or in-use by the system.
  • Communication Ports - Embedded systems use wired communications to transmit data between the microcontroller, peripheral devices, and other embedded systems. Engineers must select a communication protocol to facilitate this data exchange, ensuring that devices in the system are all "speaking the same language" when they communicate or transmit data. Common communication protocols for embedded systems include the I2C protocol, SPI protocol, and the USB protocol, but there are many other wired and wireless protocols available for engineers to choose from.

Embedded Systems Software and RTOS

Programming for embedded systems is most frequently done using C, C++, the Embedded C language or assembly language. The software programming for embedded systems, including the RTOS, resides in the memory chip and can be accessed whenever the power supply for the system is activated. Unlike standard computers, embedded systems are designed to carry out a specific task or function rather than for "general use". As such, embedded systems software is highly specific to each application of embedded systems.

Embedded Systems Applications Today

Embedded systems impact everyday life in so many ways, we may not always realize the number of devices in our immediate surroundings that are controlled by embedded systems. Let's take a brief inventory of some of the most important embedded systems applications and areas of innovation today.

Embedded Systems in Communications

Cellular phones are some of the most accessible examples of embedded systems that we interact with on a daily basis. Mobile phones contain all of the characteristic components of an embedded system: a power supply, some memory or storage, a processor, and ports for communicating with other devices. Mobile phones also contain additional hardware that supports utilities like audio, cameras, internet connectivity, touch screen and calling.

Like other embedded systems, your mobile phone uses a defined communication protocol to facilitate data transactions between the microcontroller or processor and peripheral devices that collect data.

Embedded Systems in Consumer Electronics

Embedded systems are finding their way into many categories of consumer electronics, including home security systems, home appliances, printers, watches, and more. Home appliances like refrigerators, microwave ovens and washing machines use simple embedded systems to provide features, collect input from users, and control the appliance according to user specifications. They may even use some sensors to collect information about how the appliance is functioning and modify settings accordingly.

Home security systems use embedded systems with peripheral sensors to collect information about activity in and around the home and either initiate a response (alarm) or communicate that data to the homeowner.

Embedded Systems in Automotive Applications

All cars manufactured today contain at least one computer that works to measure and minimize engine emissions throughout the operational life of the vehicle. This embedded computer collects data from a variety of peripheral sensor devices, including oxygen sensors, air pressure sensors, air temperature sensors, and the engine temperature sensor. The computer can use data from these sensors to measure the cleanliness of engine emissions and control the fuel injectors, spark plugs and other variables to optimize for engine performance while minimizing environmental impact.

Most vehicles have additional embedded systems that control things like automatic transmission, anti-lock braking systems, air bags, key-less entry or security systems, audio devices and safety applications like lane drift detection.

Embedded Systems in Healthcare

Embedded systems are used in medical scanning machines, imaging systems, and diagnostic equipment. Some of the most commonly used medical imaging devices, such as CT scanners, MRI machines, and Sonography equipment used to conduct ultrasound imaging are built around and controlled by embedded systems. Digital flow sensors used to monitor respiration, heart monitoring machines, and simple diagnostic machines that test for blood pressure or glucose content also use embedded systems.

The expansion of the Internet of Things (IoT) is leading to new trends in embedded systems for healthcare. In the future, patients will use wearable devices to track their vital signs with data regularly transmitted to their hospital or physician in real time. There will be no shortage of product development opportunities for embedded systems engineers that can use their skills to lower healthcare costs or improve access for patients.

The Future of Embedded Systems

Embedded systems are a major area of innovation that is expected to grow substantially on a per-year basis. Across industries, embedded systems engineers are deploying new products and technologies to increase safety and reduce costs.

In the automotive sector, we're seeing major technological growth in embedded systems as major manufacturers partner with leading technology companies to develop self-driving vehicles. The market for wearable medical devices is expanding rapidly, with an estimated growth rate of 18.5% through 2023. There is also a growing demand for "smart" home appliances and devices that can reduce energy consumption while offering convenience and features for homeowners.

Summary


Ultimately, microcontrollers and microprocessors are different ways of organizing and optimizing a computing system based on a CPU. While a microcontroller puts the CPU and all peripherals onto the same chip, a microprocessor houses a more powerful CPU on a single chip that connects to external peripherals. Microcontrollers are optimized to perform a dedicated low-power application - ideal for embedded systems - while microprocessors are more useful for general computing applications that require more complex and versatile computing operations.

The growing demand for "smart" devices across industries is creating a major area of opportunity for embedded systems engineers to develop their capabilities and launch new products. Embedded systems consist of a microcontroller with on-board memory, a power supply, and communication ports for transmitting data to other devices. Embedded software programs tell the microcontroller how to respond in real time to data collected from the environment through peripheral sensors and devices. Embedded systems are used to enhance safety, reduce costs, and offer convenience and cost-savings to customers in industries that include automotive, home/consumer electronics, communications, and healthcare.

Differences Between Arduino and Raspberry Pi

No.ArduinoRaspberry Pi
1.Control unit of Arduino is from Atmega family.While control unit of Raspberry Pi is from ARM family.
2.Arduino is based on a microcontroller.While Raspberry Pi is based on a microprocessor.
3.It is designed to control the electrical components connected to the circuit board in a system.While Raspberry Pi computes data and produces valuable outputs, and controls components in a system based on the outcome of its computation.
4.Arduino boards have a simple hardware and software structure.While Raspberry Pi boards have a complex architecture of hardware and software.
5.CPU architecture: 8 bit.CPU architecture: 64 bit.
6.It uses very less RAM, 2 kB.While Raspberry Pi requires more RAM, 1 GB.
7.It clocks a processing speed of 16 MHz.While Raspberry Pi clocks a processing speed of 1.4 GHz.
8.It is cheaper in cost.While Raspberry Pi is expensive.
9.It has a higher I/O current drive strength.While Raspberry Pi has a lower I/O current drive strength.
10.It consumes about 200 MW of power.While it consumes about 700 MW of power.
11.Its logic level is 5V.Its logic level is 3V.
12.It does not have internet support.It has inbuilt Ethernet port and WiFi support.
13.It has higher current drive strength.It has lower current drive strength.
14.Some of the applications of Arduino are traffic light countdown timer , Weighing machines , etc.Some of the application of Raspberry Pi are Stop motion cameras , Robot Controllers , Game Servers.

References

Total Phase Blog. 2022. Microcontroller vs Microprocessor - What are the Differences?. [online] Available at: <https://www.totalphase.com/blog/2019/12/microcontroller-vs-microprocessor-what-are-the-differences/#:~:text=Ultimately%2C%20microcontrollers%20and%20microprocessors%20are,that%20connects%20to%20external%20peripherals.> [Accessed 24 September 2022].

GeeksforGeeks. 2022. Difference between Arduino and Raspberry Pi - GeeksforGeeks. [online] Available at: <https://www.geeksforgeeks.org/difference-between-arduino-and-raspberry-pi/#:~:text=Arduino%20is%20based%20on%20a,circuit%20board%20in%20a%20system.> [Accessed 24 September 2022].