Understanding Android Location Permissions in Android/ Flutter Apps

When building a location-based app in Flutter, especially for Android, you need to declare certain permissions in your AndroidManifest.xml file. Below are three important permissions commonly used in tracking or location-aware apps:


<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>

 

1. ACCESS_FINE_LOCATION

This permission allows the app to access precise location using GPS and other location sources. It’s suitable when your app needs high-accuracy location, such as:

  • Real-time tracking (e.g., delivery or sales agents)
  • Navigation apps
  • Check-in or attendance based on exact coordinates

 

2. ACCESS_COARSE_LOCATION

This permission gives access to approximate location, usually determined by Wi-Fi or mobile networks (cell towers). It's less accurate (typically within 100–1000 meters) but uses less battery power.

Use this when your app only needs to know the general area or city where the user is located.

 

3. ACCESS_BACKGROUND_LOCATION

This permission allows the app to access the user's location even when the app is running in the background.

It’s essential for apps that need to track users continuously, such as:

  • Employee tracking
  • Geofencing and background logging
  • Fitness or travel logs

Note: Since Android 10 (API level 29), this permission must be requested separately and may require the user to manually enable it in system settings.

 

Runtime Permission Is Also Required!

Declaring the permission in the manifest is not enough. Starting from Android 6.0 (API 23), you also need to request location permissions at runtime in Flutter. You can use the permission_handler package:


import 'package:permission_handler/permission_handler.dart';

Future<void> requestLocationPermission() async {
  await [
    Permission.location,
    Permission.locationAlways,
  ].request();
}

 

When to Use Each

Use Case Permissions Needed
Location only while app is in use ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
High-accuracy tracking (e.g., GPS) ACCESS_FINE_LOCATION
Background location tracking ACCESS_BACKGROUND_LOCATION (plus runtime request)

Make sure to handle permissions properly to avoid crashes or unexpected behavior. Always guide the user if extra steps are needed, especially for background location access.

 

 

 

What Does 'Enable Realtime' Mean in Supabase Tables?

When you create or edit a table in Supabase, you’ll see an option:

Enable Realtime
"Broadcast changes on this table to authorized subscribers"

 

What Does It Mean?

It means Supabase will broadcast changes in the table such as INSERT, UPDATE, or DELETE to all authorized subscribers in real time.

 

Example Usage

Imagine you have a table called sales_log that tracks your sales team’s location data. If Enable Realtime is checked, your Flutter app (or any frontend) can instantly receive updates whenever a new entry is added or modified in that table no need to refresh or re-fetch data manually.

 

What Are "Authorized Subscribers"?

This means only users who are authenticated and have the proper Row Level Security (RLS) permissions will receive these realtime updates. Supabase won't push data to just anyone it respects your security rules.

 

When Should You Enable Realtime?

  • Enable it if your app needs live updates, such as:
    • Live chat
    • Location tracking
    • Real-time notifications
    • Interactive dashboards
  • Don’t enable it if:
    • The table is static or rarely changes
    • You don’t need instant updates in your frontend

 

Flutter Example Using Realtime


Supabase.instance.client
  .channel('public:sales_log')
  .onPostgresChanges(
    event: PostgresChangeEvent.insert,
    schema: 'public',
    table: 'sales_log',
    callback: (payload) {
      print('New data received: ${payload.newRecord}');
    },
  )
  .subscribe();

With this setup, your Flutter app will respond in real-time to any new data added to the sales_log table!

VirtualBox can't enable the AMD-V extension. Please disable the KVM kernel extension, recompile your kernel and reboot

Fixing VirtualBox Error: AMD-V In Use (VERR_SVM_IN_USE)

Error: VirtualBox can't enable AMD-V extension. Please disable the KVM kernel extension, recompile your kernel and reboot (VERR_SVM_IN_USE).

 

Why This Happens

This error occurs because AMD-V is already in use by KVM (Kernel-based Virtual Machine) on your Linux host. VirtualBox cannot share AMD-V with KVM, resulting in a failure to start your VM.

 

