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
// https://ru.wikipedia.org/wiki/Декоратор_(шаблон_проектирования) | |
// Класс для последующего декорирования | |
function Coffee() { | |
this.cost = function() { | |
return 1; | |
}; | |
} | |
// Decorator A |
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
app.get("/pg", function(req, res) { | |
connection.any("SELECT * FROM people", true) | |
.then(function(data) { | |
res.format({ | |
"application/json": function() { | |
res.status(200).send(data); | |
console.log(data); | |
} | |
}); | |
}) |
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
// define function with two args and callback | |
function foo(a, b, cb) { | |
console.log(a + ' ' + b); | |
// check type of cb | |
if (typeof(cb) === "function") { | |
cb(); | |
} | |
else { | |
console.log('error ' + cb + ' not a function'); |
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 checkPalindrom(str) { | |
strLowerCase = str.toLowerCase(); | |
var reverse = strLowerCase.split('').reverse().join(''); | |
if (reverse === strLowerCase) { | |
console.log(str + ' ' + 'is Palindrom'); | |
} else { | |
console.log(str + ' ' + 'is not Palindrom'); | |
} | |
} |
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
// parent class | |
function Animal(name) { | |
this.name = name; | |
}; | |
Animal.prototype.getName = function() { | |
return console.log(this.name); | |
}; | |
// child class | |
function Dog(name){ |
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
File -> Open Your Keymap | |
'atom-text-editor[data-grammar="text html mustache"]:not([mini])': | |
'tab': 'emmet:expand-abbreviation-with-tab' |
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
.bw{ | |
width: 450px; | |
height: 450px; | |
background-repeat: no-repeat; | |
background-image: url(http://i.imgur.com/GEJoUAB.jpg); | |
-webkit-filter: grayscale(100%); /* Chrome 19+, Safari 6+, Safari 6+ iOS */ | |
-moz-filter: grayscale(100%); | |
-ms-filter: grayscale(100%); /* IE 10-11 */ | |
-o-filter: grayscale(100%); |
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
// Удаляем пробелы в начале и конце строки, используя | |
// возможности библиотеки jQuery | |
var text1 = " a b c d e f g "; | |
var newText1 = $.trim(text1); | |
// Увидим "a b c d e f g" | |
// Удаляем пробелы в начале и конце строки, используя | |
// регулярные выражения в JavaScript (RegEx): | |
var text2 = " a b c d e f g "; | |
var newText2 = text2.replace(/(^\s+|\s+$)/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
// http://momentjs.com/docs/#/displaying/format/ | |
// moment('InputDate', 'MaskOfInputDate').format('OutputDate') | |
// example | |
moment('27/08/2016 09:00:00 PM', 'DD/MM/YYYY mm:hh:ss A').format('DD/MM/YYYY') |
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 check(mail){ | |
return /^[0-9a-z]([\.-]?\w+)*@[0-9a-z]([\.-]?[0-9a-z])*(\.[0-9a-z]{2,4})+$/i.test(mail) | |
} | |
console.log( check('[email protected]') ) // >> true |
OlderNewer