Wednesday 13 March 2024

The Git & Github Bootcamp Part1 - Master on essentials and the tricky bits: rebasing, squashing, stashing, reflogs, blobs, trees, & more!


Installation & Setup

1. Installing Git: Terminal Vs. GUIs

  • Terminal: A text-based interface to run commands directly on your computer.
  • GUIs (Graphical User Interfaces): Software applications with graphical elements, like buttons and icons, making it easier to perform Git operations without memorizing commands.

2. WINDOWS Git Installation

  • Step 1: Visit git-scm.com and download the Windows version of Git.
  • Step 2: Open the downloaded file and follow the installation instructions. Leave the default settings unless you have a specific need to change them.

3. MAC Git Installation

  • Step 1: Open the Terminal.
  • Step 2: Type git --version and press Enter. If Git is not already installed, this will prompt you to install it.
  • Alternatively, you can use Homebrew by typing brew install git if you have Homebrew installed.

4. Configuring Your Git Name & Email

Before you start using Git, you need to introduce yourself to Git by configuring your user name and email address. This information is important because every Git commit uses this information.

  • Command:
    git config --global user.name "Your Name"
    git config --global user.email "your.email@example.com"
    

5. Installing GitKraken (Our GUI)

GitKraken is a graphical Git client that makes Git commands more user-friendly.

  • Step 1: Go to gitkraken.com and download GitKraken.
  • Step 2: Run the installer and follow the setup instructions.

6. Terminal Crash Course: Creating Files & Folders

Creating files and folders from the terminal is a basic but essential skill.

  • Creating a Folder: Use the mkdir command followed by the name of the folder. For example, mkdir MyProject creates a new folder named MyProject.
  • Creating a File: Use the touch command followed by the filename. For example, touch README.md creates a new file named README.md.

7. Terminal Crash Course: Deleting Files & Folders

Sometimes, you need to clean up or remove unnecessary files and folders.

  • Deleting a File: Use the rm command followed by the filename. For example, rm README.md deletes the README.md file.
  • Deleting a Folder: Use the rm -r command followed by the folder name to remove a folder and its contents. For example, rm -r MyProject deletes the MyProject folder and everything inside it.

Putting It All Together: Creating a New Sample Project

Now that you have Git and GitKraken installed, and you know how to manage files and folders from the terminal, let’s start a new sample project.

  1. Open the Terminal or Git Bash on Windows.
  2. Navigate to where you want to create your project using the cd command (e.g., cd Documents).
  3. Create a new folder for your project (e.g., mkdir SampleProject).
  4. Navigate into your project folder (e.g., cd SampleProject).
  5. Initialize a new Git repository:
    • Command: git init
    • This command creates a new Git repository in your project folder. You’ll see a message like “Initialized empty Git repository in [your project path]/.git/”.
  6. Create your first file (e.g., touch README.md) and open it with a text editor to add some content, such as “This is my first Git project!”.
  7. Add your file to the staging area with Git:
    • Command: git add README.md
    • This command tells Git to start tracking changes to the README.md file.
  8. Commit your changes:
    • Command: git commit -m "Initial commit"
    • This command saves your changes to the repository with a message describing what you did.

Very Basics of Git: Adding & Committing

10. What Is A Git Repo?

A Git repository (repo) is a folder on your computer where Git tracks the changes to your project files. It allows you to save different versions of your project, so you can recall specific versions later. The repository was initialized in your project folder when you ran git init.

11. Our First Commands: git init and git status

  • git init: This command was used to initialize your project folder as a Git repository. It allows Git to start tracking changes in the folder.
  • git status: Use this command to see which changes Git has noticed but not yet recorded. Let’s try it:
    cd SampleProject
    git status
    
    This command will show the status of your repository, including any files that have been added, modified, or are untracked.

12. The Mysterious .git Folder

When you initialize a Git repository, Git creates a hidden folder named .git in your project directory. This folder contains all the information necessary for version control, including logs, configurations, and the status of each file. You typically won’t need to interact with this folder directly.

13. A Common Early Git Mistake

A frequent mistake beginners make is forgetting to stage changes before committing them. Git requires you to “add” changes to the staging area before you can “commit” them to your repository’s history. This two-step process gives you control over exactly what changes you include in a commit.

14. Staging Changes With git add

  • Example: Suppose you’ve edited the README.md file to add more project details. To prepare these changes for a commit, you use the git add command.
    git add README.md
    
  • This command moves the changes in README.md to the staging area, making them ready to be committed.

