//Получить угол между двумя точками
function getAngle(dx, dy, dx1, dy1) {
return Math.atan2(dy - dy1, dx - dx1) + Math.PI;
}
///Получить растояние между двумя точками
function getDist(x, y, x1, y1) {
return Math.hypot(x - x1, y - y1);
}
var names = arr.map(e=>e.Data[0].name);
var counter = names.filter((v,i,arr)=> arr.indexOf(v) === i).map(el=>{
return {"name":el,"count" :names.filter(e=>el == e).length }
});
console.log(names)
console.log(counter)
["Sony", "Apple", "Sony"]
[{
count: 2,
name: "Sony"
}, {
count: 1,
name: "Apple"
}]
let box_h, item, co, staf;
co = document.querySelector(".boots");
staf = function(){
document.querySelectorAll(".push").forEach((e)=>{
e.addEventListener("click",(ev)=>{
console.log("good")
},false);
})
}
function g_global() {
//
box_h = "";
item = 5;
//
for(i = 0; i <= item; i++) {
box_h += '<div class="push"><button>нажми</button></div>'
}
//
co.innerHTML = box_h;
staf();
}
g_global();
<?PHP
$ch = curl_init();
$site = "https://habr.com/";
$url = "https://www.google.com/search?hl=ru&q=site:$site";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER , true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0');
$content = curl_exec($ch);
if(!$content){
echo 'Ошибка curl: ' . curl_error($ch);
die;
}
curl_close($ch);
if(preg_match("/Результатов:\s*(примерно)?\s*([^(]+)/",$content,$matches))
echo "Количество: ".$matches[2];
else
echo "Не найдено";
?>
Зачем делать шаг назад, в плане непонятных сеток, вложенностей и т.д.
модель/синтаксис/логика HTML/CSS/ Javascript
Также разочаровывает отсутствие нормального визуального редактора. Не только у XAML, у QML тоже и т.д. Редактор в VS сводится к подобию браузера с возможностью перетаскивания элементов и изменения их базовых значений.
try
{
Console.WriteLine("Введите путь к приложению:");
string path = Console.ReadLine().Trim();
if (!File.Exists(path)){
Console.WriteLine("Файл не найден");
Console.ReadKey();
return;
}
else
{
Console.WriteLine("Введите аргументы запуска(не обязательно):");
string startupArgs= Console.ReadLine().Trim();
Console.WriteLine("Введите время работы таймера например 10sec или 5min или 3hour или 3hour 5min 10sec");
string time = Console.ReadLine().Trim();
int ms = 0;
var sec = Regex.Match(time, @"(\d+)\s*sec");
if (sec.Success)
ms += Int32.Parse(sec.Groups[1].Value) * 1000;
var min= Regex.Match(time, @"(\d+)\s*min");
if (min.Success)
ms += Int32.Parse(min.Groups[1].Value) * 60*1000;
var hour = Regex.Match(time, @"(\d+)\s*hours?");
if (hour.Success)
ms += Int32.Parse(hour.Groups[1].Value) *60 * 60 * 1000;
if (ms < 5000){
Console.WriteLine("Таймер минимум на 5сек");
Console.ReadKey();
return;
}
Console.WriteLine("Закрывать ли другие копии этого процесса? y/n");
bool isCloseOthers = false;
while (true)
{
var key = Console.ReadKey(true).Key;
if ( key == ConsoleKey.Y)
{
isCloseOthers = true;
break;
}
else if (key == ConsoleKey.N)
{
isCloseOthers = false;
break;
}
}
Console.WriteLine("Перезагружать таймер автоматически каждый раз? y/n");
bool isAutoReset = false;
while (true){
var key = Console.ReadKey(true).Key;
if (key== ConsoleKey.Y)
{
isAutoReset = true;
break;
}
else if (key == ConsoleKey.N)
{
isAutoReset = false;
break;
}
}
Timer t = new Timer(ms);
t.AutoReset = isAutoReset;
t.Elapsed += (sender, eventArgs) =>{
Console.WriteLine("Перезапуск! Для отключения таймера нажмите X");
var p = Process.Start(path, startupArgs);
if (isCloseOthers){
var duplicates = Process.GetProcessesByName(p.ProcessName).Where(process => process.Id != p.Id)
.ToList();
foreach (var duplicate in duplicates)
duplicate.Kill();
}
};
Console.WriteLine("Таймер запущен(" + TimeSpan.FromMilliseconds(t.Interval).ToString(@"hh\:mm\:ss") + ")! Для отключения таймера нажмите X");
t.Start();
while (Console.ReadKey(true).Key != ConsoleKey.X) { }
t.Stop();
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadKey();
}
$(document).on("keydown", e => {
if(e.key.search(/\d/) != -1)
$("span").append(e.key);
});
.box{
background:black;
}
.box.active{
background:red;
}
const elem = document.querySelectorAll('.box');
for (let i = 0; i < elem.length; i++)
elem[i].addEventListener('click', function (evt) {
var el = document.querySelector('.box.active');
if(el)
el.classList.remove("active");
evt.target.classList.add("active");
});
$(function() {
// TODO
// Google remarketing hack удалить после того как гугл перестанет использовать document.write
document.write = function(html) {
$('body').append(html);
};
wb.product.DomReady.init({
showTones: 'False' == 'True',
selectedCod1S: 10424026,
selectedSize: 0,
rowId: 0,
isPopup: false,
haveSizes:true,
data: {"dataForVisited":10424026,"goodsName":"Ботинки","description":"","brandName":"Lassie","brandId":2034,"nomenclatures":{"10424026":
{"isSoldOut":false,"cod1S":10424026,
"ordersCount":2200
var arr = [
{date:"2020-04-28"},
{date:"2020-04-29"},
{date:"2020-04-30"},
{date:"2020-05-01"},
{date:"2020-05-02"},
{date:"2020-05-03"}
];
var find = Math.floor(+new Date()/86400000);
var finded = arr.find(e=>Math.floor(+new Date(e.date)/86400000) == find);//{date:"2020-05-01"}, если сегодня это число