How to Fix It (Temporarily)

  1. Check if KVM is loaded:
    lsmod | grep kvm
    If it returns results like kvm or kvm_amd, it's active.
  2. Unload KVM modules:
    sudo modprobe -r kvm_amd kvm
    This command removes KVM from the kernel for the current session.
  3. Start your VirtualBox VM: It should now run without the error.

 

Optional: Permanently Disable KVM (for VirtualBox Users)

  1. Blacklist KVM modules:
    echo -e "blacklist kvm\nblacklist kvm_amd" | sudo tee /etc/modprobe.d/blacklist-kvm.conf
  2. Update initramfs:
    sudo update-initramfs -u
  3. Reboot your system:
    sudo reboot

Note: This will disable KVM permanently. Useful for VirtualBox, but will break QEMU/KVM functionality.

If you need both KVM and VirtualBox often, consider isolating them using dual boot or separate containers/VMs. These hypervisors generally don’t work well together.

Function vs Class Component in React JS: Which One Should You Choose?

If you're learning React JS, you'll quickly encounter two ways of creating components: Function Components and Class Components. Both are valid, both work, and both have their place—although one is definitely more modern and widely recommended today.

In this casual article, let's explore the difference between function and class components, their pros and cons, when to use each, and answer the classic question: function vs class which one wins?

 

What Is a Component in React?

First things first—components are the building blocks of React applications. Think of them as LEGO bricks you can mix and match to build user interfaces. Components can be tiny (like a button) or massive (like an entire page).

Every component can have:

  • UI (written in JSX)
  • Logic (event handlers, state)
  • Props (data from parent components)

And you can write them in two main styles:

  1. Function Components
  2. Class Components

 

Class Components

Class components are the older, traditional way to create components in React. They use JavaScript classes and are more verbose.

import React, { Component } from 'react';

class Welcome extends Component {
  render() {
    return <h1>Hello, {this.props.name}</h1>;
  }
}

Key characteristics:

  • Use the class keyword and extend React.Component
  • Props and state are accessed with this
  • Require a render() method

 

Function Components

Function components are more modern and now the preferred way to write components in React.

function Welcome(props) {
  return <h1>Hello, {props.name}</h1>;
}

// Or using arrow function:
const Welcome = ({ name }) => <h1>Hello, {name}</h1>;

Advantages: shorter, easier to read, no need for this, and easy to reuse logic with Hooks.

 

Then Came Hooks

Before Hooks were introduced in React 16.8, function components were "dumb" they couldn't manage state or lifecycle logic. But with Hooks like useState and useEffect, function components became much more powerful and flexible.

 

Function vs Class: Side-by-Side Comparison

Aspect Class Component Function Component
Syntax Uses class and this Plain JavaScript function
Props this.props props (or destructured)
State this.state, this.setState() useState()
Lifecycle componentDidMount, etc. useEffect()
Binding Often needed Not required
Code Length More verbose More concise
Future-Proof Still supported Recommended going forward

 

Example: Counter Component

Class Version

class Counter extends React.Component {
  constructor(props) {
    super(props);
    this.state = { count: 0 };
  }

  increment = () => {
    this.setState({ count: this.state.count + 1 });
  };

  render() {
    return (
      <div>
        <p>Count: {this.state.count}</p>
        <button onClick={this.increment}>+1</button>
      </div>
    );
  }
}

Function Version

const Counter = () => {
  const [count, setCount] = useState(0);

  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={() => setCount(count + 1)}>+1</button>
    </div>
  );
};

 

Say Goodbye to this

One of the most painful parts of class components for beginners is dealing with this. You often have to manually bind methods in the constructor. With function components, you don’t have to worry about this at all. Simpler, cleaner, and less buggy!

 

Lifecycle Methods in One Hook

In class components, you’d use methods like:

  • componentDidMount()
  • componentDidUpdate()
  • componentWillUnmount()

In function components, you can handle all that with just one hook:

useEffect(() => {
  console.log("Mounted");

  return () => {
    console.log("Unmounted");
  };
}, []);

 

When Should You Still Use Class Components?

