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 eratosfen(maxNubm) { | |
var arr = []; | |
var p = 2; | |
//Создаем массив заданной длины | |
for (var i = 2; i < maxNubm; i++) { | |
arr[i] = true | |
} | |
while (p * p < maxNubm) { | |
// Производим "зачеркивание" чисел по "p" |
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 camelize(str) { | |
var arr = str.split('-'); | |
for (var i = 1; i < arr.length; i++) { | |
arr[i]= arr[i][0].toUpperCase() + arr[i].slice(1); | |
} | |
str = arr.join(''); | |
return str; | |
} |
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 getWeekDay(date) { | |
var days = ['вс', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб']; | |
var result; | |
result = days[date.getDay()]; | |
return result; | |
} |
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 getDateAgo(date, days) { | |
var newDate = new Date(date); | |
newDate.setDate(newDate.getDate() - days) | |
return newDate.getDate(); | |
} |
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 getLastDayOfMonth(year, month) { | |
var currentMounth = new Date(year, month); | |
var nextMounth = new Date(year, month + 1); | |
var result = (nextMounth - currentMounth)/86400000; | |
return result; | |
} | |
/* | |
Лучшее решение | |
function getLastDayOfMonth(year, month) { |
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
/** | |
* Задача — реализовать строковый буфер на функциях в JavaScript, со следующим синтаксисом: | |
Создание объекта: var buffer = makeBuffer();. | |
Вызов makeBuffer должен возвращать такую функцию buffer, которая при вызове buffer(value) добавляет значение в некоторое | |
внутреннее хранилище, а при вызове без аргументов buffer() — возвращает его. | |
* @example http://plnkr.co/edit/aOwEwSKX2fpwURBVmOqN?p=preview | |
* */ | |
function makeBuffer() { | |
var text = ''; | |
var buffer = function(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 Calculator() { | |
var methods = { | |
"-": function(a, b) { | |
return a - b; | |
}, | |
"+": function(a, b) { | |
return a + b; | |
} | |
}; |
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
preg_replace('/[^\d]+/', '', $response); |
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
First task | |
a. Вернуть название фирмы и ее телефон. В результате должны быть представлены | |
все фирмы по одному разу. Если у фирмы нет телефона, нужно вернуть пробел или | |
прочерк. Если у фирмы несколько телефонов, нужно вернуть любой из них. | |
SELECT DISTINCT | |
name, | |
IFNULL(phone, " ") AS phone | |
FROM symfony.firms AS firms | |
LEFT JOIN symfony.phones AS phones ON firms.id = phones.firm_id | |
GROUP BY 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
<html lang="en"><head><style class="vjs-styles-defaults"> | |
.video-js { | |
width: 300px; | |
height: 150px; | |
} | |
.vjs-fluid { | |
padding-top: 56.25% | |
} | |
</style> |