воскресенье, 30 декабря 2012 г.

Learn Sanskrit using ActionScript

Here is a simple and (I hope) useful tool for learning Devanagari alphabet. Basically, it is a Flash application wrote in pure ActionScript3 programming language without any visual tools or IDEs. Devanagari alphabet consists of 49 "letters". Each Devanagari letter is given with corresponding IAST transliteration symbol (sometimes with alternative variants). You can also train pronunciation: alphabet is chanted by Igor Belyaev -  prominent specialist in Sanskrit language and Indian culture.

Flash application can be found here.
And here, on GitHub, you can browse program's source code.

пятница, 30 марта 2012 г.

Sound Blaster Connect Hi-Fi USB + Linux

This will be interesting for those who want to buy an external sound card but not sure if it will work with Linux. Official ALSA site lacks this information, so I will try to fulfil it. Short answer - YES, Sound Blaster Connect Hi-Fi USB (SB1260) works with Linux, at least with Ubuntu 11 with PulseAudio server.

There are three main reasons for buying an external audio card:
  • Internal sound card of your laptop had fried
  • Your laptop lacks Line-In connector (this was the reason for me)
  • Sound quality or set or features of your internal sound card doesn't satisfy you
Here is minimal background required for further explanations: recent Linux kernels have built-in support for USB audio devices (snd-usb-audio kernel module), ALSA (Advanced Linux Sound Architecture) system is used to orchestrate all sound devices at low level. Morden Linux distributions come with audio server software, e.g. PulseAudio. PulseAudio acts as an audio dispatcher/router/manager between applications and ALSA system. It can do a lot of cool features, that would be difficult with bare ALSA.

As for playback, SB1260 started to work out-of-box: you just need to plug the card and change active output device in "Sound settings" menu (right click on the speaker icon in the tray in my distro). Line-In recording was a little more tricky. I've tried to select an active input device (in neighbour tab) and adjust record level but with no luck. The only thing I was able to record is a silence. After 3 evenings of experimenting with the %subj% I came up with a brilliant idea: use low-level alsamixer program to check & adjust recording level and ... it worked! Record level was at 0% and PulseAudio's mixer didn't change that.

I hope this will save 3 evening of your life!

UPDATE: Also I had to switch Capture Source from 'mic' to 'line-in' in alsamixer. Unfortunately doing the same thing using PulseAudio's front-end didn't help.

вторник, 24 января 2012 г.

Как сгенерировать себе случайный аватар?

Сгенерируем тысячу и выберем самый красивый:
  • mkdir /tmp/avatars/
  • for i in `seq 1 1000`; do hash=`dd if=/dev/random bs=16 count=4 2>/dev/null | md5sum | awk '{ print $1 }'`; wget -q "http://www.gravatar.com/avatar/$hash?s=128&d=identicon&r=PG" -O /tmp/avatars/$hash.png; echo "$hash"; done
  • Идём в /tmp/avatars/ и выбираем аватар. Если нужна картинка большего размера, то можно вручную сделать HTTP-запрос с этим хешем.
  • Если случайные числа в /dev/random быстро заканчиваются, то замените его на /dev/urandom