×
Clear all filters including search bar
Valeri Tandilashvili's Personal Professional Blog
<select name="cars" id="cars" multiple>
<option value="volvo1">Volvo1</option>
<optgroup label="Swedish Cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</optgroup>
<optgroup label="German Cars">
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>
<optgroup>
is used to group several options together<header>
- defines a header for a document or section;
<nav>
- defines a set of navigation links;
<main>
- specifies the main content of a document;
<footer>
- defines a footer for a document or section;
<article>
- defines an article;
<section>
- defines a section in a document;
<aside>
- defines content aside from the page content;replacer
let room = {
number: 23
};
let meetup = {
title: "Conference",
participants: [{name: "John"}, {name: "Alice"}],
place: room // meetup references room
};
room.occupiedBy = meetup; // room references meetup
// All the properties (except occupiedBy) are the encoded
document.write( JSON.stringify(meetup, function replacer(key, value) {
return (key == 'occupiedBy') ? undefined : value;
}));
The function will be called for every (key, value)
pair and should return the replaced
value, which will be used instead of the original one. Or undefined
if the value is to be skipped.
...
In our case, we can return value
“as is” for everything except occupiedBy
. To ignore occupiedBy
, the code above returns undefined
.
The result of the code above will be the following:{"title":"Conference","participants":[{"name":"John"},{"name":"Alice"}],"place":{"number":23}}
As we expected all the values are encoded except occupiedBy
JSON schema
is a JSON document that describes other JSON document. It is a specification for JSON based format to define the structure of JSON data- Describes your existing data format
- Defines the structure of a JSON message
- Clear, human- and machine-readable documentation
- Complete structural validation, useful for automated testing
- Complete structural validation, validating JSON message
- Can be used to validate API request and response
parent
and grandparent
clasesclass A {
public static function who() {
echo __CLASS__;
}
}
class B extends A {
public static function who() {
parent::who();
}
}
One way to call grandparent's who
method is to use the grandparent class name A
class C extends B {
public static function who() {
A::who();
}
}
C::who();
Another way is to call who
method of parent class which also calls its parent class (which is grandparent for C
class)class C extends B {
public static function who() {
parent::who();
}
}
C::who();
Posts
php artisan make:controller PostsController
With the following basic content<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class Postscontroller extends Controller
{
//
}
Creates controller and empty methods in it (with appropriate comments)php artisan make:controller PostsController --resource
The methods are:
index()
- Displays a list of the resource.
create()
- Shows the form for creating a new resource
store(Request $request)
- Stores a newly created resource in storage
show($id)
- Displays the specified resource
edit($id)
- Shows the form for editing the specified resource
update(Request $request, $id)
- Updates the specified resource in storage
destroy($id)
- Removes the specified resource from storagefirst-child
to select only the first child element:.my-list li:first-child {
background-color: red;
}
last-child
is used to select the last member from the list:my-list li:last-child {
background-color: blue;
}
nth-child(5)
is used to select nth
element. In the example we select 5th element.my-list li:nth-child(5) {
background-color: yellow;
}
We can also use nth-child(even)
to select even members from the list.my-list li:nth-child(even) {
background-color: grey;
}
p:before {
color: red;
content: "read this carefully";
}
p:after {
color: red;
content: "you have read it! good job";
}
target
- Identifies the application to which the instruction is directed.
2. instruction
- A character that describes the information for the target
application to process.
...
PI's example in real XML document<?xml version="1.0" encoding="UTF-8"?>
<student>
<?sort alpha-ascending?>
<?textinfo whitespace is allowed ?>
<first-name>George</first-name>
<phone.mobile>(011) 123-4567</phone.mobile>
</student>
In this example we have two PIs
1. sort
with value - alpha-ascending
2. textinfo
with value - whitespace is allowed
...
Note: processing instructions can contain any data except the combination ?>
, which is interpreted as a closing delimiterIF
has three parameters:
1 - Condition.
2 - Executes if the condition evaluates to true
3 - Executes if the condition evaluates to false
IF(condition , [expression when true], [expression when false]);
Returns false
because the first parameter 0
evaluates to falseSELECT IF(0, 'true', 'false') AS Boolean
Simple IF
statement in SELECT
clauseSELECT *,
IF(points>=90, "Brilliant", "Lazy") AS class
FROM `students`
ORDER BY points DESC
Nested IF
conditional statement.
Categorizes students based on their pointsSELECT *,
IF(points>=90, "Brilliant", IF(points>=80, "Gold", IF(points>=60, "Silver", "Lazy"))) AS class
FROM `students`
ORDER BY points DESC
Sub-query inside IF
.
Highlights the student with highest pointsSELECT *,
IF(points>=90, IF(points=(SELECT MAX(points) FROM students), "Highest", "Brilliant"), IF(points>=80, "Gold", IF(points>=60, "Silver", "Lazy"))) AS class
FROM `students`
ORDER BY points DESC
IF
statement in WHERE
clause.
Checks mail
if it is not empty otherwise checks mail2
SELECT *
FROM `students`
WHERE IF(LENGTH(mail), mail, mail2) LIKE '%gmail.com%'