Although function components are preferred now, class components are still useful in some cases:

  • Working with legacy code
  • Some older libraries still rely on class lifecycle methods
  • You’re refactoring old projects

 

Why Function Components Are the Future

React’s documentation and ecosystem are moving toward function components for good reason:

  • Shorter, cleaner syntax
  • Hooks make logic reusable
  • Easier to test
  • Better performance in some cases

 

Final Thoughts: Function Component Wins!

If you’re just starting with React, use function components. They’re simpler, more modern, and more aligned with where React is going. But if you want to be a well-rounded React developer, understanding class components will help you maintain or upgrade older projects.

 

Tips

  • Use useReducer() for complex state management
  • Use useCallback() to prevent unnecessary renders
  • Use useMemo() for performance optimization

 


Understanding the McCulloch-Pitts Neuron Model: The Foundation of Artificial Intelligence

Who would’ve thought that today’s AI capable of recognizing faces, generating art from text, and even writing articles like this traces its roots back to a simple idea from 1943? In this casual article, let’s explore how the McCulloch-Pitts neuron model laid the groundwork for modern neural networks, powering everything from ChatGPT to self-driving cars.

 

What Is the McCulloch-Pitts Neuron Model?

This model is a mathematical abstraction of a biological neuron. Created by two brilliant scientists, Warren McCulloch and Walter Pitts, it attempts to mimic how the human brain processes information using binary logic.

The McCulloch-Pitts model works as follows:

  • It takes binary inputs (0 or 1)
  • Sums them (usually with equal weights)
  • Compares the total to a threshold
  • If the sum ≥ threshold → neuron “fires” (output = 1)
  • If the sum < threshold → neuron remains inactive (output = 0)

 

Mathematical Formulation

Output = 
    1, if Σ(inputs) ≥ threshold
    0, otherwise

Simple, right? For example:

  • Inputs: [1, 1, 0]
  • Threshold: 2
  • Sum = 2 → Output = 1

 

Why Is This Model Important?

Back in the 1940s, even basic computers were rare. Yet McCulloch and Pitts demonstrated that this simple model could represent basic logical functions like AND, OR, and NOT. That means with enough neurons, you could build complex logic systems!

In essence, the McCulloch-Pitts neuron is the “Hello World” of artificial intelligence.

 

Logic Functions with McCulloch-Pitts

AND Function

  • Inputs: x₁, x₂
  • Threshold: 2
x₁x₂Output
000
010
100
111

OR Function

  • Threshold: 1
x₁x₂Output
000
011
101
111

 

NOT Function (Using Inhibitory Input)

  • Inhibitory inputs can shut down the neuron, even if other inputs are active.

For example, if input 1 is excitatory and input 2 is inhibitory:

  • [1, 0] → Output: 1
  • [1, 1] → Output: 0 (inhibitor blocks the neuron)

 

Limitations of the Model

Despite its brilliance, the model has several limitations:

  • Only handles binary inputs and outputs
  • Weights are fixed (no learning mechanism)
  • Cannot model XOR function without network layering
  • No training or adaptation possible

 

Basis of Modern Neural Networks

Still, the McCulloch-Pitts neuron inspired today’s neural networks. While modern models use weighted sums and activation functions (like ReLU or sigmoid), the core idea remains:

output = activation(Σ(input × weight) + bias)

Compare that to the original McCulloch-Pitts neuron: no weights, no bias, just pure threshold logic.

 

A Bit of History

  • 1943: McCulloch and Pitts publish their seminal paper.
  • 1950s: Frank Rosenblatt introduces the perceptron, a trainable extension.
  • 1980s+: Backpropagation revives neural networks in AI research.

 

Why You Should Learn This Model

Here’s why this model still matters:

  1. It’s the foundation of AI and neural networks
  2. Simple enough for beginners
  3. Builds intuition about how neurons and logic circuits work

 

Try It Yourself (Python)

def mcculloch_pitts(inputs, threshold):
    total = sum(inputs)
    return 1 if total >= threshold else 0

# AND Function
print(mcculloch_pitts([1, 1], 2))  # Output: 1
print(mcculloch_pitts([1, 0], 2))  # Output: 0

 

