import re
str = '<tr class="img weatherIcoS"> <td class="p1"> <div class="weatherIco n000" title="Ясно"><img alt="" class="weatherImg" src="//sinst.fwdcdn.com/img/weatherImg/s/n000.gif"/></div> </td> <td class="p2 bR"> <div class="weatherIco n000" title="Ясно"><img alt="" class="weatherImg" src="//sinst.fwdcdn.com/img/weatherImg/s/n000.gif"/></div> </td> <td class="p3"> <div class="weatherIco d300" title="Облачно с прояснениями"><img alt="" class="weatherImg" src="//sinst.fwdcdn.com/img/weatherImg/s/d300.gif"/></div> </td> <td class="p4 bR"> <div class="weatherIco d300" title="Облачно с прояснениями"><img alt="" class="weatherImg" src="//sinst.fwdcdn.com/img/weatherImg/s/d300.gif"/></div> </td> <td class="p5 cur"> <div class="weatherIco d300" title="Облачно с прояснениями"><img alt="" class="weatherImg" src="//sinst.fwdcdn.com/img/weatherImg/s/d300.gif"/></div> </td> <td class="p6 bR"> <div class="weatherIco d320" title="Облачно с прояснениями, дождь"><img alt="" class="weatherImg" src="//sinst.fwdcdn.com/img/weatherImg/s/d320.gif"/></div> </td> <td class="p7"> <div class="weatherIco d320" title="Облачно с прояснениями, дождь"><img alt="" class="weatherImg" src="//sinst.fwdcdn.com/img/weatherImg/s/d320.gif"/></div> </td> <td class="p8"> <div class="weatherIco n300" title="Облачно с прояснениями"><img alt="" class="weatherImg" src="//sinst.fwdcdn.com/img/weatherImg/s/n300.gif"/></div> </td> </tr>'
titles = re.findall(r'title="([^"]*)"', str)
print(titles) // ['Ясно', 'Ясно', 'Облачно с прояснениями', 'Облачно с прояснениями', 'Облачно с прояснениями', 'Облачно с прояснениями
, дождь', 'Облачно с прояснениями, дождь', 'Облачно с прояснениями']
function subscribe (ind = 0) {
request.post({
url: 'https://example.com',
form: {list: mis[ind]}
}, (err, response, body) => {
console.log(response.statusCode)
if (response.statusCode == 200)
subscribe (ind + 1)
})
}
subscribe()
const App = () => {
const [showComponent, changeShowComponent] = useState(0)
return <div>
<button onClick={() => changeShowComponent(1)}>Начинаем</button>
{showComponent === 1 && <FirstModalComponent changeShowComponent />}
{showComponent === 2 && <SecondModalComponent changeShowComponent />}
</div>
}
changeShowComponent(2)
и все перерисуется, первый компонент исчезнет, второй появится import math
def middle_permutation(string):
res, letters = '', sorted(list(string))
fct = math.factorial(len(letters))
remained = math.ceil(fct / 2)
while (len(letters)):
fct /= len(letters)
cnt = math.ceil(remained/ fct) - 1
res = res + letters.pop(cnt)
remained -= fct * cnt
if (remained == 0):
remained = fct
return res
function createTree(data, defaultId, parentIds = '') {
const ul = document.createElement("ul");
data.map((item, index) => {
const li = document.createElement("li");
const id = [parentIds, item.id].join('_')
li.textContent = id;
if (item.children) {
li.appendChild(createTree(item.children, index, id));
}
ul.appendChild(li);
});
return ul;
}
SELECT
timeStart, timeEnd, ROUND(IFNULL(seconds, 0) / 3600 * 100) as percent
FROM
(SELECT
timeStart,
timeEnd,
SUM(3600 - CASE
WHEN UNIX_TIMESTAMP(timeStarted) - UNIX_TIMESTAMP(timeStart) < 0 THEN 0
ELSE UNIX_TIMESTAMP(timeStarted) - UNIX_TIMESTAMP(timeStart) END - CASE
WHEN UNIX_TIMESTAMP(timeEnd) - UNIX_TIMESTAMP(timeStopped) < 0 THEN 0
ELSE UNIX_TIMESTAMP(timeEnd) - UNIX_TIMESTAMP(timeStopped) END) as seconds
FROM (
SELECT '2020-06-23 00:00:00' as timeStart, '2020-06-23 00:59:59' as timeEnd
UNION SELECT '2020-06-23 01:00:00', '2020-06-23 01:59:59'
UNION SELECT '2020-06-23 02:00:00', '2020-06-23 02:59:59'
UNION SELECT '2020-06-23 03:00:00', '2020-06-23 03:59:59'
UNION SELECT '2020-06-23 04:00:00', '2020-06-23 04:59:59'
UNION SELECT '2020-06-23 05:00:00', '2020-06-23 05:59:59'
UNION SELECT '2020-06-23 06:00:00', '2020-06-23 06:59:59'
// и т.д.
) as HoursSet
LEFT JOIN (
SELECT MAX(IFNULL(StartedPoints.time, '2020-06-23 00:00:00')) as timeStarted, StoppedPoints.time as timeStopped FROM `stanki` as StoppedPoints
LEFT JOIN stanki as StartedPoints
ON StoppedPoints.name = StartedPoints.name AND
StartedPoints.value = 'ACTIVE' AND
StoppedPoints.time > StartedPoints.time
WHERE StoppedPoints.name = '01' AND StoppedPoints.value IN ('STOPPED', 'UNAVAILABLE')
GROUP BY StoppedPoints.time
UNION ALL
SELECT time, '2020-06-24 00:00:00'
FROM (SELECT * FROM stanki WHERE name = '01' ORDER BY time DESC LIMIT 1) as LastRecord
WHERE value = 'ACTIVE'
) as ActiveIntervals ON ActiveIntervals.timeStopped > HoursSet.timeStart
AND ActiveIntervals.timeStarted <= HoursSet.timeEnd
GROUP BY timeStart, timeEnd) as CalculatedSeconds
// После добавления записи в банк
CREATE TRIGGER `cash_movemenets` AFTER INSERT ON `cash`
FOR EACH ROW BEGIN
INSERT INTO movemenets Set date = NEW.date, income = NEW.sum;
END
// После добавления записи в кассу
CREATE TRIGGER `bank_movemenets` AFTER INSERT ON `bank`
FOR EACH ROW BEGIN
INSERT INTO movemenets Set date = NEW.date, income = NEW.transfer;
END
const extendMe = ({prototype: childProto}, {prototype: parentProto}) => {
for (const key of Object.getOwnPropertyNames(parentProto)) {
if (!(key in childProto)) {
childProto[key] = parentProto[key]
}
}
}
class Animal {
name () { return 'Животное' }
legs () { return undefined }
get isAnimal () {
return true
}
}
class Cat {
name () { return 'Котик' }
legs () { return 15 }
}
const cat = new Cat()
console.log(cat.isAnimal) //undefined
extendMe(Cat, Animal)
console.log(cat.isAnimal) // true
SELECT pairs.startDate, pairs.endDate, pairs.endDate - pairs.startDate + 1 as count FROM
(SELECT t1.date as startDate, MIN(t3.date) as endDate FROM statistics as t1
LEFT JOIN statistics t2 ON t1.date - t2.date = 1 and t2.done = 1
LEFT JOIN statistics as t3 ON t1.date <= t3.date and t3.done = 1
LEFT JOIN statistics as t4 ON t3.date - t4.date = -1 and t4.done = 1
WHERE t1.done = 1 AND ISNULL(t2.date) AND ISNULL(t4.date)
GROUP BY t1.date) as pairs
ORDER BY pairs.startDate