Skip to content

Instantly share code, notes, and snippets.

View Denilson-Semedo's full-sized avatar
🌴
On vacation

Denilson Tavares Denilson-Semedo

🌴
On vacation
View GitHub Profile

Merging Changes from Master into Your Branch: Rebase vs. Merge

When working on a project with multiple collaborators or branches, integrating changes from the main branch (often master) into your feature branch is a common task. Git offers two primary methods for this: rebase and merge. Both approaches achieve the same goal but have different implications for project history and workflow. Let's explore when to use each method and how to execute them.

Using rebase

Syntax:

git checkout custom_branch
git pull origin master
git rebase master
@Denilson-Semedo
Denilson-Semedo / wpa_supplicant.md
Created April 7, 2024 18:16
WiFi Connection on Linux using wpa_supplicant

Setting up WiFi Connection on Linux using wpa_supplicant

In Linux systems, connecting to a WiFi network often involves configuring wpa_supplicant, a versatile tool for managing WiFi connections. This tutorial will guide you through the process of setting up a WiFi connection using wpa_supplicant on a Linux system.

Prerequisites

  • A Linux distribution installed on your system.
  • wpa_supplicant package installed.
  • Basic knowledge of using the command line interface (CLI).
@Denilson-Semedo
Denilson-Semedo / alembic.md
Last active April 11, 2024 17:42
Annotations About Alembic

Alembic

Alembic is a lightweight database migration tool for usage with the SQLAlchemy Database Toolkit for Python. It started as a small utility to keep track of changes in a project's database schema, but as it grew it became useful to other projects as well, for example to keep track of changes in a project's internal data format, or as a backup tool. It aims to be simple to use, easy to extend, and to support database changes without the need for a full ORM model definition.

Features

  • Can emit ALTER statements to a database in order to change the structure of tables and other constructs
  • Provides a system whereby "migration scripts" may be constructed; each script indicates a particular series of steps that can "upgrade" a target database to a new version, and optionally a series of steps that can "downgrade" similarly, doing the same steps in reverse.
  • Can also output changes as SQL text files
  • A system of "stamping" the database with a revision marker, so that it's possible to detect if a da

venv | Python Virtual Environment

Python Virtual Environment is a tool to keep the dependencies required by different projects in separate places. The venv module provides support for creating lightweight “virtual environments” with their own site directories, optionally isolated from system site directories. Each virtual environment has its own Python binary (which matches the version of the binary that was used to create this environment) and can have its own independent set of installed Python packages in its site directories.

Creating a Virtual Environment

To create a virtual environment, decide upon a directory where you want to place it, and run the venv module as a script with the directory path:

python3 -m venv /path/to/new/virtual/environment

POETRY | PYTHON PACKAGING AND DEPENDENCY MANAGEMENT

Poetry serves as a versatile tool for dependency management and packaging within Python projects. With Poetry, you can effortlessly specify the libraries your project relies on, and it takes care of managing their installation and updates. Moreover, Poetry provides a lockfile mechanism to ensure consistent installs and facilitates project distribution through its build capabilities.

Requirements

Poetry mandates Python 3.8 or higher for its operation. It boasts multi-platform compatibility, aiming to deliver seamless performance across Linux, macOS, and Windows environments.

Installing Poetry

If you haven't installed Poetry yet, you can do so by running the following command in your terminal:

@Denilson-Semedo
Denilson-Semedo / mongo_db.md
Created November 30, 2023 06:01
MongoDB Cheatsheet

MongoDB Cheatsheet

Introduction to MongoDB

Welcome to the MongoDB Cheatsheet – A short and comprehensive guide to MongoDB, the NoSQL database renowned for its flexibility, scalability, and high performance. This cheatsheet is designed to help with the MongoDB implementation in Pyhton.

For more in-depth information and detailed documentation, visit the official MongoDB documentation https://www.mongodb.com/docs/
Here you can access a MongoDB CRUD operations tutorial with Python(Fastapi) https://www.mongodb.com/languages/python/pymongo-tutorial

Key Concepts

@Denilson-Semedo
Denilson-Semedo / postgresql.md
Last active December 28, 2023 18:37
PostgreSQL cheatsheet guide

[review] Schemas

PostgreSQL Cheatsheet

Connection

psql -d database -U username -p port

Also you can use -W to prompt a password
psql -d database -U username -p port -W

Alter Password (Set new password)

urllib

urllib is a Python standard library that provides a set of modules for handling URLs and performing various tasks related to network communication. It allows you to open URLs, retrieve data from web servers, parse URLs, encode and decode URL parameters, handle errors, manage cookies, and more.

The main module in urllib is urllib.request, which provides functions and classes for making HTTP requests, interacting with web servers, and handling responses. With urllib.request.urlopen(), you can open a URL and obtain a file-like object to read the response. This method supports both GET and POST requests, allowing you to send data to the server if needed.

urllib - Python Standard Library Documentation

Function/Method Description Example

httplib2

httplib2 is a Python library that provides a comprehensive HTTP client for making requests and handling responses. It offers a simple and intuitive interface, making it easier to work with HTTP protocols in your Python applications. The library supports both HTTP/1.1 and HTTPS, handling redirects, cookies, authentication, caching, and more.

Installation

To install httplib2 using pip, you can run the following command:

pip install httplib2 
@Denilson-Semedo
Denilson-Semedo / requests.md
Last active June 8, 2023 01:29
Requests Library

Requests Library: Simplifying HTTP Requests in Python

The Requests library is a popular Python library for making HTTP requests and interacting with web services. It provides a simple and intuitive API that allows you to send HTTP requests, handle responses, manage cookies, handle authentication, and much more.

With the Requests library, you can easily perform common HTTP methods such as GET, POST, PUT, DELETE, HEAD, PATCH, and OPTIONS. It supports various features like passing parameters, adding headers, handling response content (including JSON), uploading files, managing cookies, and session management.

The library is widely used due to its user-friendly design, robustness, and extensive documentation. It abstracts the complexities of working with HTTP and provides a high-level interface that makes it straightforward to integrate web services into your Python applications.

Python Requests Documentation