Author Archives: himself

выгода организатор

Всё на свете ломается и портится – бумага желтеет, компакт-диски перестают читаться. Аккумулятор нетбука, который я купил три года назад, перестал заряжаться, и я его заменил. Старый КПК, который безнадёжно сломался в 2008, в 2005 был таким новым и модным.

Разбирая бумаги, я нашёл чехол-органайзер, из тех, что продавали в Россию китайцы в 1998. Два отделения, в одном на колечках календарь, ежедневник, телефоны, заметки, плохо переведённые заголовки вроде “выгода организатор”.
Я закончил школу в 2003-м, в этом ежедевнике мои заметки из 10-го класса: сдать программу, внести какие-то фильмы в какую-то базу. Телефон классного руководителя, которого я уже плохо помню, пометка принести “15 рублей за книги”. Сейчас мне 25 лет, эти слова были написаны 12 лет назад. Тогда я бегал в жилетке как у Вассермана и пил дешёвый “Колокольчик”.

Вместе с ежедневником и записной книжкой на колечках китайского портмоне висел калькулятор – простой и маленький, чтобы помещаться в отделение, на одноразовой батарейке, которая приехала вместе с ним, вероятно, из Китая. Я нажал на кнопку, и он включился.

Restore deleted notes in Anki

Sometimes you accidentally delete notes/cards in Anki. Ctrl-Z can revert one deletion, but several notes cannot be restored. If you use Anki Sync and haven't done any important edits locally, you should simply delete the collection and redownload it. But what if you don't want to lose local edits/reviews?

Note: If you have Sync enabled, do not sync at any point throughout this instruction. Pull out the network cable, disable Wi-Fi etc, to stop Anki from accidentally uploading your collection midway.

  1. Close Anki.
  2. Go to My Documents and zip the whole Anki folder. Put the archive in the safe place.
  3. Revert the collection to an older date:
    • Go to My Documents\Anki\YourProfile\Backups and choose a backup from when you have not yet deleted the cards.
    • Start Anki, wait until it loads, then double-click the chosen .apkg file.
    • Anki will say this will replace your collection, confirm it.
    • You have now reverted the collection to the older date.
  4. Export the broken deck:
    • Go to File->Export.
    • Choose "Export format: Anki deck package".
    • "Include": the deck where the deleted cards were.
    • Include sheduling information and media.
    • Press "Export" and save the file somewhere outside of Anki folder.
  5. Restore the current deck state
    • Close Anki.
    • Delete the My Documents\Anki folder
    • Unpack the zip file you have prepared before
    • Make sure the contents of My Documents\Anki folder is as before (no double Anki\Anki folders etc)
  6. Start Anki
  7. Double-click the saved deck .apkg file and let Anki import it
  8. Missing cards are imported with all their history.

Code Geass: Boukoku no Akito

Умудряются выпускать серии аккурат с такой периодичностью, что к новой серии как раз забываешь, что было в предыдущей.

Kurenai

annoying yet lovable loli • “Черепахи!” • воспитанная девочка из богатой семьи • школьник с глазами невыспавшегося убийцы • все учатся в школе, но школа к делу не имеет отношения • влиятельный древнеяпонский клан • куча взрослых • драки ногами • “Здравствуйте, я переговорщик” • нет фансервиса • сначала комедия, потом драма • всем забыли рассказать про пистолеты

Лоля смешная, говорит как ребёнок, а не как анимешные героини. Не то, что прямо-таки советую, но если нечего посмотреть, очень нормальный вариант.

(картинки)

“Шинкуро, кто эти страшные железные львы?”

Цукимоногатари и Коёмимоногатари

Давно уже прочёл Цуки и Коёми. Обе достаточно скучные, единственная радость – в конце Коёмимоногатари (спойлер)Коёми убивают. Но тут же воскрешают.

Сюжет Цукимоногатари: (не особо-то и спойлер)

Арараги болтает с Ёцуги ни о чём. В конце появляется злодей, ворует чужих имот, требует встретиться. Когда Арараги приходит, эмо-злодей сидит на полу храма и жалуется на жизнь, погоду и злую волю, которая поставила Арараги и его по разные стороны каких-то баррикад. И уже готов решить дело миром, как из кустов выходит кукла Ёцуги и убивает его.

Мораль: Ёцуги жестокая, она не человек. Чтобы компенсировать эту мораль, Ёцуги подселяют жить к Арараги.
Ах да, забыл: Коёми теперь нельзя использовать свою вампирскую натуру, т.к. он и так перестал отражаться в зеркале, и если дальше продолжать, скоро сверкать на солнце начнёт.

У Коёмимоногатари нет сюжета, это 12 рассказов, по рассказу в месяц – от самого начала цикла до его настоящего времени. Каждый рассказ посвящён одному из персонажей, и во всех Коёми выясняет, “что для такого-то значит Путь” (внятного ответа на этот вопрос не получая).
Коёми, что за ерунду ты у людей спрашиваешь. И не только у людей.

Рассказы бьют все рекорды скукоты и бессобытийности, например, в одном из рассказов коллектив додзё хотел срубить некрасивое дерево, и Карен пришла к Арараги советоваться, как бы их переубедить. В другом чан с водой показывал Канбару её бабушку (спойлер: на самом деле это была сама Канбару). В сумме таких интригующих сюжетов набралось на 440 страниц, самая длинная книга в серии.

