Skip to content

Instantly share code, notes, and snippets.

@iredun
iredun / CentOS command.txt
Last active March 20, 2017 14:10
Команда которая находит и выводи путь к файлу, номер строки и строку, в котором содержится "base64_decode" в текущем каталоге
grep -iRI -n "base64_decode" ./
@iredun
iredun / youtube.txt
Created April 13, 2016 08:59
Youtube API get thumbnail image
Each YouTube video has 4 generated images. They are predictably formatted as follows:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
For the high quality version of the thumbnail use a url similar to this:
@iredun
iredun / copy_table.sql
Created December 14, 2015 14:29
Cкопировать таблицу в MySQL
CREATE TABLE new_table_name LIKE old_table_name;
INSERT new_table_name SELECT * FROM old_table_name;
@iredun
iredun / delDirRecursive.php
Created October 29, 2015 07:26
Функция для удаления директорий с вложенными файлами, возвращает 1 если удаление прошло успешно.
<?
function delTree($dir)
{
$files = array_diff(scandir($dir), array('.','..'));
foreach ($files as $file) {
(is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file");
}
return rmdir($dir);
}
?>
@iredun
iredun / arrayToXML.php
Created October 26, 2015 07:45
Array to Xml
<?php
header("Content-Type: text/xml");
$array = array (
'10.10.10.10' => 'Server'
);
$xml = new SimpleXMLElement('<root/>');
array_walk_recursive($array, array ($xml, 'addChild'));
print $xml->asXML();
?>
@iredun
iredun / code39.php
Created October 23, 2015 12:29
Генерирует штрих-код формата CODE 39, Пример использования www.example.com/code39.php?str=21010100745&width=400&height=200
<?
header ("Content-type: image/png");
$code = array();
$code['start'] = '1001011011010';
$code['1'] = '110100101011';
$code['2'] = '101100101011';
$code['3'] = '110110010101';
$code['4'] = '101001101011';
$code['5'] = '110100110101';
$code['6'] = '101100110101';
@iredun
iredun / pre.php
Created August 22, 2015 21:28
Функция для распечатки массива, с выводом дебаг информации
<?
function pre($array=false,$description=false,$debug_print_trace=false) {
$debug_trace = debug_backtrace();
if($debug_print_trace){
foreach(debug_backtrace() as $k=>$v){
if($v['function'] == "include" || $v['function'] == "include_once" || $v['function'] == "require_once" || $v['function'] == "require"){
$backtracel .= "#".$k." ".$v['function']."(".$v['args'][0].") called at [".$v['file'].":".$v['line']."]<br />";
}else{
$backtracel .= "#".$k." ".$v['function']."() called at [".$v['file'].":".$v['line']."]<br />";
}
@iredun
iredun / errors.php
Created August 12, 2015 09:22
Показывает все ошибки на странице, вне зависимости от настроек сервера (Работает и для 1С-Битрикс)
<?
ini_set('display_errors',1);
ini_set('error_reporting',2047);
?>
@iredun
iredun / dep.php
Created August 12, 2015 08:58
Получить список разделов и их подразделов в 1С - Битрикс
<?
$res = CIBlockSection::GetList(
Array('name' => 'asc'),
Array('IBLOCK_ID' =>'5' , 'ACTIVE' => 'Y')
);
while ($row = $res->GetNext())
{
echo $row['NAME'].'<br>';
$rsParentSection = CIBlockSection::GetByID($row['ID']);
if ($arParentSection = $rsParentSection->GetNext())
@iredun
iredun / bitrix_del_iblock_el.php
Created April 16, 2015 13:40
Скрипт удаляет все старые элементы инфоблока
<?
$arSelect = Array("ID", "NAME", "TIMESTAMP_X");
$arFilter = Array("IBLOCK_ID"=>"21", "<TIMESTAMP_X"=>"31.12.2013 23:59:59");
$res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>1000), $arSelect);
echo $res->SelectedRowsCount();
while($ob = $res->GetNextElement())
{
echo "<pre>";
$arFields = $ob->GetFields();
print_r($arFields);