Skip to content

Instantly share code, notes, and snippets.

View helloris25's full-sized avatar
😎

helloris25

😎
View GitHub Profile
@helloris25
helloris25 / RegExp YouTube video iFrame | object
Created September 16, 2015 14:31
RegExp YouTube video iFrame | object
$regexstr = '~
# Match Youtube link and embed code
(?: # Group to match embed codes
(?:<iframe [^>]*src=")? # If iframe match up to first quote of src
|(?: # Group to match if older embed
(?:<object .*>)? # Match opening Object tag
(?:<param .*</param>)* # Match all param tags
(?:<embed [^>]*src=")? # Match embed tag to the first quote of src
)? # End older embed code group
)? # End embed code groups
@helloris25
helloris25 / nanoTpl.js
Last active August 29, 2015 14:27
Simplest JS template engine
/*
* String nanoTpl (String template, Object data)
*
* Usage: nanoTpl('Hello ${name}! (not ${name}?)', { name: 'Gandalf' })
*
* Result: Hello Gandalf! (not Gandalf?)
*/
function nanoTpl (template, data) {
var result = template;
@helloris25
helloris25 / Быстрый импорт элементов инфоблока из xml-файла с настройками по умолчанию:
Last active August 29, 2015 14:09
Быстрый импорт элементов инфоблока из xml-файла с настройками по умолчанию:
<?php
$ABS_FILE_NAME = $_SERVER["DOCUMENT_ROOT"]."/xml/demo.xml";
$WORK_DIR_NAME = substr($ABS_FILE_NAME, 0, strrpos($ABS_FILE_NAME, "/")+1);
$obXMLFile = new CIBlockXMLFile;
// Удаляем результат предыдущей загрузки
$obXMLFile->DropTemporaryTables();
// Подготавливаем БД
if($obXMLFile->CreateTemporaryTables())
{