Skip to content

Instantly share code, notes, and snippets.

these commands are specific to mongo shell (mongosh command):

  1. show dbs ==> shows list of all available databases
  2. use flights ==> when starting to insert data in this DB, then flights db will be created on the fly.
  3. db.flightData.insertOne({"name":"f1"})
  4. db.flightData.find(); ==> shows all data
  5. db.flightData.find().pretty(); ==> shows all data in pretty format
  6. mongoDB uses BSON (which is binary json) for storing data in database.
  1. in blade template engine: {{ $x }} is equal to <?php echo $x ?>
  2. behind the scenes the blade code is compiled to vanilla php.
  3. it is possible to define conditional aggregate in laravel eloquent queries. for example:

suppose we have a table called requested_features which has columns named: title and status.
the status column can has three distinct values: 1.planned 2.requested 3.completed
if we want to count number of records which has "status=planned" and "status=requested" and "status=completed"
then the best solution is:

@zahra-ove
zahra-ove / php80_attributes.php
Created June 16, 2024 08:19 — forked from ziadoz/php80_attributes.php
Using PHP 8.0 Attributes/Annotations To Decorate Functions
<?php
// Attributes (AKA Annotations).
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_FUNCTION)]
class CharDecoratorAttribute
{
public function __construct(protected string $char) // Constructor Property Promotion
{
}
public function decorate(Closure $fn): Closure
@zahra-ove
zahra-ove / devops-with-laravel-toc.md
Created May 31, 2024 14:12 — forked from mmartinjoo/devops-with-laravel-toc.md
DevOps with Laravel Table of Contents

Topics coming in the next edition:

  • ✅ Load balancers from scratch (published on 10th of October)
  • ✅ Terraform (published on 12th of November)
  • HELM

Fundamentals - 208 pages (Basic package)

Building a pipeline

nginx

  • Serving static content
  • CGI, FastCGI, php-fpm

----------------installing React---------------------

  1. node must be installed on your system. when installing node, npm also get installed.
  2. way1: npx create-react-app <your_project_name>

**note:
The main difference between "npm create-react-app" and "npx create-react-app" lies in how they are used to create a new React application.

  1. all python files should have .py extension.
  2. interesting note: in this code, * is printed 10 time:
print("*" * 10)
  1. there is two different version for python:
  • python2
  • python3

Most PHP programmers have used PHP strictly in a web server environment. In such an environment, PHP is a CGI/Fast GGI or server module called and controlled by the HTTP server (usually Apache, IIS, Nginx, or similar)\

The HTTP server receives a request for a PHP-based web page and calls the PHP process to execute it, which usually returns output to the HTTP server to be sent on to the end user.

  1. create a copy from a table:
    suppose we have already a table named: orders and we want to make a copy from this table which name will be order_archived.\

    CREATE TABLE order_archived AS 
        SELECT * FROM orders

    but please note: this way does not copy some column attributes like primary key.

Big-O time complexity:

  1. big O is used to describe the performance of an algorithm. it determines how scalable an algorithm is. ==> we want to figure out how the algorithm slows down as size of arguments grows larger.

run time complexity

O(1) — Constant Time:
O(log n) — Logarithmic Time: The number of steps it takes to accomplish a task are decreased by some factor with each step.
O(n) — Linear Time: The number of of steps required are directly related (1 to 1).
O(n²) — Quadratic Time: The number of steps it takes to accomplish a task is square of n.\