timo-71

Рейтинг
63
Регистрация
19.09.2018
Vall89 #:
Зачем делать один универсальный движок на все задачи

Роутинг, авторизация,   защита  Cross Site Request, шаблонизация,  события - первое, что в голову пришло из ряда универсальных для каждого сайта компонентов.

Samail:
мышкой потыкал на изображение и создались нужные ссылки

Если потыкать, то несложно. За 5 мин болванка из которой можно все что угодно развить

document.getElementById('iiii').addEventListener('click', function (event) {

let b = this.getBoundingClientRect(),
x = event.x - b.left - 10,
y = event.y - b.top -10;
console.log(b, x, y)

/*
* ну так на всякий, если скадрировано, то координаты можно пересчитать с поправкой на коэф
*/
console.log(
this.clientWidth,
this.clientHeight,
this.naturalWidth,
this.naturalHeight
)
var div = document.createElement("div")
div.style.position = 'absolute';
div.style.width = '20px';
div.style.height = '20px';
div.style.top = y+'px';
div.style.left = x+'px';
div.style.background = 'rgba(255,0,0,.2)';
this.parentNode.appendChild(div);
});
Samail:
mouse poked the image and create the necessary links

If you poke it is simple. 5 min ingot from which you can build anything

 document.getElementById ( 'iiii'). addEventListener ( 'click', function (event) { 
let b = this.getBoundingClientRect (),
x = event.x - b.left - 10,
y = event.y - b.top -10;
console.log (b, x, y)

/ *
* Well, just if cropped, the coordinates can be counted-adjusted coefficients
* /
console.log (
this.clientWidth,
this.clientHeight,
this.naturalWidth,
this.naturalHeight
)
var div = document.createElement ( "div")
div.style.position = 'absolute';
div.style.width = '20px';
div.style.height = '20px';
div.style.top = y + 'px';
div.style.left = x + 'px';
div.style.background = 'rgba (255,0,0, .2)';
this.parentNode.appendChild (div);
});

https://pastebin.com/HgtXG8d2

На питоне с тем же алгоритмом:(

---------- Добавлено 18.06.2020 в 19:06 ----------

danforth:
не думал как соточку выжать?

Что то идей больше нет. :(

https://pastebin.com/HgtXG8d2

In Python with the same algorithm :(

---------- Posted 18.06.2020 at 19:06 ----------

Danforth:
sotochku thought how to squeeze?

That the idea is no more. :(

danforth:
На пыхе у меня вот так вышло

Очень похожий результат

timo-71:
Смысл в значениях в качестве индекса.
https://pastebin.com/NcuYkQbe
Danforth:
On pyhe I like this happened

Very similar results

timo-71:
The point values as an index.
https://pastebin.com/NcuYkQbe

Сначала в не ту степь с array_combine. Работает, но не обязательно первое достает c например [1,2,3,3,3,3,3, 6].

Потом дошло. Смысл в значениях в качестве индекса.

https://pastebin.com/NcuYkQbe

Вариант в "лоб" по памяти чуть лучше, но медленней

class Solution {

private $n, $t, $l;
public function twoSum(array $nums, int $target) {
$this->n = $nums;
$this->t = $target;
$this->l = count($nums);
$c = $this->l-1;
for($i=0;$i<$c;$i++){
$r = $this->calc($this->n[$i], $i+1);
if(false!==$r) return [$i,$r];
}
return [];
}

private function calc($val, $k){
for($i=$k;$i<$this->l;$i++){
if( $this->t == $val + $this->n[$i]) return $i;
}
return false;
}
}

First, in the wrong steppe array_combine. Works, but not necessarily the first example gets c [1,2,3,3,3,3,3, 6].

Then it came. The point values as an index.

https://pastebin.com/NcuYkQbe

Option in the "forehead" slightly better memory, but slower

 class Solution { 
private $ n, $ t, $ l;
public function twoSum (array $ nums, int $ target) {
$ This-> n = $ nums;
$ This-> t = $ target;
$ This-> l = count ($ nums);
$ C = $ this-> l-1;
for ($ i = 0; $ i <$ c; $ i ++) {
$ R = $ this-> calc ($ this-> n [$ i], $ i + 1);
if (false == $ r!) return [$ i, $ r];
}
return [];
}

private function calc ($ val, $ k) {
for ($ i = $ k; $ i <$ this-> l; $ i ++) {
if ($ this-> t == $ val + $ this-> n [$ i]) return $ i;
}
return false;
}
}
suffix:
Ну скажем cloudflare не берет под защиту сайт с wildcard DNS

днс атака на субдомен

При DNS-атаке поддоменов злоумышленник отправляет DNS-запросы для нескольких случайных несуществующих поддоменов одного сайта. Цель состоит в том, чтобы создать отказ в обслуживании для авторитетного сервера имен домена, что делает невозможным поиск веб-сайта с сервера имен. Как побочный эффект ISP, обслуживающий атакующего, также может быть затронут, поскольку кэш рекурсивного резолвера будет загружен плохими запросами.

Вообще не про это, т.к. нс - cloudflare, т.е косвенно защищает. А так да * - серое, сайт.ру

png Asset1.png
Всего: 541