Results: 1580
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
Merge Objects
let obj1 = { name: "John" };
   let obj2 = { age: 114 };
let newObj = { . . .obj1, . . .obj2 };
// Returns {  name: "John", age: 114 }  
by Tinatin Kvinikadze
2 years ago
0
JavaScript
problem solving
0

<?php

function numbers($price, $discount) {
    
    return $price - $price/100*$discount;
}


echo numbers(80,20);  //result - "80-80/100*20=64"
echo numbers(100,50); //result - "100-100/100*50=50"
echo numbers(200,80); //result - "200-200/100*80=40"


by Gvanca Gharibashvili
2 years ago
0
PHP
0

let numbers = [2, 3, 5, 6, 7, 8]
let myfavouritenumbers = ["1"," 2"," 3", "4"," 5"]
let myfavouritecolors = ["red", "green", "blue"]
let mynumbers = 1,78



//"push"-adds the given element to the array
//result- red, green, blue, yellow
myfavouritecolors.push("yellow")



//"splice"-Removes the element whose "address" we gave
//result- 1,2,4,5
myfavouritenumbers.splice(2, 1)



//[3]- find third number in array
//result-"6"
numbers[3]



//"tofixed"-Rounds the number
//rersult- "2"
mynumbers.tofixed()

by Gvanca Gharibashvili
2 years ago
0
JavaScript
0

let name="giorgi"
let age= 27

function gender() {
alert "men"
}
We can write all this as an object

let human= {
         name: "giorgi",
         age: 27,
         gender: "men",

//we can make function in objects too

     men() {
               alert "hello"
        },

//also we can make object in objects 

          favanimal {
              first:"dog",
              second:"cat"
     }   
}
by Gvanca Gharibashvili
2 years ago
0
JavaScript
0
 1)    function proposal(thename, thecolor) {

// "+"-means conjunction, for example sentence 1 is sentence 2 in this case
// "alert"- is like "$x" in php

alert ("my name is" + thename + "and my favourite color is " + thecolor + ".")
 
}
proposal("gvanca", "green")
//result- "my name is gvanca and my favourite color is green"



2)     function number(x,) {

return 8 * x 

}

let number1 = number(2)

alert (number1)
//result- 8 * 2=16 so the answer is "16"
by Gvanca Gharibashvili
2 years ago
0
JavaScript
0
fresh and seed single table and seeder without loosing data in another tables in laravel
1) add this code
 DB::statement('SET FOREIGN_KEY_CHECKS=0;');
 DB::table('rcsa_timeline_statuses')->truncate();
 DB::statement('SET FOREIGN_KEY_CHECKS=1;');
2) Seed database
php artisan db:seed --class=RcsaProgressSeederĀ 
by Luka Tatarishvili
2 years ago
0
Laravel
MySQL
0
Get the first and last days of the current month
Gets the first and last days of the current month and passes it to the request using
start_date
and
end_date
variables. The following script should be located in
Pre-request Script
let date = new Date();
let year = date.getFullYear()
let month = ("0" + (date.getMonth() + 1)).slice(-2)
let start_date = year+'-'+month+'-01';
let days = new Date(year, month, 0).getDate()
let end_date = year+'-'+month+'-'+days;

