Skip to content

Instantly share code, notes, and snippets.

View maximishchenko's full-sized avatar

Maxim Ishchenko maximishchenko

  • Russia
View GitHub Profile
@maximishchenko
maximishchenko / php_GDImageFill.php
Last active July 9, 2017 13:48
PHP Fill or Fit Image (based on gd library)
<?php
namespace common\widgets;
/**
* Crop fill or fit image with php-gd library
* @author Maxim Ishchenko <maxim.ishchenko@gmail.com>
* @version 1.0*
* @uses, @example
* @license GPL
@maximishchenko
maximishchenko / StringOperations.php
Created June 25, 2017 11:53
String Operatons Class
<?php
/**
*
*/
class StringOperations
{
public function Transliterate($str) {
$translit=array(
"А"=>"a","Б"=>"b","В"=>"v","Г"=>"g","Д"=>"d","Е"=>"e","Ё"=>"e","Ж"=>"zh","З"=>"z","И"=>"i","Й"=>"y","К"=>"k","Л"=>"l","М"=>"m","Н"=>"n","О"=>"o","П"=>"p","Р"=>"r","С"=>"s","Т"=>"t","У"=>"u","Ф"=>"f","Х"=>"h","Ц"=>"ts","Ч"=>"ch","Ш"=>"sh","Щ"=>"shch","Ъ"=>"","Ы"=>"y","Ь"=>"","Э"=>"e","Ю"=>"yu","Я"=>"ya",
@maximishchenko
maximishchenko / GoogleMaps.php
Last active May 19, 2017 11:16
Download Google Maps Image by Coordinates
<?php
/**
* Get Image from Google Maps API by place coordinates and download it.
* @author Maxim Ishchenko <maxim.ishchenko@gmail.com>
* @version 1.0*
* @uses
*
* $map = new GoogleMaps(
* array(
@maximishchenko
maximishchenko / YoutubeThumbs.php
Created May 8, 2017 21:52
Download Youtube Thumbnail
<?php
/**
* Get Preview Image from Youtube video link (not from embeded code) and download it if video exist
* @author Maxim Ishchenko <maxim.ishchenko@gmail.com>
* @version 1.0*
* @uses
*
* $getThumbs = new YoutubeThumbs('https://youtu.be/xxxxxxxxxxx', 'quality', 'directory');
* echo '<img src="'.$getThumbs->getThumbnail().'"/>';
@maximishchenko
maximishchenko / js_classesManipulation.js
Last active October 16, 2016 14:14
Javascript: добавление, удаление, переключение классов элемента
/**
* @author [Maxim Ishchenko <maxim.ishchenko@gmail.com>]
* @param {[string]} [title] [Набор методов для добавления, удаления, переключения класса элемента]
* [classesManipulation содержит набор методов для добавления/удаления классов элемента, в случае его наличия]
* @return {[none | false]} [производит указанный набор манипуляций с классами элемента в случае его наличия]
* @example
* // добавить скрипт на страницу:
* script type="text/javascript" src="path/to/this/script"
* // объявить класс:
* var classesManipulation = new classesManipulation();
@maximishchenko
maximishchenko / yii2_proceedGridviewCheckBoxes.js
Created August 17, 2016 12:12
yii2_proceedGridviewCheckBoxes.js
// included script. For example js/gridViewProceedCheckBoxes.js
/**
* [proceedCheckBoxes description]
* @param {[type]} btnID [id of button]
* @param {[type]} gridID [id of GridView]
* @param {[type]} pjaxID [id of pjax-container]
* @param {[type]} emptyAlertText [text for alert "Nothing Checked"]
* @param {[type]} confirmAlertText [text for confirmation alert]
* @param {[type]} proceedURL [controller action ro proceed]
@maximishchenko
maximishchenko / js_previewImageBeforeUpload.html
Last active August 14, 2016 11:15
JavaScript Preview Image Before Upload
<script type="text/javascript">
/**
* Display image selected in html input widget
* @param {string} inputID id of html image input
* @param {string} imgFieldID id of html img tag
* @return none
*/
function previewImageBeforeUpload(inputID, imgFieldID) {
@maximishchenko
maximishchenko / activeDirectoryResetTrustWithWorkstation.cmd
Created August 8, 2016 20:38
activeDirectoryResetTrustWithWorkstation
# in DC
netdom reset <computerName> /domain <domainName> /Usero <userName> /Passwordo <password>
# in Workstation
nltest /server:<computerName> /sc_reset:<domainName>\<DCName>
# test
nltest /query
@maximishchenko
maximishchenko / Yii2_form_field_with_submit_button.php
Created May 28, 2016 07:52
Yii2_form_field_with_submit_button
<?php
echo $form->field($model, 'email', [
'template' => '<div class="input-group">{input}<span class="input-group-btn">'.
Html::submitButton(Yii::t('app', '{icon} Search', ['icon' => FA::icon('search')]), ['class' => 'btn btn-primary']).'</span></div>',
]);
?>
@maximishchenko
maximishchenko / js_toggle_div.js
Created May 10, 2016 18:50
JS Toggle Div on Button Onclick
<div id="target_div_id"></div>
<button id='button_id'>Click</button>
var button = document.getElementById('button_id');
button.onclick = function() {
var div = document.getElementById('target_div_id');
if (div.style.display !== 'none') {
div.style.display = 'none';
}