Showing posts with label etc. Show all posts
Showing posts with label etc. Show all posts

April 8, 2014

I think I'll stay on Windows XP

Today, on the 8th of April 2014, the official support for Windows XP is now over. No, this does not mean the computers will stop working. It's just there will be no more security updates and patches. Microsoft claims the computers running Windows XP are now at risk.

But I can't think of any reasons to upgrade, honestly, no matter what the Microsoft management wants me to believe.

This is all more paperwork than the real issues. All these scary stories about how you're unprotected and on your own will make sense after you read several of them. At that point you're supposed to suddenly notice how they all look the same. It feels like all of them were written in the Microsoft HQ basement and pushed to Forbes, Washington Post, Mashable, Computerworld and the others as some sort of paid advertisement to make whoever is still on XP upgrade in fear. They even seem to have the same structure and tone - it does sound like they were written by a hysterical housewife afraid of not being able to log on Facebook more than anything else. I guess Microsoft wants to push 8.1 that desperately.

I once again will not upgrade. There's no reason to. I wasn't using Microsoft Update and those security-fixes-whatever anyway, so if Microsoft will shut it down, it's no biggie to me. I don't even run any antivirus software for more than 4 years, and I believe I know what I'm doing

I just like XP, I got used to it. This is the OS I started with many, many years ago. It was there when all of the major things in our lives happened, it was groundbreaking back then. I guess I'm just getting older. When I'm working with it, I... I know it sounds weird, but I just feel home. There's no need for me to abandon it.

P.S. here's a story on how a guy was searching for wherever the Autumn wallpaper photo was taken: Autumn and the Plot Against Me

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3cb6gRAh-kPQbTMUdVhnBHnoEiyiMbdhZztXGKqnIxVZ2oh-teOkItrgnZHgSToF7VkaCnas9c0Z4WYhMjqykSgxo9YNBtuT6MhbAEumpRKQOgOL2rAHuhMYzzlyig22XQsIwchCoAV0/s1600/Autumn.jpg

UPDATE April 2017. Switched to a Mac. Don't regret. Still like XP though.

May 10, 2009

Как добавить поиск с автозаполнением Яндекса на сайт

Функция автозаполнения на сайте состоит из трёх компонентов: клиентской части (стили и скрипты, запрашивающие и отрисовывающие предположения по мере набора текста), серверной части, осуществляющей поиск в БД и/или запрос к поисковой системе, и собственно интерфейса поисковой системы (если решено её использовать). В своё время в качестве последнего компонента я решил выбрать Яндекс.

Я подсмотрел какие AJAX-запросы и куда отправляются по мере набора запроса на сайте Яндекса. Единственная сложность возникла лишь в том, что он возвращает данные в нестандартном формате, который становится уж более-менее ликвидным JSON'ом после замысловатых манипуляций, любезно подсказанных Alternator'ом на форуме nulled.ws, за что ему большое спасибо.

На клиентской стороне было решено поставить Autocompleter, разработанный Digitarald'ом. Безусловно, можно написать и собственный обработчик, но и этот вполне справляется.

Серверная часть. Для начала получим предположения, затем выполним над ними манипуляции, и в результате получим массив PHP. Получился эдакий скрипт преобразования предположений Яндекса в PHP массив:
<?php
$file=file_get_contents("http://suggest.yandex.ru/suggest-ya.cgi?ct=text/html&part=".urlencode($_REQUEST['value'])."&v=2");
$file=strrchr($file,"[");
$file=substr($file,0,strpos($file,"]"))."]";
$file=iconv("CP1251","UTF-8",$file);
$data=json_decode($file);
header("Content-type: text/html; charset=utf-8");
foreach($data as $key=>$val){
print '<li>'.$val.'</li>';
}
?>

В скрипт передаётся переменная $value, в которой содержится набираемый текст. Она ловко подставляется в запрос, по которому мы получаем список предположений. Затем, мы преобразовываем их в формат JSON, понятный функции json_decode(), посредством которой мы и разобьём всё это богатство в полноценный PHP-массив. Однако, прежде чем это сделать, в четвёртой строке полученные в windows-1251 данные перекодируются в понятную json'у utf-8. Шестой строкой объявляется та самая utf-8, начиная со следующей строки мы можем свободно в зависимости от ситуации управлять массивом. Как я уже сказал выше, этот скрипт передаёт данные autocompleter'у, посему адаптируем их под него.
Ну и напоследок классика жанра в качестве примера работы скрипта на одном моём сайте:


UPD от 15.02.2011: Уважаемый Глеб, обновил пост. Ещё подробнее дополню позже. Спасибо за отзыв!