How to Find or installing nano on Linux ?




๐Ÿงฉ Step 1: Check if Nano is already installed

Open your terminal and run:

nano --version
  • If Nano is installed, you’ll see version information (like GNU nano, version 6.4).

  • If it’s not installed, you’ll see an error such as:
    bash: nano: command not found


๐Ÿงฐ Step 2: Install Nano (based on your Linux distribution)

๐Ÿง Ubuntu / Debian / Linux Mint

sudo apt update
sudo apt install nano -y

๐Ÿงฑ Fedora

sudo dnf install nano -y

๐Ÿ’ฟ CentOS / RHEL

sudo yum install nano -y

On newer RHEL versions (8+), you can use dnf instead of yum.

๐Ÿงฉ Arch Linux / Manjaro

sudo pacman -S nano

๐Ÿ™ openSUSE

sudo zypper install nano

⚙️ Step 3: Verify installation

After installation, confirm again:

nano --version

If it prints version info — you’re all set!


๐Ÿ’ก Optional: Make Nano the default editor

If you want Nano to open automatically for things like git commit messages or crontab -e, set it as the default editor:

export EDITOR=nano

To make this permanent, add the above line to your ~/.bashrc or ~/.zshrc.


Enjoy! Follow us for more... 

Adding automatic timestamps in SQL

 



Adding automatic timestamps in SQL is a common practice to track when rows are created or updated. Here’s how you can do it depending on your database — I’ll focus on SQLite, since your recent topic is about SQLite 3 and PHP interface.


๐Ÿงฉ 1. Using Automatic Timestamps in SQLite

SQLite doesn’t have a built-in CURRENT_TIMESTAMP default like MySQL’s TIMESTAMP DEFAULT CURRENT_TIMESTAMP — but you can use default expressions with datetime('now').

✅ Example: Add a timestamp when inserting new records

CREATE TABLE users (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    email TEXT UNIQUE,
    created_at TEXT DEFAULT (datetime('now', 'localtime'))
);

Now when you insert a record:

INSERT INTO users (name, email)
VALUES ('Alice', 'alice@example.com');

SQLite automatically adds the current local date and time to created_at.

Result:

id name email created_at
1 Alice alice@example.com 2025-11-06 22:10:53

๐Ÿ•’ 2. Automatically Update Timestamp on Edit

SQLite does not support automatic updates to a column when a row changes, but you can achieve it using a trigger.

✅ Example with Trigger

CREATE TABLE articles (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    title TEXT,
    content TEXT,
    created_at TEXT DEFAULT (datetime('now', 'localtime')),
    updated_at TEXT
);

CREATE TRIGGER update_articles_timestamp
AFTER UPDATE ON articles
FOR EACH ROW
BEGIN
    UPDATE articles
    SET updated_at = datetime('now', 'localtime')
    WHERE id = OLD.id;
END;

Now, whenever you update a row:

UPDATE articles SET content = 'New text here' WHERE id = 1;

SQLite will automatically fill or refresh the updated_at field.


๐Ÿง  3. Using Timestamps in PHP with SQLite3 Interface

When using the PHP SQLite3 interface, you don’t need to manually generate timestamps if you’ve already set the default and trigger.

Example PHP Code:

<?php
$db = new SQLite3('example.db');

$db->exec("CREATE TABLE IF NOT EXISTS logs (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    message TEXT,
    created_at TEXT DEFAULT (datetime('now', 'localtime'))
)");

$stmt = $db->prepare("INSERT INTO logs (message) VALUES (:message)");
$stmt->bindValue(':message', 'System started', SQLITE3_TEXT);
$stmt->execute();

$result = $db->query("SELECT * FROM logs");
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
    echo $row['id'] . " | " . $row['message'] . " | " . $row['created_at'] . "\n";
}
?>

Enjoy! Follow us for more... 




SQLite 3 php interface, Choosing an interface.

 


Download SQLite 3 php interface,mp4

SQLite3 is a lightweight, file-based database engine that can be easily integrated with PHP without the need for a separate server process (like MySQL or PostgreSQL). PHP comes with built-in support for SQLite3, making it great for small-to-medium applications, local storage, or prototyping.

Here’s a full guide on using the SQLite3 PHP interface ๐Ÿ‘‡