pm.collectionVariables.set("start_date", start_date);
pm.collectionVariables.set("end_date", end_date);
Get URL of the request
https://httpbin.org/get?start_date={{start_date}}&end_date={{end_date}}
by Valeri Tandilashvili
2 years ago
0
Postman
0
PHP / JavaScript differences
PHP variable declaration
$variable = 1;
JS alternative
let variable = 1;
PHP - check if the variable exists
if (isset($variable))
JS alternative
if (typeof variable !== "undefined")
PHP count array elements
$count = count([2, 3, 4]);
JS alternative
let count = [2, 3, 4].length;
PHP count letters in the string
$len = strlen('some string');
JS alternative
let len = 'some string'.length;
PHP absolute value of a given number
$variable = abs(-5);
JS alternative
let variable = Math.abs(-5);
PHP - power of a number
$square = pow(5, 2);
JS alternative
let square = Math.pow(5, 2);
PHP - square root of a number
$square_root = sqrt(16);
JS alternative
let square_root = Math.sqrt(16);
PHP - minimum number
$max = min(2, 3, 4);
JS alternative
let max = Math.min(2, 3, 4);
PHP - maximum number
$max = max([2, 3, 4]);
JS alternative
let max Math.max(...[2, 3, 4])
PHP calculates sum of the array elements
$sum = array_sum([2, 3, 4]);
JS alternative
let sum = 0;
let arr = [1, 2, 3];
for (let value of arr) {
    sum += value;
}
Another way to calculate the same
let arr = [1, 2, 3];
let sum = 0;
let len = arr.length;
for (let i = 0; i < len; sum += arr[i++]);
PHP - string position
$pos = strpos('Hello world', 'world');
JS alternative
let pos = 'Hello world'.indexOf('world');
PHP - edit letter in a string
$string[4] = 'X';
JS alternative
string = string.substring(0, 4) + 'X' + string.substring(5);
PHP convert the variable to integer
$variable = intval(5.5);
JS alternative
let variable = parseInt(5.5);
PHP - explode the sentence
$sentence = "Lorem ipsum dolor st amet";
$words = explode(" ", $sentence);
JS alternative
let sentence = "Lorem ipsum dolor st amet";
let words = sentence.split(" ");
by Valeri Tandilashvili
2 years ago
0
PHP
1
Postman Snippets
Get variables
pm.environment.get("variable_key");
pm.globals.get("variable_key");
pm.variables.get("variable_key");
pm.collectionVariables.get("variable_key");
Set variables
pm.environment.set("variable_key", "variable_value");
pm.globals.set("variable_key", "variable_value");
pm.collectionVariables.set("variable_key", "variable_value");
Unset variables
pm.environment.unset("variable_key");
pm.globals.unset("variable_key");
pm.collectionVariables.unset("variable_key");
Send a request
pm.sendRequest("https://postman-echo.com/get", function (err, response) {
    console.log(response.json());
});
Status code: Code is 200
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});
Response body: Contains string
pm.test("Body matches string", function () {
    pm.expect(pm.response.text()).to.include("string_you_want_to_search");
});
Response body: JSON value check
pm.test("Your test name", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.value).to.eql(100);
});
Response body: is equal to a string
pm.test("Body is correct", function () {
    pm.response.to.have.body("response_body_string");
});
Response headers: Content-Type header check
pm.test("Content-Type is present", function () {
    pm.response.to.have.header("Content-Type");
});
Response time is less than 200ms
pm.test("Response time is less than 200ms", function () {
    pm.expect(pm.response.responseTime).to.be.below(200);
});
Status code: Successful POST request
pm.test("Successful POST request", function () {
    pm.expect(pm.response.code).to.be.oneOf([201, 202]);
});
Status code: Code name has string
pm.test("Status code name has string", function () {
    pm.response.to.have.status("Created");
});
Response body: Convert XML body to a JSON Object
var jsonObject = xml2Json(responseBody);
Use Tiny Validator for JSON data
var schema = {
    "items": {
        "type": "boolean"
    }
};
var data1 = [true, false];
var data2 = [true, 123];
pm.test('Schema is valid', function () {
    pm.expect(tv4.validate(data1, schema)).to.be.true;
    pm.expect(tv4.validate(data2, schema)).to.be.true;
});
by Valeri Tandilashvili
2 years ago
0
Postman
0

$ git commit -m "Something terribly misguided" # (0: Your Accident)
$ git reset HEAD~                              # (1)
[ edit files as necessary ]                    # (2)
$ git add .                                    # (3)
$ git commit -c ORIG_HEAD                      # (4)

The main command which is removing last commit and back ups files in staging area is
$ git reset HEAD~ 
by Luka Tatarishvili
2 years ago
0
Git
0
Results: 1580