Walter Pitts was a brilliant autodidact who taught himself logic from Russell & Whitehead’s “Principia Mathematica” as a teenager and even wrote a letter to Bertrand Russell!

The McCulloch-Pitts neuron might be simple, but its impact is profound. It sparked the entire field of artificial intelligence and still serves as an educational tool to this day.

So next time you use AI tools, remember they all started from a humble threshold logic gate designed over 80 years ago.


Understanding Brain Anatomy: Visualization of Cortex, Amygdala and Hippocampus

Hello Curious Brain Explorers!

Have you ever wondered how complex your brain is? Or why we can feel fear, joy, recall memories, and make tough decisions in just seconds? Well, all of that happens thanks to the amazing collaboration between different brain regions. In this casual article, we'll explore three important brain parts: the cerebral cortex, the amygdala, and the hippocampus  with anatomy and functions explained in a simple way. 

 

1. Brain Visualization: What Does It Look Like?

Imagine your brain like a bowl of folded noodles — seriously! The surface of the brain is wrinkled with ridges called gyri and grooves called sulci. These folds increase surface area, allowing for more processing power without needing a bigger skull.

From the outside, the brain is divided into two hemispheres: left and right. But that doesn’t mean they work independently. While the left side is often associated with logic and the right with creativity, both work together in harmony.

 

2. The Cerebral Cortex: The Multitasking Genius

What is the Cerebral Cortex?

The cerebral cortex is the outermost layer of the brain — that gray matter you always hear about. It’s the brain’s operating system, managing thinking, speech, memory, planning, and sensation.

Major Lobes of the Cortex

  • Frontal Lobe: Located at the front. Handles critical thinking, decision-making, personality, and emotional control.
  • Parietal Lobe: At the top-middle of the brain. Processes sensory input like touch, pain, and temperature.
  • Temporal Lobe: Near the ears. Important for hearing, language, and memory. The hippocampus is located here!
  • Occipital Lobe: At the back of the head. Dedicated to vision and visual processing.

 

3. The Amygdala: The Emotion Detector

What is the Amygdala?

The amygdala is a small almond-shaped cluster deep in the temporal lobe. Despite its size, it plays a huge role in managing emotions — especially fear and anger.

Main Functions

  • Triggers emotional responses to danger or threat.
  • Helps create emotional memories (like remembering a scary movie scene).
  • Involved in decision-making influenced by emotion.

For example, people with phobias often show high amygdala activity when exposed to their fears. That heartbeat racing at the sight of a spider? Thank the amygdala!

 

4. The Hippocampus: The Memory Guardian

What is the Hippocampus?

Shaped like a tiny seahorse (hence the name), the hippocampus sits near the amygdala in the temporal lobe. It’s crucial for memory and learning.

Main Functions

  • Creates long-term memories. Remembering your friend’s birthday? That’s the hippocampus.
  • Navigation and spatial orientation. Helps you remember the way home.
  • Memory consolidation. Transfers short-term memory into long-term, especially while sleeping.

Early signs of Alzheimer’s often involve damage to the hippocampus — that’s why memory loss is such a common symptom.

 

5. The Trio in Action: Cortex, Amygdala & Hippocampus

These three don’t work in silos. They’re constantly communicating. Here's a real-life example:

You’re walking alone at night and hear footsteps behind you.

  • Amygdala: Triggers a fear response — “Something's wrong!”
  • Hippocampus: Recalls memory — “Didn’t a robbery happen here recently?”
  • Cortex: Helps you reason — “I should walk toward the crowded street.”

This collaboration happens in milliseconds — talk about teamwork!

 

6. Keeping Your Brain Healthy

Want your brain to stay sharp and balanced? Try these simple habits:

  •  Get enough sleep
  •  Exercise regularly
  •  Eat brain-boosting foods (like omega-3s, leafy greens, berries)
  •  Keep learning — like reading this article 
  •  Manage stress
  •  Stay socially connected

Your brain is more than a squishy lump. It’s a highly intelligent, emotional, and memory-driven command center. The cortex lets you think, the amygdala helps you feel, and the hippocampus keeps your memories alive.

