Как использовать контроль версий для сайта на обычном хостинге?
var changeTitle = function() {
this.title = function () {
var title = document.title;
document.title = (title == "hello" ? "" : "hello");
}
};
changeTitle.prototype.start = function() {
this.timer = setInterval(this.title, 1000);
};
changeTitle.prototype.stop = function() {
clearInterval(this.timer)
};
var timerTitle = new changeTitle();
window.onblur = function() {
timerTitle.start();
};
window.onfocus = function() {
timerTitle.stop();
};
И правильно ли я вообще делаю?
from concurrent.futures import ThreadPoolExecutor
from requests import Session
session = Session()
urls = [
'https://toster.ru/q/372757',
'https://toster.ru/',
]
with ThreadPoolExecutor(7) as pool: # 7 - количество тредов
for response in pool.map(session.get, urls):
do_something_with_response(response)
__slots__
и namedtuple
должно натолкнуть на эти размышления.def cmp(x):
x = x.split('x')
return int(x[0]) * int(x[1])
sorted(SIZES, key=cmp)
SIZES = ('1920x1080', '1600x1200', '1400x1050', '1280x1024', '1280x960', '1152x864', '1024x768',
'3840x2400', '3840x2160', '3840x1200', '2560x1600', '2560x1440', '2560x1080', '2560x1024',
'2048x1152', '1920x1200', '1680x1050', '1600x900', '1440x900', '1280x800', '1280x720', '2160x3840',
'1440x2560', '1366x768', '1080x1920', '1024x600', '960x544', '800x1280', '800x600', '720x1280',
'540x960', '480x854', '480x800', '400x480', '360x640', '320x480', '320x240', '240x400', '240x320',
'2732x2732', '2048x2048', '1024x1024', '750x1334', '640x1136', '640x960', '1280x900')
dct = {int(size.split('x')[0]): size for size in SIZES}
dct_sorted = sorted(dct.items())
for size in dct_sorted:
print(size[1])
Сколько можно использовать ключевых слов в meta-теге keywords?
Array.prototype.asyncEach = function (each, done) {
var i = -1, a = this
function iter() {
if (++i === a.length) { done && done(); return }
each.call(a, a[i], iter)
}
iter()
}
// Example
(new Array(10)).asyncEach(function (item, next) {
setTimeout(function () {
console.log("tick")
next()
}, 1000)
})