Skip to content

Instantly share code, notes, and snippets.

View lavandosovich's full-sized avatar
💭
PunnIng

Ilya Lebedev lavandosovich

💭
PunnIng
  • Saint-Petersburg
View GitHub Profile
@lavandosovich
lavandosovich / install.md
Created May 10, 2017 09:24
COMPOSER installation
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" &&
php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" &&
php composer-setup.php &&
php -r "unlink('composer-setup.php');" 
@lavandosovich
lavandosovich / commands_flags_in_action_docker.md
Last active May 2, 2017 22:50
Container with its finest
sudo docker run -p 8080:3000 -v $(pwd):/var/www -w "/var/www" node npm start
  • -p $p1:$p2
    • p - port
    • $p1 - host port
    • $p2 - container port
  • -v $folder_1:$folder_2
  • v - volume

"Wierd" call of function

<?php
class Foo
{
    function Variable()
    {
        $name = 'Bar';
 $this-&gt;$name(); // This calls the Bar() method, $this-&gt;Bar()
@lavandosovich
lavandosovich / moduling_php.md
Last active May 2, 2017 12:45
PHP: Include vs Require

Difference {

Include

emit warning

Require

emit Fatal Error

@lavandosovich
lavandosovich / php_types.md
Last active May 2, 2017 14:59
PHP typing

PHP type checking

  • is_bool() Boolean One of the two special values, true or false
  • is_integer() Integer A whole number. Alias of is_int() and is_long()
  • is_double() Double A floating point number (a number with a decimal point). Alias
  • of is_float()
  • is_string() String Character data
  • is_object() Object An object
  • is_array() Array An array
  • is_resource() Resource A handle for identifying and working with external resources
@lavandosovich
lavandosovich / poo.md
Last active March 21, 2020 11:51
PHP7 Object Orientetion

OOP in PHP

Declaring class properties or methods as static makes them accessible without needing an instantiation of the class. A property declared as static can not be accessed with an instantiated class object (though a static method can).

Useful keywords:

self - self from the root

parent - parent of the class

static - true self for exact class, static is more agile than self, super useful for inheritance issues

@lavandosovich
lavandosovich / grep.md
Last active August 1, 2017 09:17
Grep

Grep

-i - searches for upper && lower cased
-v word - searches every row without word
-n - shows line number of occurence
-E - grep on steroids || egrep

grep -i "..cen" GNU - searches for all ..cen in GNU
grep "t[wo]o" GPL-3 - searches for too && two in GPL-3, because of [wo], which stands for ||

@lavandosovich
lavandosovich / expirience.md
Last active April 25, 2017 11:51
Expa 25.04

cat /etc/passwd - list system users root:xD928Jhs7sH32:0:0:root:/root:/bin/bash newuser:Xv8Q981g71oKK:1000:100:John Smith:/home/newuser:/bin/bash

pattern - account:password:UID:GID:GECOS:directory:shell

account — имя пользователя password — зашифрованный пароль пользователя UID — идентификационный номер пользователя GID — идентификационный номер основной группы пользователя

@lavandosovich
lavandosovich / Functions.md
Last active May 2, 2017 15:03
Some doc escense

Functoins in PHP

Map passed values

   function add_some_extra(&$string)
    {
        $string .="and somthing extra.\n";
    }
    $str = 'This is a string, ';
    add_some_extra($str);
    echo $str;
@lavandosovich
lavandosovich / list_all_containers.md
Last active April 19, 2017 15:26
List all containers.

Command

sudo docker ps

flags

  • -a all executed
  • -q ids of containers only
  • -l last executed