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
/** | |
* Дефолтный boolean параметр функции | |
* Учитывает 3 вариант: передаем true || false или вовсе не передаем (true по дефолту) | |
*/ | |
join = typeof join === 'undefined' ? true : join; |
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
/** | |
* Прототип. Возвращает строку с безопасными HTML символами | |
* @type {Function|*} | |
*/ | |
String.prototype.encodeHTML = String.prototype.encodeHTML || function () { | |
return this | |
.replace(/&/g, "&") | |
.replace(/</g, "<") | |
.replace(/>/g, ">") | |
.replace(/"/g, """) |
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
$element.css({ | |
"transition-duration":"0s", | |
backgroundColor:'#8f8' | |
}); | |
setTimeout(function() { | |
$element.css({ | |
transition:"background 2s linear", | |
backgroundColor:'#E7E7E7' | |
}); | |
},500); |
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
/** | |
* Prism: Lightweight, robust, elegant syntax highlighting | |
* MIT license http://www.opensource.org/licenses/mit-license.php/ | |
* @author Lea Verou http://lea.verou.me | |
*/ | |
Prism.languages.nginx = Prism.languages.extend('clike', { | |
comment: { | |
pattern: /(^|[^"{\\])(#.*?(\r?\n|$))/g, | |
}, |
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 declOfNum(number, titles) { | |
cases = [2, 0, 1, 1, 1, 2]; | |
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ]; | |
} | |
use: | |
declOfNum(count, ['найдена', 'найдено', 'найдены']); |
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 getNumerology(num) { | |
var strNum = num.toString(); | |
var strLen = strNum.length; | |
var sum = 0; | |
for(var i = 0; i < strLen; i++) { | |
sum += parseInt(strNum[i]); | |
} | |
return sum.toString().length < 2 ? sum : getNumerology(sum); |
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
// using a generator function | |
function* entries(obj) { | |
for (let key of Object.keys(obj)) { | |
yield [key, obj[key]]; | |
} | |
} | |
// an alternative version using a generator expression | |
function entries(obj) { | |
return (for (key of Object.keys(obj)) [key, obj[key]]); |
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 parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
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
<?xml version="1.0"?> | |
<project name="Clipboard History" basedir="." default="tester"> | |
<property name="build_dir" value="../scm_build" /> | |
<property name="dest_dir" value="../scm_build/scm" /> | |
<property name="src_dir" value="." /> | |
<!-- ДЛЯ ТЕСТЕРОВ --> | |
<target name="tester" description="Сборка в папку для тестеров"> | |
<!-- Создаем каталог для билда --> | |
<mkdir dir="${build_dir}" /> |
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 guid() { | |
function s4() { | |
return Math.floor((1 + Math.random()) * 0x10000) | |
.toString(16) | |
.substring(1); | |
} | |
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + | |
s4() + '-' + s4() + s4() + s4(); | |
} |
OlderNewer