The more you understand your brain, the better you can make the most of it — whether in school, work, or just enjoying life. Keep exploring neuroscience your brain will thank you!


Central Nervous System vs Peripheral Nervous System: What's the Difference? Here's the Fun and Complete Guide!

Ever wondered how your body can instantly pull your hand away from something hot? Or how you can react so quickly to a loud noise? That’s all thanks to your amazing nervous system! But here’s the twist — the nervous system isn’t just one thing. It has two major parts: the Central Nervous System (CNS) and the Peripheral Nervous System (PNS).

They may sound similar, but they have very different roles — and they work hand in hand. Let’s dive into the differences and how they work together in a chill, easy-to-digest way!

 

What Is the Nervous System?

Before we compare CNS and PNS, let’s take a quick look at the big picture.

The nervous system is a complex network in your body that sends, receives, and interprets messages. Think of it like a super-fast internet connection that helps your body move, sense, think, and react.

The nervous system is divided into two main parts:

  • Central Nervous System (CNS)
  • Peripheral Nervous System (PNS)

 

Central Nervous System: The Brain Boss

 

1. What is the CNS?

The Central Nervous System is the command center. It consists of:

  • The brain
  • The spinal cord

The brain acts like the CEO, and the spinal cord is like the head of operations connecting the brain to the rest of the body.

2. What Does It Do?

The CNS is responsible for:

  • Processing sensory data (like sight, sound, taste, touch)
  • Controlling movements (both conscious and reflexive)
  • Thinking, learning, memory
  • Managing emotions

3. How Does It Work?

Let’s say you see your favorite food. Your eyes send signals to your brain, the brain processes it, and suddenly you feel hungry and start drooling — and your hand reaches for the plate, all automatically!

 

Peripheral Nervous System: The Messenger Network

 

1. What is the PNS?

If the CNS is the HQ, the PNS is the communication network. It consists of:

  • Cranial nerves (from the brain)
  • Spinal nerves (from the spinal cord)

2. What Does It Do?

The PNS connects the CNS to limbs and organs — basically, it sends messages back and forth.

The PNS is divided into:

  • Somatic Nervous System: Controls voluntary movements and receives sensory information.
  • Autonomic Nervous System: Controls involuntary functions like heartbeat, breathing, digestion.

The autonomic system is split into:

  • Sympathetic: Active during stress (fight or flight)
  • Parasympathetic: Active during rest (rest and digest)

 

CNS vs PNS: Key Differences

Aspect Central Nervous System (CNS) Peripheral Nervous System (PNS)
Components Brain and spinal cord Cranial and spinal nerves
Main Role Processing and decision-making Communication between CNS and body
Location Protected inside skull and spine Distributed throughout the body
Protection Protected by bone, fluid, and membranes Less protected, more exposed
Regeneration Difficult to repair Can regenerate to some extent

 

How Do CNS and PNS Work Together?

Imagine stepping on a nail. The nerves in your foot (PNS) send a signal to your brain (CNS), which processes the pain and immediately sends a command back — move your foot!

Or when you're stressed about a deadline, the sympathetic nervous system kicks in — heart races, palms sweat. After relaxing, the parasympathetic system slows everything down. It's a beautiful back-and-forth.

 

What If One of Them Gets Damaged?

  • CNS damage can lead to paralysis, memory loss, seizures, or coma.
  • PNS damage can cause numbness, tingling, nerve pain, or muscle weakness.

For example:

  • Multiple sclerosis affects the CNS.
  • Peripheral neuropathy affects the PNS.

 

Tips to Keep Your Nervous System Healthy

  • Eat nutritious foods (rich in B vitamins and omega-3)
  • Get enough sleep — brain recovery happens during rest
  • Exercise regularly — boosts blood flow and brain function
  • Manage stress — through meditation, hobbies, or rest
  • Avoid harmful substances — alcohol, drugs, toxins

The Central and Peripheral Nervous Systems may have different roles, but they’re like Batman and Robin — better together. One can't function effectively without the other. So let’s take care of them, because they work 24/7 to take care of us!