๐Ÿงฑ 1. Enabling SQLite3 in PHP

Most modern PHP installations already have SQLite3 enabled by default.
To confirm:

php -m | grep sqlite

You should see sqlite3 in the list.
If not, enable it in your php.ini by uncommenting:

extension=sqlite3

Restart your web server afterward.


⚙️ 2. Creating and Connecting to an SQLite3 Database

SQLite databases are just files on disk. You can open (or create) one using the SQLite3 class.

<?php
// Create or open a database file
$db = new SQLite3('example.db');

// Check connection
if ($db) {
    echo "Connected to SQLite3 database successfully!";
}
?>

This will create a file named example.db in your current directory.


๐Ÿ“„ 3. Creating a Table

<?php
$db = new SQLite3('example.db');

// Create a table
$query = "CREATE TABLE IF NOT EXISTS users (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    email TEXT UNIQUE NOT NULL
)";
$db->exec($query);

echo "Table created successfully!";
?>

✏️ 4. Inserting Data

<?php
$db = new SQLite3('example.db');

$stmt = $db->prepare("INSERT INTO users (name, email) VALUES (:name, :email)");
$stmt->bindValue(':name', 'Alice');
$stmt->bindValue(':email', 'alice@example.com');
$stmt->execute();

echo "Data inserted!";
?>

๐Ÿ” 5. Querying Data

<?php
$db = new SQLite3('example.db');

$results = $db->query("SELECT * FROM users");

while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
    echo "ID: {$row['id']} | Name: {$row['name']} | Email: {$row['email']} <br>";
}
?>

๐Ÿงน 6. Updating and Deleting Data

Update Example:

$db->exec("UPDATE users SET email='alice_new@example.com' WHERE id=1");

Delete Example:

$db->exec("DELETE FROM users WHERE id=1");

๐Ÿ› ️ 7. Using PDO with SQLite (Alternative Method)

PDO provides a more flexible and modern way to interact with databases.

<?php
try {
    $pdo = new PDO('sqlite:example.db');
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    $pdo->exec("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)");
    $pdo->exec("INSERT INTO users (name, email) VALUES ('Bob', 'bob@example.com')");

    foreach ($pdo->query("SELECT * FROM users") as $row) {
        echo $row['name'] . " - " . $row['email'] . "<br>";
    }
} catch (PDOException $e) {
    echo $e->getMessage();
}
?>

๐Ÿง  8. When to Use SQLite3 in PHP

✅ Great for:

  • Small websites or internal tools

  • Local data storage

  • Desktop/web hybrid apps

  • Prototyping before using MySQL/PostgreSQL

๐Ÿšซ Not ideal for:

  • High-concurrency web apps

  • Large-scale data sets

  • Distributed systems


Enjoy! Follow us for more... 

How to add mouse input in cpp programming using xCode.mp4

 


Download How to add mouse input in cpp programming using xCode.MP4


๐Ÿ–ฑ️ How to Add Mouse Input in C++ Programming Using Xcode

When developing interactive graphics or games in C++ using Xcode, handling mouse input is an essential part of creating a responsive and user-friendly application. Whether you’re building a macOS app, a game engine, or an OpenGL project, learning how to add mouse input helps bring your C++ applications to life.

In this guide, we’ll explore how to add mouse input in C++ using Xcode, with code examples and key explanations.


๐Ÿš€ Why Mouse Input Matters in C++ Development

In modern C++ application development, user input handling allows you to capture and respond to actions like clicks, drags, and cursor movement. If you’re using Xcode on macOS, you can easily integrate mouse events using frameworks such as Cocoa, SFML, or OpenGL.

Popular use cases:

  • Detecting mouse clicks in a game window

  • Tracking mouse movement for drawing or selecting objects

  • Handling scrolling or dragging in graphical user interfaces


๐Ÿงฐ Setting Up Xcode for C++ Mouse Input

Before writing the code, make sure your Xcode project is properly configured for C++:

  1. Open Xcode and create a new Command Line Tool or macOS App project.

  2. Choose C++ as your language.

  3. Set up any external libraries if you’re using OpenGL, SFML, or SDL.


๐Ÿ–‹️ Example 1: Basic Mouse Input Using SFML in Xcode

The SFML (Simple and Fast Multimedia Library) provides an easy way to handle mouse input in C++.