15. The git log Command (And More Committing)

  • git log: Shows a history of all commits in the repository. Each commit is displayed with its unique ID, the author’s name and email, the date, and the commit message.
    git log
    
  • After staging your changes with git add, commit them with a message describing what you did:
    git commit -m "Updated README with more project details."
    

16. Committing Exercise

Let’s practice adding and committing with a new file:

  1. Create a new file: touch notes.txt
  2. Add some content to notes.txt (use a text editor).
  3. Stage the file: git add notes.txt
  4. Commit the changes with a message: git commit -m "Added notes.txt with project notes."
  5. Check the log: git log

By performing these steps, you’ve practiced adding a new file to your repository, staging it, and committing it with a descriptive message. Remember, git status is a helpful command to use throughout this process to see what changes are staged, unstaged, or untracked.

Expanding on our example project, “SampleProject,” let’s explore commits in detail, focusing on best practices, tools, and techniques to manage your project efficiently.

Commits in Detail

1. Commit Messages: Present Or Past Tense?

Commit messages should be written in the imperative mood, as if giving a command or instruction. This convention matches the messages generated by Git itself for automated commits.

  • Example: Instead of writing “Added feature X,” write “Add feature X.”

2. Escaping VIM & Configuring Git’s Default Editor

When you commit without specifying a message directly in the command line (git commit without -m "message"), Git opens the default text editor (often VIM) to write a commit message. Exiting VIM can be confusing for new users:

  • To exit VIM after adding your commit message, press Esc, type :wq (write and quit), and press Enter.
  • To change the default editor to something you’re more comfortable with (like Nano, which is simpler), run:
    git config --global core.editor "nano"
    
    Now, when you run git commit, Nano will open instead of VIM.

3. A Closer Look At The Git Log Command

git log provides a history of commits. To see more than just the commit hash, author, date, and message, you can use:

  • git log --stat: Shows the number of changes (additions and deletions) per file.
  • git log --pretty=oneline: Shows each commit on a single line, making it easier to read through many commits.
  • git log --graph: Displays a text-based graph of the commit history, useful for visualizing branch merges.

4. Committing With A GUI

Git GUI clients like GitKraken can make committing changes more intuitive for those uncomfortable with the command line. Using our project as an example:

  • Open GitKraken and navigate to your “SampleProject” repository.
  • You’ll see uncommitted changes in a panel or section often labeled “Unstaged Files.”
  • Drag the files you want to commit from “Unstaged” to “Staged.”
  • Write your commit message in the provided field and click the “Commit” button.

5. Fixing Mistakes With Amend

If you make a mistake in your last commit (e.g., forgot to add a file or made a typo in the commit message), you can correct it with git commit --amend. This combines your changes with the previous commit instead of creating a new one.

  • Make the necessary changes or add any missed files.
  • Stage the changes: git add .
  • Amend the commit: git commit --amend -m "New commit message"

6. Ignoring Files w/ .gitignore

Sometimes, there are files or directories you don’t want Git to track (e.g., temporary files, build folders). You can create a .gitignore file in your repository’s root directory and list the patterns for files to ignore.

  • Create a .gitignore file: touch .gitignore
  • Open .gitignore in a text editor and add patterns for files to ignore. For example:
    # Ignore all log files
    *.log
    
    # Ignore the node_modules directory
    node_modules/
    
  • Add and commit the .gitignore file:
    git add .gitignore
    git commit -m "Add .gitignore file"
    

By understanding these detailed aspects of committing in Git, you can maintain a clean, efficient workflow for your projects.

Read more »

Labels:

Tuesday 5 December 2023

10 Free Projects to Get Started with AWS

Are you interested in learning more about Amazon Web Services (AWS) but not sure where to start? Look no further! In this blog post, we'll explore 10 free projects that you can build using AWS services. These projects cover a range of topics, from serverless computing to machine learning, and everything in between. By the end of this post, you'll have a better understanding of the capabilities of AWS and have some hands-on experience to boot!


Build a Serverless Web Application:

Serverless computing is all the rage these days, and AWS Lambda is at the forefront of this trend. With Lambda, you can run code without provisioning or managing servers, making it easy to build scalable web applications. In this project, you'll learn how to create a simple web application using AWS Lambda and API Gateway. You'll also get familiar with the basics of serverless architecture and how to deploy your application to production. 

Get started here:  https://lnkd.in/gCgdvmYK

Read more »

Labels:

Sunday 20 February 2022

Heroku vs. AWS: Understanding the Differences and Choices in Cloud Deployment

