Skip to content

Instantly share code, notes, and snippets.

View edtoken's full-sized avatar

Eduard Titov edtoken

View GitHub Profile
function betweenTag($html, $tag = 'pre'){
$replace = array();
$j = 0;
do{
$new = false;
//Поиск открывающего тэга (одного!)
preg_match('%(<'.$tag.'[^>]*>)(.*)%s', $html, $m);
if(isset($m[1], $m[2])){
//Начинаем поиски закрывающих тегов (всех до конца документа)
var makeNestedObject = function(key, value, pattern){
var items = key.split(pattern).reverse();
var obj = value;
for(var i=0;i<items.length;i++){
var newObj = {};
newObj[items[i]] = obj;
obj = newObj;
}
return obj;
};
Gruntfile.js:
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
// jshint: {
// options: {
@edtoken
edtoken / s.js
Last active August 29, 2015 14:09
(function ($) {
/**
* arrayUpdateSlice.
* Join arrays, update items with new data.
* add new items of updates array
* @param {array=} items basic array
* @param {array=} updates and new items array
* @returns {Array}
*/
var CalculateItems = function(str){
try {
var jsonData = JSON.parse(str);
} catch(e) {
return {'data':false};
}
var out = "\r\n" ;
@edtoken
edtoken / style.css
Created October 8, 2014 20:30
media
/**
* media height
*/
@media (max-height:320px){
}
@media (min-height: 480px) {
}
@media (max-height: 600px) {
@edtoken
edtoken / media.css
Created September 25, 2014 12:02
media css
/**
* media height
*/
@media (max-height:320px){
}
@media (min-height: 480px) {
}
@edtoken
edtoken / viewremove.js
Last active August 29, 2015 14:05
viewremove.js
var removeFunc = Backbone.View.prototype.remove;
Backbone.View.prototype.remove = function(){
if(this.children){
_.each(this.children, function(item){
item.remove();
});
}
var apiRelationalCollection = {
method:false,
type:false,
loading:function(data){
return data;
},
data:false,
relational:false,
};
var items = _.sortBy(this.models, function(model){
var custom_data = '';
custom_data += model.get('year').toString();
custom_data += model.get('month').toString();
custom_data += model.get('week').toString();
model.set({sort_data:parseInt(custom_data)},{silent:true});
return parseInt(custom_data);