๐Ÿ”ง Code Example:

#include <SFML/Graphics.hpp>
#include <iostream>

int main() {
    sf::RenderWindow window(sf::VideoMode(800, 600), "Mouse Input Example");

    while (window.isOpen()) {
        sf::Event event;
        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed)
                window.close();

            if (event.type == sf::Event::MouseButtonPressed) {
                if (event.mouseButton.button == sf::Mouse::Left)
                    std::cout << "Left mouse button clicked at ("
                              << event.mouseButton.x << ", "
                              << event.mouseButton.y << ")" << std::endl;
            }

            if (event.type == sf::Event::MouseMoved) {
                std::cout << "Mouse moved to: (" 
                          << event.mouseMove.x << ", "
                          << event.mouseMove.y << ")" << std::endl;
            }
        }

        window.clear();
        window.display();
    }

    return 0;
}

✅ What This Code Does:

  • Detects when the mouse button is clicked.

  • Tracks mouse movement coordinates.

  • Displays the output in the Xcode console.


๐Ÿงฉ Example 2: Handling Mouse Input with OpenGL and GLUT

If you’re working with OpenGL, you can use GLUT (OpenGL Utility Toolkit) for mouse input:

#include <GLUT/glut.h>
#include <iostream>

void mouse(int button, int state, int x, int y) {
    if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
        std::cout << "Mouse clicked at (" << x << ", " << y << ")" << std::endl;
}

void display() {
    glClear(GL_COLOR_BUFFER_BIT);
    glFlush();
}

int main(int argc, char** argv) {
    glutInit(&argc, argv);
    glutCreateWindow("Mouse Input in OpenGL");
    glutMouseFunc(mouse);
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
}

This approach is perfect for graphics or game programming where real-time input is required.


๐Ÿ’ก Tips for Debugging Mouse Input in Xcode

  • Ensure your app window is focused to receive input.

  • Check that event polling loops are active.

  • Use breakpoints or console logs to verify coordinates.

  • Always rebuild the project after changing input event configurations.


๐Ÿ Conclusion

Adding mouse input handling in C++ programming using Xcode is an essential step toward building interactive, graphical, or game-based applications. Whether you’re using SFML, GLUT, or the Cocoa framework, Xcode offers the flexibility and performance needed for professional C++ development.

Now that you’ve learned how to implement mouse input, try extending your program with keyboard input, camera control, or UI interactions to take your C++ projects to the next level!


Enjoy! Follow us for more... 

How to combined lighting and textures in cpp programming using xCode.mp4

 


Download How to combined lighting and textures in cpp programming using xCode.mp4


๐Ÿง  How to Combine Lighting and Textures in C++ Programming Using Xcode

When creating 3D applications or games in C++, achieving realism is often about mastering two essential concepts — lighting and textures. Lighting adds depth and mood, while textures bring surfaces to life. When combined, they form the foundation of realistic rendering. In this post, we’ll explore how to combine lighting and textures in C++ using Xcode, Apple’s powerful IDE.


๐Ÿ”ง Setting Up Your Xcode Environment

Before diving into code, make sure your environment is ready:

  1. Install Xcode from the Mac App Store.

  2. Create a new C++ Command Line Tool project.

  3. Add OpenGL (or Metal, for modern Apple graphics) frameworks.

  4. Configure your project’s build settings to link the required graphics libraries.

For OpenGL:

#include <GLUT/glut.h>
#include <OpenGL/gl.h>

๐Ÿ’ก Step 1: Understanding Lighting

Lighting simulates how light interacts with objects. In OpenGL, you can use different types of lights — ambient, diffuse, and specular.

Here’s a simple setup for basic lighting:

void setupLighting() {
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);

    GLfloat lightPosition[] = {1.0, 1.0, 1.0, 0.0};
    GLfloat lightColor[] = {1.0, 1.0, 1.0, 1.0};
    GLfloat ambientColor[] = {0.2, 0.2, 0.2, 1.0};

    glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);
    glLightfv(GL_LIGHT0, GL_AMBIENT, ambientColor);
}

This creates a white light shining from a position above your 3D scene.


๐Ÿ–ผ️ Step 2: Applying Textures