In today's technology-driven world, cloud computing has become the backbone of modern application deployment. Cloud platforms offer scalability, flexibility, and cost-efficiency, allowing businesses and developers to focus on building and delivering great products. Two popular cloud platforms, Heroku and AWS (Amazon Web Services), have gained immense popularity in the development community. In this blog post, we will explore the differences between Heroku and AWS and help you understand which platform may be the right choice for your cloud deployment needs.

Heroku Overview:

Heroku is a fully managed Platform-as-a-Service (PaaS) cloud platform that simplifies the process of deploying, managing, and scaling applications. It abstracts away much of the underlying infrastructure complexities, making it an ideal choice for developers who want to focus on building their applications rather than managing servers.

AWS Overview:

Amazon Web Services (AWS) is a comprehensive cloud platform offering a wide range of Infrastructure-as-a-Service (IaaS), Platform-as-a-Service (PaaS), and Software-as-a-Service (SaaS) solutions. AWS provides various cloud services, including compute, storage, databases, networking, machine learning, and more, giving users complete control over their infrastructure.

Comparing Heroku and AWS:

a. Ease of Use:

Heroku: With its simple and intuitive interface, Heroku is incredibly easy to use. Developers can deploy applications with a single command, and the platform takes care of the rest, including scaling and load balancing.

AWS: AWS offers a wide array of services and features, which can be overwhelming for beginners. While AWS provides extensive documentation and tools, it may require more configuration and setup compared to Heroku.

Example - Deploying a Flask Application:

Heroku:

  1. Install Heroku CLI and login.
  2. Navigate to your Flask project directory.
  3. Create a requirements.txt file with project dependencies.
  4. Create a Procfile to define the web process.
  5. Use git to commit changes.
  6. Deploy the application using git push heroku master.

AWS:

  1. Create an EC2 instance with the desired OS and configuration.
  2. SSH into the instance and set up the environment (e.g., Python, Flask, Gunicorn, etc.).
  3. Install and configure a web server like Nginx or Apache.
  4. Set up security groups and inbound rules.
  5. Deploy the Flask application manually or use a CI/CD pipeline.

b. Scalability:

Heroku: Heroku automatically scales applications based on demand, making it suitable for small to medium-sized projects. However, it may have limitations for high-traffic enterprise applications.

AWS: AWS provides on-demand scalability and allows users to choose from a wide range of instances, enabling seamless scaling for applications of any size.

Example - Auto Scaling:

Heroku: Heroku automatically handles application scaling, and developers can customize the number of dynos (containers) based on web and worker traffic.

AWS: AWS Auto Scaling allows you to set up policies to automatically adjust the number of instances based on predefined conditions, ensuring optimal resource utilization.

c. Cost:

Heroku: Heroku offers a straightforward pricing model based on dyno hours and add-ons. It is easy to estimate costs, especially for smaller applications. However, costs can increase as the application scales.

AWS: AWS pricing is more granular, with costs varying based on individual services' usage. AWS's pay-as-you-go model allows flexibility, but it can be complex to estimate costs accurately.

Example - Cost Estimation:

Heroku: A simple web application with a single dyno and standard add-ons can cost around $25-50 per month.

AWS: The cost of hosting the same web application on AWS can vary depending on factors such as EC2 instance type, RDS database, S3 storage, and data transfer.


Let's walk through the process of deploying a Django application on both Heroku and AWS to better understand the differences in deployment workflows.

Deploying a Django Application on Heroku:

Step 1: Install Heroku CLI and Login

First, install the Heroku Command Line Interface (CLI) on your local machine and log in to your Heroku account using the command line.

Step 2: Prepare the Django Project

Navigate to your Django project directory and ensure that your project is version-controlled using Git. If not, initialize a Git repository in your project directory.

Step 3: Create a requirements.txt File

Create a requirements.txt file in your project directory, listing all the Python dependencies required for your Django application. Heroku uses this file to install the necessary packages.

Example requirements.txt:

Django==3.2.5

gunicorn==20.1.0

Step 4: Create a Procfile

Create a Procfile in your project directory to declare the command to start your Django application using Gunicorn. This file tells Heroku how to run your application.

Example Procfile:

web: gunicorn your_project_name.wsgi --log-file -

Step 5: Deploy the Application

Commit your changes to the Git repository and then deploy your Django application to Heroku using the following command:

$ git add .

$ git commit -m "Initial commit"

$ git push heroku master


Heroku will automatically build and deploy your application. Once the deployment is successful, you will be provided with a URL where your Django application is hosted.

Deploying a Django Application on AWS:

Step 1: Create an AWS EC2 Instance
Log in to your AWS Management Console and navigate to the EC2 service. Create a new EC2 instance with your desired OS and configuration. Ensure that you select the appropriate security group and inbound rules to allow HTTP traffic.

