This fragment is about to be reported (you'll remain on this page):

You can enter a comment to clarify the mistake if you would like to:

Posts tagged “Computer” RSS20

Encoding choices as a secure string

Inspired by this post on Laravel forums.

In short, suppose you're writing a simple oldschool browser quest game where the user makes choices to advance in the story. Or perhaps you're making an online testing resource and want the user to be able to save his progrss without the need to register or keep track of his sessions – by simply bookmarking the current page.

Choices can be saved directly like this:

…However, it's not really great:

«…»

Has 4 comments | Read rest of this entry »

Using CSS after pseudoclass to clear floats

Using CSS after pseudoclass to clear floats

It's quite often to have floating blocks and it almost equally often you need to clear them (i.e. let the following content start after their end). However, it's not always possible to insert <div style="clear: both"></div> all around your page's code simply because you might have no control over its generation.

Luckly for us, major browsers support a nifty CSS 2 selector – :after pseudoclass. And we can use it to simulate a trailing clearing <div> just like shown before.

Here's the sample code:

And here's what it produces – paragraphs have red background and divs have white. The first div isn't cleared so its content overflows the bottom border while the second successfully clears the contained left-floating image.

Padding will also work if applied to the last div.

No comments yet | Show this entry »

Git deal

Git deal

Последние несколько дней я основательно познакомился с набирающей обороты новой системой контроля версия – она же git и её вёб-хранилище – GitHub.com.

До сих пор я знал только одну VCSSubversion, с которой работал последние три года. Как оказалось, по сравнению с git (да и с Mercurial, судя по всему, тоже) она крайне простая и… не хочу сказать примитивная, потому что свои задачи она решает более чем успешно – скорее просто VCS с другим принципом работы (начать с того, что она централизованная, как CVS)

При первом же знакомстве git меня удивил тем, что большинство операций там делается через командную строку – собственно, набор утилит git под Windows – ничто иное, как портированный bash с основными утилитами Unix. При этом GUI-инструменты git (например, SmartGit) мало того, что просто интерфейсы к git.exe, так ещё и понять, что именно они делают можно только уже познакомившись с работой с git из командной строки.

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

«…»

No comments yet | Read rest of this entry »

Removing bottom margin in Firefox image links

Removing bottom margin in Firefox image links

Firefox (since at least FF 2) has a strange habit of adding a small (3-pixel) margin to the bottom of images if they're part of a link (<a><img /></a>). Recently I went googling for the solution and found it (somewhere, the link is now lost): this only happens in XHTML documents so you have 2 options: to remove the DTD completely (something you'd avoid by all means) or to make the img tag block using CSS.

This isn't an obvious solution but who cares as long as it works…

Sample code:

No comments yet | Show this entry »

Директивы nginx – root и alias

Директивы nginx – root и alias

Решил для разнообразия написать компьютерный пост на русском – благо это просто краткая заметка для моей памяти.

Для связывания URL и локального пути в ядре nginx есть две директивы: root и alias. Обычно используется первая – например, в такой форме:

Здесь запрос любого файла с расширением htm, html, jpeg и т.д. будет связан с локальным путём /usr/home/mysite.ru/pub – анпример, http://mysite.ru/path/file.rar адресуется к /usr/home/mysite.ru/pub/path/file.rar. Как видно, nginx включает в локальный путь путь из URL (/path/).

Однако иногда нужно больше гибкости – часто нужно исключить путь к файлу в URL из локального пути, либо если используются регулярные выражения – вставить их совпадения в путь ($1 и т.д.). Это делается директивой alias:

В этом примере мы перенаправляем запрос вида http://mysite.ru/bundles/mybundle/resource.css в /usr/local/www/somewhere/bundles/MYBUNDLE/public/RESOURCE.CSS – как видим, новое расположение может быть вне любого «document root» (такого понятия в nginx по сути нет), а также может использовать $N из выражения родительского **(http://nginx.org/ru/docs/http/ngx_http_core_module.html#location location))**ю

No comments yet | Show this entry »

Glitches with FreeBSD shared library file perms

Today I got finally tired of constant server hangs because of Apache's httpd process' segfaults (signal 15) every one-two days and decided to rebuild all ports I have installed because, as I know, segfauls happen when binaries/shared libraries were built on a different system than on the one they're ran at. Or if they were linked to old library versions before an upgrade, for instance.

So I did this with shportupgrade -rRfbuv apache option which took the server roughly 8 hours to complete. However, after that I got zillion of Cyrus messages in my error log saying things like:

These lines quickly filled the logs resulting in 690 Megabytes (!). I didn't have a clue for some time and restarting Cyrus, Postfix or the entire server yielded no visible changes. Then I looked further into the log file – somewhere in the middle there turned out to be several lines like this:

I tried to execute the listed command from under the cyrus user and got this message:

«…»

No comments yet | Read rest of this entry »

Emulating sleep using ping in Windows command line

Albeit there's no built-in command for sleeping in Windows you can use ping to simulate it.

There's no standard Windows command to delay batch file execution – however, as suggested on this article we can use ping command present in most Windows installations (those having netutils). The syntax is:

Here we try to ping an IP from the private range (10.254.3.174) which isn't likely to exist on your network (if it does just change the command).

  • -w specifies timeout in milliseconds – this is effectively out sleep delay
  • -n 1 sets number of pockets – this is our delay multiplier
  • >NUL 2>&1 suppresses ping output (it will complain about unreachable address and such)

So to sleep for 1.2 seconds you can use this command:

No comments yet | Show this entry »

Managing file templates in Windows XP

Explains how to customize File | New templates of Windows Explorer using TweakUI and Registry Editor (regedit.exe).

Managing file templates in Windows XP

I have known and still know many people who were claiming that Windows Explorer is terrible, unfriendly and actually slow while oldy Norton Commander was a piece of usability art and FAR or Total Commander as its reincarnations are what Windows should have instead of its ugly Explorer. They actually do say «ugly», huh.

That's something I can't really understand albeit I have worked with Norton Commander myself many years ago – and since the time of my first Windows installation I've been using standard Explorer which is quite a convenient tool, I would say. More convenient in GUI environments than Norton is anyway.

One of its useful features are file templates that you can invoke using either File main menu or folder context menu (see the screenshot on the left). There are at least 3 ways of customizing it:

  1. Using TweakUI – a freeware Microsoft tool with useful features making up for some would-be Control Panel options. Among other things it provides means for creating and deleting file templates.
  2. Editing files in %AllUsersProfile%\Templates and %UserProfile%\Templates – this is where all users' and current user's templates are stored; however, it only works for already created file templates and won't necessary work for new ones even if they belong to a registered file type.
  3. Directly editing the registry – this is the low-level way of customizing templates and it's what I will explain below.

«…»

Popular post (8 comments) | Read rest of this entry »