Textures wrap 2D images around 3D geometry to make them look detailed. You can load texture data from an image and map it to an object’s surface.

Here’s a simple example:

GLuint texture;

void loadTexture(const char* filename) {
    // Load image (pseudo-code)
    unsigned char* data = loadImage(filename); 
    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    // Apply texture data
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
}

Once your texture is loaded, you can apply it to an object:

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture);

๐ŸŽจ Step 3: Combining Lighting and Textures

Now, to make both work together, we’ll enable both lighting and texturing in our render function:

void display() {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_DEPTH_TEST);

    setupLighting();
    loadTexture("brick_wall.jpg");

    glEnable(GL_LIGHTING);
    glEnable(GL_TEXTURE_2D);

    glBegin(GL_QUADS);
        glNormal3f(0.0, 0.0, 1.0); // surface normal for lighting
        glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, 0.0);
        glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, 0.0);
        glTexCoord2f(1.0, 1.0); glVertex3f( 1.0,  1.0, 0.0);
        glTexCoord2f(0.0, 1.0); glVertex3f(-1.0,  1.0, 0.0);
    glEnd();

    glutSwapBuffers();
}

This renders a textured quad illuminated by a light source. The glNormal3f() function ensures that the lighting interacts correctly with the surface.


๐Ÿงฉ Step 4: Adjusting Material Properties

For finer control, you can adjust the material’s properties to influence how it reacts to light.

GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};
GLfloat mat_shininess[] = {50.0};

glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);

This makes your texture surface appear glossy under direct light.


๐Ÿš€ Conclusion

Combining lighting and textures in C++ with Xcode can transform your 3D scenes from flat and dull to dynamic and realistic. While OpenGL is the classic way to do this, modern Apple platforms also support Metal, which offers even more performance and flexibility.

Experiment with different light positions, texture images, and material settings to bring your C++ graphics projects to life!


Enjoy! Follow us for more... 

How to create the code behind the class in cpp programming using Microsoft Visual Sytudio.mp4

 


Download How to create the code behind the class in cpp programming using Microsoft Visual Sytudio.mp4

Creating the code behind a class in C++ using Microsoft Visual Studio is a common practice to separate class declarations (in header files) from definitions (in source files) — improving readability and maintainability.

Here’s a step-by-step guide ๐Ÿ‘‡


๐Ÿงฉ Step 1: Create a New Project

  1. Open Microsoft Visual Studio.

  2. Go to File → New → Project.

  3. Choose Console App (C++).

  4. Name your project (e.g., ClassExample) and click Create.


๐Ÿงฑ Step 2: Add a Header File (.h)

  1. In Solution Explorer, right-click the project → Add → New Item...

  2. Select Header File (.h) and name it, e.g., Student.h.

  3. Add the class declaration here.

Example – Student.h

#pragma once
#include <string>

class Student {
private:
    std::string name;
    int age;

public:
    Student(std::string n, int a); // Constructor declaration
    void displayInfo();            // Method declaration
};

⚙️ Step 3: Add a Source File (.cpp)

  1. Right-click the project again → Add → New Item...

  2. Choose C++ File (.cpp) and name it Student.cpp.

  3. Include the header file and define the methods.

Example – Student.cpp

#include "Student.h"
#include <iostream>
using namespace std;

Student::Student(std::string n, int a) {
    name = n;
    age = a;
}

void Student::displayInfo() {
    cout << "Name: " << name << ", Age: " << age << endl;
}

๐Ÿš€ Step 4: Use the Class in main.cpp

Visual Studio automatically creates a main.cpp file. Use your class there:

Example – main.cpp

#include <iostream>
#include "Student.h"
using namespace std;

int main() {
    Student s1("Alice", 21);
    s1.displayInfo();
    return 0;
}

๐Ÿง  Step 5: Build and Run

  • Press Ctrl + F5 or click Run → Start Without Debugging

  • You’ll see:

    Name: Alice, Age: 21
    

✅ Summary

File Purpose
Student.h Class declaration (what it looks like)
Student.cpp Class definition (how it works)
main.cpp Entry point of the program


Enjoy! Follow us for more... 

How to Find or installing nano on Linux ?

๐Ÿงฉ Step 1: Check if Nano is already installed Open your terminal and run: nano --version If Nano is installed, you’ll see version inf...