Step 2: SSH into the EC2 Instance
After creating the EC2 instance, SSH into it using the private key associated with the instance. Install required packages such as Python, Django, and Gunicorn on the EC2 instance.

Step 3: Set Up a Web Server
Install and configure a web server like Nginx or Apache on the EC2 instance. Configure the server to proxy requests to Gunicorn, which will serve your Django application.

Step 4: Deploy the Django Application
Copy your Django project files to the EC2 instance using SCP (Secure Copy Protocol) or any other preferred method. Then, start the Gunicorn process to serve your Django application.

Step 5: Configure Security Groups and Inbound Rules
Ensure that your EC2 instance's security group allows incoming HTTP traffic on port 80 so that users can access your Django application through a web browser.

In this example, we have seen the deployment process of a Django application on both Heroku and AWS. Heroku provided a straightforward and streamlined approach to deployment, while AWS allowed for more control and customization. The decision between Heroku and AWS depends on your project's complexity, scalability needs, and budget considerations. Both platforms offer unique advantages, and understanding the differences will help you make an informed decision that aligns with your specific project requirements. 

Labels: , ,

Wednesday 13 March 2024

The Git & Github Bootcamp Part 2- Master on essentials and the tricky bits: rebasing, squashing, stashing, reflogs, blobs, trees, & more!


Working With Branches

1. Introducing Branches

Branches in Git allow you to diverge from the main line of development and work independently on different tasks without affecting each other. It’s like working on a different copy of the project which can later be merged back into the main project.

2. The Master Branch (Or Is It Main?)

Traditionally, the default branch in Git repositories was called “master.” However, there’s a shift towards using “main” as the default branch name for new repositories. It’s important to know the name of your default branch, as it’s the base for new branches and often serves as the stable version of your project.

Read more »

Labels:

The Git & Github Bootcamp Part 5 - Master on essentials and the tricky bits: rebasing, squashing, stashing, reflogs, blobs, trees, & more!


GitHub Grab Bag: Odds & Ends

GitHub Repo Visibility: Public Vs. Private

  • Public repositories are visible to everyone on the internet, and anyone can contribute to your project.
  • Private repositories are hidden from the public and only accessible to you and the people you choose to share access with.

Adding GitHub Collaborators

To collaborate with others on private projects, you need to add them as collaborators:

  1. Go to your repository on GitHub.
  2. Click on “Settings” > “Manage access” > “Invite a collaborator.”
  3. Enter their GitHub username and send the invite.
Read more »

Labels:

Tuesday 26 March 2024

5 Fresh Project Ideas for Data Analysts to Explore

The world of data analysis is dynamic and continuously evolving. For data analysts looking to expand their portfolio or gain new insights, working on real-world datasets can be both enlightening and challenging. Here are five fresh project ideas that offer a wealth of information to analyze, visualize, and model.

🏠 Airbnb Open Data

Dataset: Airbnb Open Data on Kaggle
Project: Analyze the vibrant homestay landscape of New York City through Airbnb’s open data. From pricing strategies to seasonal availability, dive deep into what makes a successful Airbnb listing stand out in the bustling Big Apple.

Read more »

Tuesday 19 March 2024

Dive into Live: Exciting SQL Live DataSet to Enhance Your Skills


SQL, or Structured Query Language, is the backbone of data management and analysis in today’s data-driven world. Whether you’re a budding data analyst, a seasoned database manager, or somewhere in between, honing your SQL skills is essential. What better way to sharpen these skills than by diving into real-world datasets? Here, we present a collection of SQL project ideas across various domains, complete with datasets to get you started. These projects are designed to challenge your understanding of SQL and provide practical experience with real-world data.

Read more »

Labels:

Wednesday 13 March 2024

The Git & Github Bootcamp Part 6 - Master on essentials and the tricky bits: rebasing, squashing, stashing, reflogs, blobs, trees, & more!


Cleaning Up History with Interactive Rebase

1. Introducing Interactive Rebase

Interactive rebase (git rebase -i) allows you to modify commits in a more controlled manner. It opens a text editor showing a list of commits from the current branch relative to the specified base commit, along with options for how to alter each commit.

2. Rewording Commits With Interactive Rebase

To reword a commit means to change the commit message without altering the snapshot.

  • Start an interactive rebase for the last n commits: git rebase -i HEAD~n.
  • In the editor that opens, change pick to reword (or r) next to the commit you want to reword.
  • Save and close the editor. Git will open a new editor window for each commit you chose to reword.
  • Update the commit message, save, and close the editor to continue.
Read more »

Labels: