Skip to content

Instantly share code, notes, and snippets.

View kdes70's full-sized avatar
🏠
Working from home

Dmitriy Krivoshein kdes70

🏠
Working from home
View GitHub Profile
@kdes70
kdes70 / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
/**
* Подстовляем дефис в интервал десятичных чисел
* *1, 1.2, 1.3, 1.4, 2, 3 => result 1-1.4, 2, 3*
*
* @param $array
* @param bool $str если TRUE возврощать будет страку
*
* @return array|string
*/
public static function spacing($array, $str = FALSE)
@kdes70
kdes70 / gist:3fe5ad604f9be928201f
Created July 16, 2015 16:54
Yii2 Рендер категорий выподающем списке в виде дерева
<?=$form->field($offer, 'categories_list')->dropDownList(
ArrayHelper::map($categories,'id',function($value){ return str_repeat('-',count(explode('.',$value->path) )) . $value->name ;} ),
['multiple' => true]);
?>
document.getElementById('google_preview').innerHTML = '<span class="google_preview_title">' + document.getElementById('theme_metatitle').value + '</span><br/><span class="google_preview_seo_url">'+ domain_name_short + script_url + seo_url + '</span><br/><span class="google_preview_page_description">'+ document.getElementById('theme_metadescription').value+'</span>';
var img_id = 'google_preview_img';
if(typeof jQuery('#'+img_id).data('qtip') == 'object')
{
var api = jQuery('#'+img_id).qtip("api");
change_google_preview();
}
else
{
jQuery('#'+img_id).qtip({
@kdes70
kdes70 / gist:17856cb86672be1af1ac
Created November 23, 2015 09:36
array_column
<?php
if (!function_exists('array_column')) {
function array_column(array $array, $columnKey, $indexKey = null)
{
$result = array();
foreach ($array as $subArray) {
if (!is_array($subArray)) {
continue;
} elseif (is_null($indexKey) && array_key_exists($columnKey, $subArray)) {
$result[] = $subArray[$columnKey];
@kdes70
kdes70 / new_gist_file.php
Last active August 14, 2016 16:50
JS блок Yii2
$script = <<< JS
//some script
JS;
//маркер конца строки, обязательно сразу, без пробелов и табуляции
$this->registerJs($script, yii\web\View::POS_READY);
// POS_HEAD
// POS_BEGIN: после тэга <body>
// POS_END: перед тэгом </body>
// POS_LOAD: оборачивается в jQuery(window).load(). Note that by using this position, the method will automatically register the jQuery js file.
@kdes70
kdes70 / css_debug.css
Created April 27, 2016 04:42
CSS DEBUGER
/* --- DEBUG ---*/
/* подсвечиваем теги без необходимых атрибутов */
img:not([alt]),
label:not([for]),
input[type=submit]:not([value]) {
outline:2px solid red;
}
@kdes70
kdes70 / img_bg_pix_.css
Created June 14, 2016 09:01
img Base64
url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFklEQVR42mJydnb+DwQMjCACBAACDABTiAfG7AT+jQAAAABJRU5ErkJggg==) #282828
@kdes70
kdes70 / gist:6027b087284e464cf1f1d6a01353cd68
Created December 1, 2016 18:25
Чтобы поместить HTML боковой панели в шаблоне blade. (Laravel)
@include('partials.sidebar')
To pass the data the sidebar needs (in AppServiceProvider boot method) :
view()->composer('partials.sidebar', function ($view) {
// Get the $data
$view->with('data', $data);
@kdes70
kdes70 / select.html
Created December 2, 2016 15:40
select - выпадающий список с выделением цветом родительской категории
<label for="">Rubric</label>
<select name="category_id" id="category_id" class="ui dropdown">
<option class="item" value="" disabled selected="">Выберите категорию...</option>
@foreach($categories as $item)
@if($item->children->count() > 0)
<option class="item select-option-label" value="{{$item->id}}">{{ $item->name }}</option>
@foreach($item->children as $submenu)
<option class="item" value="{{$submenu->id}}">- {{ $submenu->name }}</option>
@endforeach
@else