Snippets Collections
Practice Queries : 

    1.  Find the names of sailors who have reserved boat number 103

    2.   Find the names of sailors who have never reserved boat number 103

    3.   Find the names of sailors who have reserved a red boat

    4. Find the names and ages of all sailors.

    5. Find all sailors with rating > 7.

    6.  Find the colors of boats reserved by Lubber

    7.  Find the names of sailors who have reserved at least one boat

    8.   Find the names of sailors who have reserved a red or a green boat

    9.  Find the names of sailors who have reserved both a red and a green boat
 
    10.  Find the names of sailors who have reserved a red but not a green boat

    11.  Find the names of sailors who have reserved at least two different boats

    12.   Find the sids of sailors with age over 20 who have not reserved a red boat

    13.   Find the names of sailors who have reserved all boats

    14.  Find the names of sailors who have reserved all boats called Interlake

    15.  Find the sailor name boat id and reservation date for each reservation

    16.  Find sailors who have reserved all red boats

    17.   Find the sids of sailors who have reserved a red boat;

    18. Find the ages of sailors whose name begins and ends with B and has at least 3 characters.

    19.  Find the ages of sailors whose name begins and ends with B and has at least three characters

    20.  Find the sids of all sailors who have reserved red boats but not green boats

    21. Find the average age of all sailors

    22. Find the average age of sailors with a rating of 10

    23. Count the number of sailors

    24.  Count the number of different sailor names

    25.   Find the colors of boats reserved by Albert.
function undefinedVariableExample() {
    echo $undefinedVar; // Causes an error
}
	// Avoid this
function badFunction() {
    global $someGlobalVar;
    // ... do something with $someGlobalVar
}

// Prefer this
function betterFunction($someVar) {
    // ... do something with $someVar
}
$globalVar = 42;

function modifyGlobalVar() {
    // Incorrect: $globalVar here would create a new local variable
    $globalVar = 10;
    echo $globalVar; // Output: 10 (local variable)
}

modifyGlobalVar();
echo $globalVar; // Output: 42 (global variable is not modified)
$variable = 10; // Global variable

function shadowingExample() {
    $variable = 5; // Local variable with the same name
    echo $variable; // Output: 5
}

shadowingExample();
echo $variable; // Output: 10 (global variable is not modified)
$globalVariable = 42; // Global variable

function exampleFunction() {
    global $globalVariable;
    echo $globalVariable;
}

exampleFunction(); // Output: 42
echo $globalVariable; // Output: 42
function exampleFunction() {
    $localVariable = 42; // Local variable
    echo $localVariable;
}

// This will cause an error because $localVariable is not accessible here
echo $localVariable;
<?php
function addNumbers($a, $b) {
    $sum = $a + $b;
    return $sum;
}

// Calling the function and storing the result in a variable
$result = addNumbers(5, 3);

// Displaying the result
echo "The sum is: $result";
?>
<?php
function greetUser($name) {
    echo "Hello, $name!";
}

// Calling the function with a parameter
greetUser("John");
?>
<?php
function sayHello() {
    echo "Hello, World!";
}

// Calling the function
sayHello();
?>
function functionName(parameters) {
    // Function code goes here
}
Count: 1
Count: 2
Count: 3
Count: 4
Count: 5
$counter = 1;

do {
    echo "Count: $counter <br>";
    $counter++;
} while ($counter <= 5);
do {
    // code to be executed
} while (condition);
for ($i = 1; $i <= 5; $i++) {
    if ($i == 3) {
        continue; // skip the rest of the loop for $i equals 3
    }
    echo $i . " ";
}
// Output: 1 2 4 5
for ($i = 1; $i <= 10; $i++) {
    if ($i == 5) {
        break; // exit the loop when $i equals 5
    }
    echo $i . " ";
}
// Output: 1 2 3 4
switch (expression) {
    case value1:
        // code block 1
        break;
    case value2:
        // code block 2
        break;
    case value3:
        // code block 3
        break;
    default:
        // default code block
}
if (condition1) {
    // code block 1
} elseif (condition2) {
    // code block 2
} elseif (condition3) {
    // code block 3
} else {
    // default code block
}
$day = "Monday";

switch ($day) {
    case "Monday":
        echo "It's the start of the week.";
        break;
    case "Friday":
        echo "It's almost the weekend!";
        break;
    default:
        echo "It's a regular day.";
}
switch (expression) {
    case value1:
        // code to be executed if expression matches value1
        break;
    case value2:
        // code to be executed if expression matches value2
        break;
    // additional cases as needed
    default:
        // code to be executed if none of the cases match
}
// Print numbers from 1 to 5 using a while loop
$i = 1;

while ($i <= 5) {
    echo $i . " ";
    $i++;
}
while (condition) {
    // code to be executed as long as the condition is true
}
// Print numbers from 1 to 5
for ($i = 1; $i <= 5; $i++) {
    echo $i . " ";
}
for (initialization; condition; iteration) {
    // code to be executed during each iteration
}
<?php
$temperature = 25;

