Skip to content

Instantly share code, notes, and snippets.

@sorokadima
sorokadima / Kill rails server by PID.md
Created January 6, 2021 14:17
Kill rails server by PID

lsof -wni tcp:3000

kill -9 PID

@sorokadima
sorokadima / Yii2 dropdown.php
Last active August 10, 2020 08:16
Yii2 dropdown
<?php
[
'attribute' => 'foo',
'value' => 'foo',
'label' => Yii::t('adminpanel', 'Foo'),
'filter' => Foo::getFooList(),
'filterType' => GridView::FILTER_SELECT2,
'filterOptions' => ['style' => 'min-width: 85px'],
'filterWidgetOptions' => [
@sorokadima
sorokadima / PHP current timestamp (php get current date).php
Created August 5, 2020 12:30
PHP current timestamp (php get current date)
<?php
(new DateTime())->getTimestamp();
@sorokadima
sorokadima / PHPdoc example.php
Created August 5, 2020 11:16
PHPdoc example (php doc, documentation comment)
<?php
/**
* Set foo field
*
* @param boolean $baz
*
* @return boolean
*/
@sorokadima
sorokadima / User.php
Created August 5, 2020 09:27
Yii2 model custom attribute getter. (custom property)
<?php
// model
public function getFoo() {
return true;
}
@sorokadima
sorokadima / web.php
Created August 3, 2020 09:15
Yii2 Mail Debug to file
<?php
// config/web.php:186
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'messageClass' => 'app\components\Message',
'htmlLayout' => '@app/modules/account/mail/layouts/html',
'useFileTransport' => true, // <--
],
@sorokadima
sorokadima / Yii2 is null MySQL Expression.php
Last active July 31, 2020 08:24
Yii is null MySQL Expression
<?php
// new \yii\db\Expression('ISNULL(foo)'),
if ($this->foo === '0') {
$query->andFilterWhere(['is', 'foo', new \yii\db\Expression('null')])
->orFilterWhere(['=', 'foo', $this->foo]);
}
@sorokadima
sorokadima / CSS Hover.md
Created July 30, 2020 09:36
CSS Hover наводиш на один елемент а підсвічується інший
@sorokadima
sorokadima / Yii2 DataColumn render HTML.php
Created July 29, 2020 08:11
Yii2 DataColumn render HTML
<?php
// ...
[
'class' => 'kartik\grid\DataColumn',
'attribute' => 'foo',
'format' => 'html', // <=====
'value' => function (Limit $model) {
return '-';
@sorokadima
sorokadima / bootstrap.txt
Created July 15, 2020 07:27
Bootstrap margin only for sm
mt-3 mt-sm-0