About Me

My photo
i'm a laugning jack-o'-lantern

Friday, June 24, 2011

zip / unzip

zip() is simple and tricky buit-in python function at the same time.
>>> zip(range(3), '123')
... [(0, '1'), (1, '2'), (2, '3')]
That's simple, heh. :)
The trickest part is when you've got the result of your zip(a, b), but you want to unzip it.
>>> a1 = (1, 2, 3)
>>> b1 = (4, 5, 6)
>>> c = zip(a1, c1)
>>> # woo-a la
>>> a2, b2 = zip(*c)
>>> print a1 == a2 and b1 == b2
... True

We've got the origial values. Congrats!
BTW, unzip is described in python documentation http://docs.python.org/library/functions.html#zip

Wednesday, January 12, 2011

psi+

I always used psi as jabber-client for linux, but there were some feelings that it needs something more for comfortable usage. And couple weeks ago I've found that there are some russian guys who work on psi+ (based on psi) that already has lot's of customizable things. I really love it.

In Debian (and may be Ubuntu, but I haven't checked) it's available in repos, so you could install it:
apt-get install psi-plus

Monday, December 27, 2010

VMWare Player

I wanted to figure out how to work with my tablet (Wacom Intuos 4) using virtual machine. I tried VirtualBox4, but nothing worked out (mb I'm too stupid). After that I download "VMWare Player" and installed it.

Everything but vmmon module started well. `dmesg | tail` said:
kernel: [214725.964887] vmmon: disagrees about version of symbol smp_ops
kernel: [214725.964896] vmmon: Unknown symbol smp_ops

After googled for a while, I've found that `smp_ops` is not available at debian 2.6.32 kernel ( http://lists.debian.org/debian-kernel/2010/12/msg00507.html )

Finally solution was found:
wget http://files.archlinux.org.il/vmmon_fix_2.6.36.sh
chmod +x vmmon_fix_2.6.36.sh
./vmmon_fix_2.6.36.sh ( as root )

P.S. Tablet works well! I have lots of fun with it.

Thursday, March 25, 2010

PyFlakes.

1. There is wonderful command line utility that checks python code  called pyflakes.  
Here text from pyflakes man page: 
Pyflakes is a simple program which checks Python source files for errors. It is similar to PyChecker in scope, but differs in that it does not execute the modules to check them. This is both safer and faster, although it does not perform as many checks. Unlike PyLint, Pyflakes checks only for logical errors in programs; it does not perform any checks on style.
All commandline arguments are checked, which have to be either regular files or directories. If a directory is given, every .py file within will be checked.
When no commandline arguments are given, data will be read from standard input.
2. There's vim filetype plugin that uses pyflakes utility:  http://www.vim.org/scripts/script.php?script_id=2441
p.s. Это фрагмент письма в рабочую рассылку. Переводить не стал. :)

Thursday, March 18, 2010

amarok 2.2.2


В чудном музыкальном комбайне под названием Amarok есть поддержка «панели настроений» (moodbar). Что это такое? Это когда вместо унылого прогресс-бара появляется расчудесно-цветной прогресс-бар, в котором визуализирован аудио контент. Сложно сказано, но выглядит просто офигенно.

Как это устанавливается:
  • в настройках amarok ставим "панель настроения";
  • ставим moodbar: apt-get install moodbar;
  • запускаем нижеописанный скрипт в директории с музыкой:
#!/bin/bash
NUMCPU="`cat /proc/cpuinfo | grep processor | wc -l`"

find . -type f -regextype posix-awk -iregex '.*\.(mp3|ogg|flac|wma)' |
while read i ; do
if [ `jobs -p | wc -l` -ge $NUMCPU ] ; then
wait
fi

TEMP="${i%.*}.mood"
OUTF=`echo "$TEMP" | sed 's#\(.*\)/\([^,]*\)#\1/.\2#'`
if [ ! -e "$OUTF" ] ; then
moodbar -o "$OUTF" "$i" &
fi
done


Wednesday, March 17, 2010

skype on debian 64 bit

Долгое время не доходили руки разобраться с проблемой установки (и работы) 32-битной версией skype под 64-битный debian. После гугления выявлены следующие шаги установки:
  1. Качаем skype для debian отсюда
    http://www.skype.com/go/getskype-linux-beta-deb
  2. Устанавливаем необходимые библиотеки:
    apt-get install ia32-libs ia32-libs-gtk
  3. Устанавливаем skype:
    dpkg -i --force-architecture skype-debian_2.1.0.81-1_i386.deb
  4. Удаляем* /usr/lib32/libpulse* ; можно не удалять, а просто поменять права:
    chmod 000 /usr/lib32/libpulse*
Теперь можно радоваться жизни.

Saturday, March 13, 2010

Очень радует новый дизайн. По этому поводу, начну писать в этот блог чаще.

Saturday, October 31, 2009

задача от Сергея Быстрицкого

Существует ли разнобокая (не равнобокая) трапеция, которую можно рассечь прямой на две равные фигуры?

Monday, October 19, 2009

Задача от А. Драля

Есть комнада 2x3 метра. В 3-х метрой стене посередине стоит дверь, длина которой 1 метр. Предложите фигуру площадью не меньше 3 м2, чтобы она вошла в комнату.

Sunday, August 16, 2009

Задача от А.И.Галочкина

Дан график функции y=sin(x) на интервале [0; a], построенный в прямоугольной системе координат с одинаковым масштабом по осям. С помощью циркуля и линейки построить касательную к графику в точке x0(0; a) если:
  1. a(π/2; π);
  2. a(0; π/2).