В самом-самом-самом-самом конце, даже после того спойлера, который я дал выше, есть одно приятное событие, которое всем понравится. Отличный способ продать 440 страниц ненужного текста, Исин.

Не печатайте домен

Многие забывают, что тэг a href можно использовать без домена:
<a href="/path/">
Поддерживается всеми браузерами с незапамятных времён. Выгода двойная: меньше печатать, и если когда-нибудь перенесёте сайт – не придётся менять адреса.

В сочетании с умением вордпресса находить пост или страницу только по их ярлычку (slug), это позволяет писать вот такие замечательные ссылки:
<a href=opera>Полезные заметки по браузеру Opera</a>
Также можно указывать путь относительно текущей папки <a href="./path/">

Коимоногатари

Вброс: завтра будет не первая серия Кои, а рекап. Появится Кайки, скажет: “А потому, что не надо верить никому, даже аниме-компаниям”.

Apache cannot serve files with unicode filenames

I've had a problem with my Apache setup where it couldn't serve images with unicode characters in file names:

 <a href="http://www.boku.ru/img/проверка.jpg">http://www.boku.ru/img/проверка.jpg</a> (really missing right now; just an example)

SCP client (WinSCP) clearly showed files were present, other files from the same folder could be accessed but those with cyrillic characters were returning 404.

Using Wireshark, I determined my browser sends urlencoded text (B0%D0…) instead of bare unicode, but that was, apparently, like it should be.

Studying Apache logs, I've found it complain about missing files, re-encoded in \x notation (\xb0\xd0…). For a while I thought this suggested a problem, but in the end it was unrelated and probably correct behavior.

Turns out, WinSCP does not use UTF-8 by default. Instead it sends file names to server in the local PC encoding, Win-1251 in my case. Looking through WinSCP everything seemed alright because it reads filenames back in the same encoding. But from the server point of view (as seen through SSH for example) those were not Russian characters but some Krakozyabry.

In other words, there really was no проверка.jpg.

To recongifure WinSCP, open Site manager, press Edit, Advanced, "UTF-8 encoding for file names: On", then reconnect. You'll have to rename all affected files.

A lost game

A move many debaters try to pull off is setting up a lost game. It works like this:

“Punishing those who download books is unfair. They just take what was lying in the open. That’s a basic human right.”
“Yes they can reshare. You can’t punish for that either. They haven’t signed a contract promising not to do so. They are free to do as they wish.”
“Eh, okay. But surely, as a writer, I’ll just pen a contract by which anyone who buys and then shares is to be held responsible for all the millions of dollars of damages?”
“No, we cannot do this because that’s immoral. That’s basically enslaving him.”
“But then how do we protect the writers?”
“I don’t know? You want copyright, you think of something.”

Or like this:

“The government has no right to ban Freedom Hosting! They didn’t host CP, they hosted everything, that was just their business model: no restrictions.”
“Providers cannot be ordered to ban sites. That’s censorship!”
“People must be allowed to remain anonymous on the internet.”
“So you want to fight CP? We cannot ban the site, cannot ban the hoster and cannot find out who the owner is. I guess you have to sit and wait until the owner reveals itself, FBI! Know that I rooted for you.”

Negotiations don’t work like this. Either you don’t support the idea at all, or you see a point in it and then by the rules of discussion you must protect its interests to the extent you see it as important. In other words, if you agree you agree. No one is ever convinced by “I’d love to clean the room mom, but there’s a reason I can’t”.

That’s not how you should do it. There are several sides to the story and it’s okay to take one as long as you’re honest.
“I want there be a certain amount of uncontrollable freedom in the internet because total control is unhealthy for any society”. Absolutely.

See how the reaction changed? That’s because that was the truth. That was the idea that moved you, not the layers of justifications built around to make it “consistent”. And what moved one person may move another. You wouldn’t want to be held responsible for simply providing a hosting? Neither would I. It just feels wrong that one can go to jail for typing on the keyboard? Does so to me. You don’t want to be made to buy books, you want to buy books you liked? I can relate to that.

WordPress not remembering name or email for anonymous commenters

Someone reported that WordPress at boku.ru hasn’t been remembering the name and email which you enter in comments. I vaguely remembered this working before. After some investigation, turns out it was W3 Total Cache plugin which uses comment_cookie_lifetime filter to drop standard WordPress cookie lifetime from half a year to 30 minutes. And since my site runs as GMT, this was eaten by the 4-hour time difference.

W3 Total Cache did that because for cookie-less visitors it serves fast static version of the page (which can not be tailored for each visitor and have their name pre-entered, the way names are handled now). As long as you have posted a comment, you receive a cookie and WordPress serves you slower, dynamic version of the page. So the longer the cookie lifetime is, the longer you’re going to be served dynamic pages (but the longer your settings are going to be preserved).

This setting can be changed at “Performance > Page Cache > Advanced > Comment cookie lifetime”.

If you’ve stumbled upon this post while solving a related problem, here’s some additional pointers:
1. WordPress stores commenter name/email/url in cookies:
comment_author_*
comment_author_email_*
comment_author_url_*

An example of how querying for these values should look like is in /wp-includes/comment-template.php/comments_template()

2. Your comment form is generated either by this, or by customization hook in your theme’s comments.php.

3. To debug cookies, add print_r($_COOKIES); to your theme’s header.php, don’t forget to remove it later. Use Wireshark or your browser’s request sniffer to track what’s being sent.