This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jsonObj = [{"forget":"me","leave":"alone"}, {"take":"them", "not":"him"}]; | |
var arr = []; | |
for(var i = 0; i < jsonObj.length; i++) { | |
var val = jsonObj[i]; | |
var def = Object.keys(val); | |
//console.log("all keys: " + def); | |
for(var j = 0; j < def.length; j++) { | |
arr.push([ def[j], val[def[j]] ]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var text = "one, two"; | |
var text1 = text.split(","); | |
Array.prototype.slice.call(text1).map(function(item) { | |
return item.replace(" ", ""); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WordPress Query Comprehensive Reference | |
* Compiled by luetkemj - luetkemj.com | |
* | |
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query | |
* Source: http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/query.php | |
*/ | |
$args = array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Запуск модульных тестов при изменении какого-либо php-файла в проекте | |
var phpunit = require('gulp-phpunit'); | |
var gulp = require('gulp'), | |
notify = require('gulp-notify'), | |
phpunit = require('gulp-phpunit'); | |
gulp.task('phpunit', function() { | |
var options = {debug: false, notify: true}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Originally from http://davidwalsh.name/convert-xml-json | |
* This is a version that provides a JSON object without the attributes and places textNodes as values | |
* rather than an object with the textNode in it. | |
* 27/11/2012 | |
* Ben Chidgey | |
* | |
* @param xml | |
* @return {*} | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function $$(selector){ | |
return Array.prototype.slice.call(document.querySelectorAll(selector), 0); | |
} | |
$$('div').length |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = []; | |
var testValues = function(value) { | |
return /keyword_here/.test(value); | |
}; | |
var addPrefix = function(value) { | |
return 'prefix '+value; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function do_smth_with_arguments(/* lots of arguments here */){ | |
var args = Array.prototype.reverse.call(arguments);//call array method whatever you like | |
for(var i=0; i<args.length; i++){ | |
alert(args[i]);//do whatever you want with each argument passed | |
} | |
}; | |
do_smth_with_arguments.apply(null, ['one','two','three']);//null points to 'this' context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var thumbModal = function (thumbs, fullImgContainer) { | |
for (var i = 0; i < thumbs.length; i++) { | |
var thumb = thumbs[i]; | |
var show = function (event) { | |
event.preventDefault(); | |
var imgBlock = this.querySelector(fullImgContainer); | |
if (imgBlock.style.display != 'block') { | |
$(fullImgContainer).hide(); | |
$(imgBlock).fadeIn(500); | |
} else { |
OlderNewer