if ($temperature > 30) {
    echo "It's hot outside!";
} elseif ($temperature >= 20 && $temperature <= 30) {
    echo "The weather is pleasant.";
} else {
    echo "It's cold outside.";
}
?>
php
if (condition1) {
    // code to be executed if condition1 is true
} elseif (condition2) {
    // code to be executed if condition2 is true
} else {
    // code to be executed if none of the conditions are true
}
if (condition) {
    // code to be executed if the condition is true
} else {
    // code to be executed if the condition is false
}
if (condition) {
    // code to be executed if the condition is true
}
sudo /opt/lampp/lampp start
sudo ./xampp-linux-*-installer.run
chmod +x xampp-linux-*-installer.run
#include <iostream>
using namespace std;
int main()
{
    int n, r, i, t, q, w, a, s, d;
    cin>>r;
    for(i=1;i<=r;i++)
    {
        cin>>n;
        q=w=a=s=d=0;
        t=n%60;
        q+=n/60;
        if(t>35)
        {
            q++;
            if(t%10<5)
            {
                a+=6-t/10;
                s+=t%10;
            }
            else
            {
                a+=(60-t)/10;
                d+=(60-t)%10;
            }
        }
        else
        {
            if(t%10<=5)
            {
                w+=t/10;
                s+=t%10;
            }
            else
            {
                w+=t/10+1;
                d+=10-t%10;
            }
        }
        cout<<q<<" "<<w<<" "<<a<<" "<<s<<" "<<d<<"\n";
    }
    return 0;
}
ocelotapigw:
    container_name: ocelotapigw
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    depends_on: 
      - catalog.api
      - discount.api
      - basket.api
      - ordering.api
    ports:
      - "8010:80"

ordering.api:
  container_name: ordering.api
  environment:
    - ASPNETCORE_ENVIRONMENT=Development
    - "ConnectionStrings: OrderingConnectionString=Server=orderDB;Database=OrderDb;User Id=sa;Password=SwN12345678; TrustServerCertificate=True"
    - "EventBusSettings:HostAddress=amqp://guest:guest@localhost:5672"
  depends_on: 
    - orderdb
    - rabbitmq
  ports:
    - "8004:80"
Right Click on Project -> Add -> Container Orchestration Support -> Docker Compose -> Linux
<?php
// Konfigurasi koneksi ke database
$servername = "localhost"; // Ganti dengan nama server Anda
$username = "adminmaster"; // Ganti dengan username database Anda
$password = "DTCMtolong313"; // Ganti dengan password database Anda
$dbname = "master"; // Ganti dengan nama database Anda

// Membuat koneksi
$conn = new mysqli($servername, $username, $password, $dbname);

// Memeriksa koneksi
if ($conn->connect_error) {
    die("Koneksi gagal: " . $conn->connect_error);
}

// Ambil term dari input pengguna
//$term = $_POST["term"];
$term = mysqli_real_escape_string($conn, $_POST['term']);

// Query untuk mengambil data nama lengkap dari master_data_staff dengan jantina = 0
$sql = "SELECT DISTINCT nama_lengkap FROM master_data_staff WHERE jantina = 0 AND nama_lengkap LIKE '%$term%' LIMIT 10";
$result = $conn->query($sql);

// Menyimpan hasil query dalam bentuk array
$data = array();
if ($result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        $data[] = $row["nama_lengkap"];
    }
}

// Mengirimkan data dalam format JSON
echo json_encode($data);

// Menutup koneksi database
$conn->close();
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script>
        $(document).ready(function() {
            $("#nama_suami").autocomplete({
                source: function(request, response) {
                    $.ajax({
                        url: "fetch_nama_lengkap.php",
                        type: "POST",
                        dataType: "json",
                        data: {
                            term: request.term
                        },
                        success: function(data) {
                            response(data);
                        }
                    });
                },
                minLength: 2 // Jumlah minimum karakter sebelum autocomplete mulai
            });
        });
    </script>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Edit Staff</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="adminer.css" />

<script>
        $(document).ready(function() {
            $("#nama_suami").autocomplete({
                source: function(request, response) {
                    $.ajax({
                        url: "fetch_nama_lelaki.php",
                        type: "POST",
                        dataType: "json",
                        data: {
                            term: request.term
                        },
                        success: function(data) {
                            response(data);
                        }
                    });
                },
                minLength: 2, // Jumlah minimum karakter sebelum autocomplete mulai
                select: function(event, ui) {
                    $("#nama_suami").val(ui.item.value);
                    $.ajax({
                        url: "fetch_id_number.php",
                        type: "POST",
                        dataType: "json",
                        data: {
                            nama_lengkap: ui.item.value
                        },
                        success: function(data) {
                            $("#id_suami").val(data.id_number);
                        }
                    });
                    return false;
                }
            });
        });
    </script>
// Slick Script
function site_styles() {
	wp_register_style('slick', 'https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.css', array(), false, 'all');
    wp_enqueue_style('slick');
	wp_register_style('slick-theme', 'https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick-theme.css', array(), false, 'all');
    wp_enqueue_style('slick-theme');
}
add_action('wp_enqueue_scripts', 'site_styles');

