Skip to content

Instantly share code, notes, and snippets.

View marcuzy's full-sized avatar
:octocat:

Oleg Krasavin marcuzy

:octocat:
View GitHub Profile
@marcuzy
marcuzy / linux rar unpack
Last active August 29, 2015 14:25
Linux rar упаковка файлов в архив из папки cats без папки cats
rar a -ep1 -m5 cats_arch.rar cats/
#-ep1 - параметр, удаляющий корневую директорию, т.е. cats
#a - архивироть
#-m5 - максимальная степень сжатия
@marcuzy
marcuzy / gist:f5193b70e5ba063556aa
Created July 29, 2015 07:09
SublimeText3 Plugins
SublimeLinter
SublimeLinter-php
SublimeLinter-phplint
DockBlockr
File Rename
SublimeCodeIntel
@marcuzy
marcuzy / BatchInsert.php
Last active April 12, 2016 07:35
BatchInsert.php
<?php
class BatchInsert extends \yii\base\Component
{
const EVENT_AFTER_EXCECUTE = 'afterExecute';
public $columnNames = [];
public $tableName = '';
public $bufferedRowsNum = 200;
public $rows = [];
@marcuzy
marcuzy / twitter_bootstrap_callout.css
Created August 5, 2015 07:29
twitter_bootstrap_callout
.bs-callout {
padding: 20px;
margin: 20px 0;
border: 1px solid #eee;
border-left-width: 5px;
border-radius: 3px;
}
.bs-callout h4 {
margin-top: 0;
margin-bottom: 5px;
@marcuzy
marcuzy / yii2_attributes_trait.php
Last active August 29, 2015 14:26
Подмешивание геттеров с модели с лэйблами
<?php
trait DictGrouped
{
public function getGroupName()
{
return $this->dictGroup ? $this->dictGroup->name : '';
}
public function getBrandName()
@marcuzy
marcuzy / create_db_utf8.sql
Last active September 24, 2015 04:28
MySQL create DB utf8
CREATE DATABASE `my_db` CHARACTER SET utf8 COLLATE utf8_general_ci
@marcuzy
marcuzy / ssh-key-bases-auth.md
Created February 28, 2016 08:36
SSH Key-Based auth
  1. Загенерить ключ, который, возможно, уже есть:
ssh-keygen
  1. Залить ключ на на сервер, к которому нужно настроить доступ:
ssh-copy-id user@domain
@marcuzy
marcuzy / debug_only_admin.php
Created February 29, 2016 19:50
Оторбражение дебагера Yii2 только для юзера с ролью админ
<?php
//из config.php
if (YII_DEBUG) {
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.33.1', '*'],
'on beforeAction'=>function($event) {
//суть
$event->isValid = nil(Yii::$app->user->getIdentity())->hasRole(\common\models\User::ROLE_ADMINISTRATOR);
@marcuzy
marcuzy / select2_tags_dropdown_hide.php
Created May 14, 2016 16:59
Select2.js tags, hide dropdown (here Yii2 kartik widget)
<?php
echo Select2::widget([
//...
'pluginOptions' => [
'tags' => true,
'tokenSeparators' => [',', ' '],
'dropdownCssClass' => 'hide' // <-- hide - Twitter Bootstrap class for hidding dropdown
],
//...
])
@marcuzy
marcuzy / .htaccess
Created May 16, 2016 09:09
htaccess for yii2
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php