29 November 2008

Thinkpad X60s, WiFi and Debian

You will need following packages:

  • wireless-tools
  • wpasupplicant
  • firmware-iwlwifi
  • >=linux-image-2.6.23
After installing the packages create wpa_supplicant.conf (change 'your_ssid' to your router SSID and 'your_password' to your real passphrase):
# wpa_passphrase your_ssid your_password > /etc/wpa_supplicant/wpa_supplicant.conf

Open /etc/wpa_supplicant/wpa_supplicant and make sure it looks like this:
ctrl_interface=/var/run/wpa_supplicant

eapol_version=1
ap_scan=1
fast_reauth=1

# Only WPA-PSK is used. Any valid cipher combination is accepted.
network={
ssid="your_ssid"
proto=WPA
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
priority=2
#psk="your_password"
psk=6d5324610d3627ab4f97b80cf22b742996d82c022b283a874e88d083a299734c
}
Open and add to /etc/network/interfaces following text:
# Wireless
allow-hotplug wlan0
iface wlan0 inet manual
wpa-drive wexp
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
Run this command and you're done:
# ifconfig wlan0 up

More information can be found on Debian Wiki.

14 July 2008

Как встречают новые идеи в информатике

Я наткнулся на интересную подборку отзывов на первые публикации таких учёных как Дейкстра, Тюринг, Код, Хоар и т. д. Революционные идеи часто встречают скептические замечания о их практической пользе и простоте реализации.

13 July 2008

Context menu for column headers of .NET ListView

ListView doesn't provide ColumnHeaderMouseClick event so I had to find a workaround to display context menu for column headers. There is a way to do this by resorting to Windows API but my solution is easier.

Let's say we've got a ListView control called contentsListView and two menus: generalContextMenu and headerContextMenu. generalContextMenu should be displayed when user right-clicks on an item and headerContextMenu should be displayed when he clicks on a column header.

Set the list view's property 'ContextMenuStrip' to generalContextMenu:
contentListView.ContextMenuStrip = generalContextMenu;

Add handler for 'Opening' event of generalContextMenu:
generalContextMenuStrip.Opening += generalContextMenu_Opening;

I have played with debugger a bit and found out that contentListView.GetItemAt returns first visible item of the list even when we actually click on a column header. So, when we get some value this means we either clicked on an item or on a column header. Any list item is located below the header, so if the item Position.Y is less than MousePosition.Y then user clicked on a column header.

Here is the code for the handler:

private void generalContextMenu_Opening(object sender,
    CancelEventArgs e)
{
    Point pt = contentListView.PointToClient(new Point(MousePosition.X,
        MousePosition.Y));
    ListViewItem item = contentListView.GetItemAt(pt.X, pt.Y);
    
    // Not an item or a column header
    if (item == null)
    {
        e.Cancel = true;
        return;
    }
    
    // Is it a column header?
    if (item.Position.Y > pt.Y)
    {
        e.Cancel = true;
        headerContextMenu.Show(MousePosition);
    }
}

17 June 2008

Русская типографика и Windows

Всегда приятно читать красиво оформленный текст, но его не так просто набрать с помощью русской раскладки, которая входит в поставку Windows. Свою типографическую раскладку можно создать с помощью утилиты Microsoft Keyboard Layout Creator или же можно взять готовую раскладку на сайте Ильи Бирмана.

17 March 2008

Installing Debian Lenny

Two days ago I got my hands on Debian 4.0 testing DVDs. Debian installation was smooth on my previous PC but I ran into problems while installing it on the PC with ASUS P5K SE motherboard, IDE DVD-RW drive and IDE hard disk. Debian boots up from the install DVD but fails to find the DVD during the installation process. The solution is to boot with option 'expert generic.all_generic_ide=1'.

1 February 2008

Gismeteo предрекает апокалипсис

Согласно Gismeteo.ru, 2 февраля мороз в Москве достигнет небывалых ранее размеров :-)

3 December 2007

Новый год

Новый год я проведу в Тамбове, куда приеду 29-го декабря, а уеду 6-го января.