// Slick Script
add_action('wp_body_open', function() { ?>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js"></script>
<?php });

***
  
<script type="text/javascript">    
	jQuery('.history-timeline').slick({
	  dots: true,
	  infinite: false,
	  speed: 300,
	  slidesToShow: 3,
	  slidesToScroll: 3,
	  responsive: [
	    {
	      breakpoint: 1024,
	      settings: {
	        slidesToShow: 2,
	        slidesToScroll: 2
	      }
	    },
	    {
	      breakpoint: 767,
	      settings: {
	        slidesToShow: 1,
	        slidesToScroll: 1
	      }
	    }
	    // You can unslick at a given breakpoint now by adding:
	    // settings: "unslick"
	    // instead of a settings object
	  ]
	});
</script>
// C++ code to find count of largest consectutive subset
#include <iostream>
#include <stdlib.h>
#include <unordered_set>
using namespace std;

int main() {
    int sz, num;
    unordered_set<int> numbers;
    int maxLen = 0;
    cin>>sz;
    for (int i=0;i<sz;i++) {
        cin>>num;
        numbers.insert(num);
    }
    
    for (int i : numbers) {
        if (numbers.find(i-1) == numbers.end()) {
            int temp = i;
            while (numbers.find(temp) != numbers.end()) temp++;
            
            if (maxLen < (temp-i)) maxLen = temp-i;
        }
    }

    cout<< maxLen;
    return 0;
}
<?php
  $greeting = "Hello, ";
  $name = "John";

  $greeting .= $name;

  echo $greeting; // Outputs: Hello, John
?>
<?php
  $firstName = "John";
  $lastName = "Doe";

  $fullName = $firstName . " " . $lastName;

  echo $fullName; // Outputs: John Doe
?>
def qo_shish(son1, son2):
    return son1 + son2

# Test qilish
son1 = 5
son2 = 3
natija = qo_shish(son1, son2)
print(f"{son1} + {son2} = {natija}")
 docker-compose -f docker-compose.yml -f docker-compose.override.yml down
star

Mon Mar 04 2024 08:08:41 GMT+0000 (Coordinated Universal Time) https://download-directory.github.io/

@yadhu

star

Mon Mar 04 2024 07:23:11 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/cpp-programming/online-compiler/

@PRAttAY2003 #c++

star

Mon Mar 04 2024 05:57:11 GMT+0000 (Coordinated Universal Time)

@dsce

star

Mon Mar 04 2024 02:04:32 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 02:01:37 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 01:59:15 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 01:57:37 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 01:55:50 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 01:53:34 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 01:43:43 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 01:42:27 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 01:36:00 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 01:34:40 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 01:21:10 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 01:20:06 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 01:18:44 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 01:14:30 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 01:12:37 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 01:08:02 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 01:06:03 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 01:01:56 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 01:00:56 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 00:52:48 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 00:51:42 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 00:48:57 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 00:47:40 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 00:46:10 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 00:34:17 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 00:32:51 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 00:28:23 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 00:27:12 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 00:12:42 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 00:07:55 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Mon Mar 04 2024 00:04:14 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Sun Mar 03 2024 22:56:06 GMT+0000 (Coordinated Universal Time) https://www.acmicpc.net/submit/19940/74359993

@hajinjang0714

star

Sun Mar 03 2024 13:33:57 GMT+0000 (Coordinated Universal Time)

@abhikash01

star

Sun Mar 03 2024 13:32:45 GMT+0000 (Coordinated Universal Time)

@abhikash01

star

Sun Mar 03 2024 13:21:49 GMT+0000 (Coordinated Universal Time)

@adnanbasalamah #php

star

Sun Mar 03 2024 13:20:52 GMT+0000 (Coordinated Universal Time)

@adnanbasalamah #javascript

star

Sun Mar 03 2024 13:19:22 GMT+0000 (Coordinated Universal Time)

@adnanbasalamah #javascript

star

Sun Mar 03 2024 11:14:02 GMT+0000 (Coordinated Universal Time)

@omnixima #jquery

star

Sun Mar 03 2024 07:45:26 GMT+0000 (Coordinated Universal Time)

@VS_codes #c++

star

Sat Mar 02 2024 16:48:11 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Sat Mar 02 2024 16:43:17 GMT+0000 (Coordinated Universal Time)

@codewarrior

star

Sat Mar 02 2024 10:21:14 GMT+0000 (Coordinated Universal Time) https://p5play.org/lang/ja/learn/index.html

@mirainoschool

star

Sat Mar 02 2024 07:12:03 GMT+0000 (Coordinated Universal Time)

@khanwins

star

Sat Mar 02 2024 05:32:24 GMT+0000 (Coordinated Universal Time)

@abhikash01

star

Sat Mar 02 2024 05:32:06 GMT+0000 (Coordinated Universal Time)

@abhikash01

star

Sat Mar 02 2024 05:32:06 GMT+0000 (Coordinated Universal Time)

@abhikash01

star

Sat Mar 02 2024 05:31:23 GMT+0000 (Coordinated Universal Time)

@abhikash01

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension