This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Exercises from Workshop 2015 day 1 | |
| Simple Quyering | |
| 'id', 'name' of countries | |
| 'id', 'population' of countries | |
| sum of 'population' of all countries (method 1) | |
| sum of 'population' of all countries (method 2) | |
| count of continents (with Collection) | |
| count of continents (with PHP) | |
| Associations | |
| Countries speaking certain language |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function validate_email($email) | |
| { | |
| $email_host = array_pop(explode('@', $email)); | |
| if (checkdnsrr($email_host, 'MX)) { | |
| return true; | |
| } else { | |
| return false; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| docker run -it --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:7.0-cli php file.php |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class dnsRecord { | |
| private $domain = ''; | |
| private $subdomains = []; | |
| private $type = 'MX'; | |
| private $filter = null; | |
| private $check; | |
| public function __construct($domain = '', $subdomains = [], $type = '', $filter = null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dig mail.yandex.ru @ns1.yandex.ru A +short |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $arr = [ | |
| ['id' => 123, 'name' => 'Joe'], | |
| ['id' => 345, 'name' => 'Sally'] | |
| ]; | |
| array_column($arr, null, 'id'); // [ 123 => ['id' => 123, 'name' => 'Joe'] ... | |
| array_column($arr, 'name', 'id'); // [ 123 => 'Joe', 345 => 'Sally' ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function array_map_filter($fn, ...$arr) | |
| { | |
| return array_filter(array_map($fn, ...$arr)); | |
| } | |
| /////////////////////////////////////////// | |
| $users = [ | |
| [ 'id' => 1, 'name' => 'Joe' ], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $users = [ 'Joe', 'Bob', 'Sam' ]; | |
| array_map(function ($name, $position) { | |
| return compact('position', 'name'); | |
| }, $users, range(1, count($users))); | |
| // [ position => 1, name => 'Joe' ] | |
| // [ position => 2, name => 'Bob' ] | |
| // [ position => 3, name => 'Sam' ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Controller views are very simple | |
| class HomePageController extends React.Component { | |
| // Normal Flux store listening | |
| componentDidMount() { | |
| Store1.on('change', this.onStoreChange); | |
| Store2.on('change', this.onStoreChange); | |
| } | |
| onStoreChange() { |
OlderNewer