Skip to content

Instantly share code, notes, and snippets.

@korniychuk
korniychuk / example.sql
Created October 28, 2015 15:34
SQL join example
/**
* Пользователь
* Без внешного ключа, по этому нет проверки целосности
*/
CREATE TABLE IF NOT EXISTS `user` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255),
`city_id` INT UNSIGNED NOT NULL,
PRIMARY KEY `pk_id`(`id`),
INDEX `city_id_idx` (`city_id` ASC) -- Индекс. Для быстрой выборки
@korniychuk
korniychuk / index.php
Created October 30, 2015 18:50
queenmo local frontend index.php
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../common/config/bootstrap.php');
require(__DIR__ . '/../frontend/config/bootstrap.php');
$config = yii\helpers\ArrayHelper::merge(
@korniychuk
korniychuk / main.php
Created November 4, 2015 15:02
Yii swiftmailer config
<?php
return [
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
'authManager' => [
'class' => 'yii\rbac\DbManager',
],
@korniychuk
korniychuk / count-groupBy-having.sql
Created January 4, 2016 18:28
count & having example
DROP TABLE IF EXISTS `user`;
DROP TABLE IF EXISTS `video`;
CREATE TABLE IF NOT EXISTS `user` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255),
`access` TINYINT UNSIGNED,
PRIMARY KEY `pk_id`(`id`)
) ENGINE = InnoDB;
@korniychuk
korniychuk / sftp-config.json
Created January 9, 2016 18:10
пример настройки sftp
{
// The tab key will cycle through the settings when first created
// Visit http://wbond.net/sublime_packages/sftp/settings for help
// sftp, ftp or ftps
"type": "sftp",
"save_before_upload": true,
"upload_on_save": true,
"sync_down_on_open": true,
@korniychuk
korniychuk / code-ex.php
Last active June 10, 2016 14:48
Задание на собеседование - прокомментировать код
<?php
/**
* Я переписал предложенный код в соответствии с моим комментарием ниже и моим видением(учитывая что остального кода, кроме этого фрагмента я не видел)
*/
class AnyModel extends SomeBaseModel {
/**
* AnyModel constructor.
*
* @param int $userId
#### model:
```php
class Article extends ActiveRecord {
public static tableName() {
return 'article';
}
}
@korniychuk
korniychuk / common\config\main-local.php
Created March 30, 2016 15:34
An easy example how to send feedback emails in yii2 (Advanced template)
<?php
return [
'components' => [
...
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
// send all mails to a file by default. You have to set
@korniychuk
korniychuk / composer.json
Last active April 1, 2016 23:37
Swift mailer simple example
{
"require": {
"swiftmailer/swiftmailer": "@stable"
}
}
@korniychuk
korniychuk / index.js
Created June 14, 2016 18:42
check correct order of the brackets in expression
/**
* @param {string} str testable string
*
* @return {boolean}
*/
function verify(str) {
if (typeof str !== 'string') return false;
var pairs = {
'(' : ')',