Monday, March 11, 2013

FFTW3 Sound Spectral Analyzer Example

Using libsndfile, ncurses, alsa-libs and of course fftw3 library, one can write a 200-liner console program in C that performs spectral analysis of a sound file while playing it. This is of course limited to audio files supported by libsndfile, which is currently wav and ogg. But nothing prevents people to do lame -d or use a similar decoder and pipe the resulting wave to the program.

What I am talking about? Look:

https://github.com/jirislaby/collected_sources/tree/master/snd_fft

Wednesday, February 20, 2013

Phone+Bluetooth=Laptop Control

Controlling your laptop using your phone? Sure:
https://github.com/jirislaby/L2cap
Using Bluetooth, a phone can move with mouse pointer and press mouse buttons on your machine. The only thing needed is to run l2cap from the repository on the machine and the Java app on the phone. Of course l2cap is Linux-specific but it should not be that hard to extend to other systems.

Monday, June 25, 2012

Installed, but unpackaged files (debug ones)

When creating an RPM of some package this error might occur. Sometimes it does not make much sense as it lists only debug files as unpackaged.

In this case, it is most likely caused by invalid use of %exclude macro. Grr. I spent a bunch of time debugging this. HTH somebody.

Sunday, April 15, 2012

All TTY Drivers to Have tty_port

So the second pile of TTY patches have been accepted…

And now, the most of drivers in the tree was augmented to operate with tty_port structure. The only few remaining will be changed in the next merge window (a month or so). After that, every out-of-tree driver will be broken unless it is fixed right now. You have been warned.

One might ask, why we are doing this change? The answer is simple: The code is broken. Some of the code predates Linux 1.0. Yes, it is no argument, but you know what? It is full of ancient broken code designed originally for uniprocessor, no preemption and such. Thus there are many race conditions without any real chance to fix them in the state the code stands now.

And yet, Big-Kernel-Lock (BKL). You heard that it is gone from the kernel for some time already, right? No, it is not. It is still there. Some parts of the kernel still have left-overs from this ancient coarse-grained crap. In TTY, it is called Big-TTY-Mutex. And nobody really knows what is protected by the lock (and what is not). And as a reader may suggest, I volunteered to find out.

The plan is to centralize common code which is repeated over and over. This is done by using tty_port helpers. Next, we will move TTY I/O buffers from tty_struct to tty_port and revamp locking a bit. The move will also ensure that we will not need to care about tty_struct in a prevalent count of interrupt service routines, timers etc. They really need TTY buffers, not a structure which randomly comes and goes with every open and close the way tty_struct does. And since tty_port is in the memory intact as long as the device stays in the machine (and its interrupt service routine installed in the kernel), it is a perfect place to put the buffers in. And this is exactly what is happening here right now.

Stay tuned and report bugs!

Saturday, April 14, 2012

A Must-Have for Czech OpenStreetMappers

I collected the following URLs and find them useful when mapping: Besides these links, what is usually good to have is a GPS tracker. I use the one in my Nokia 5800 XM phone. Then It becomes handy if one has a bike to explore their hometown. And it really helps to have a (fast :)) motorbike to take a look at other cities.

Monday, March 19, 2012

Making ant work with antlr3 and cpptasks

When one uses antlr3 or cpptasks with ant, it might happen, that the following error occurs during build:
$ ant jar
...
.../build.xml:89: Problem: failed to create task or type
        antlib:org/apache/tools/ant/antlr:antlr3
.../build.xml:92: Problem: failed to create task or type
        antlib:net.sf.antcontrib.cpptasks:cc
The cure is (and always was) simple on openSUSE. One just needs to define OPT_JAR_LIST environment variable with appropriate jar names of packages where those classes are defined:
OPT_JAR_LIST='ant-antlr3.jar cpptasks.jar' ant jar

Tuesday, March 13, 2012

Adding a New Clang Checker

Create a file with checker, e.g. by making a copy of some other. Make sure you leave ClangSACheckers.h include in your checker.

Next, you need to add an entry to CMakeLists.txt and Checkers.td. Without that, you will not have your checker built or listed in clang checkers list respectively.

You may hit this build error:
error: 'void clang::ento::register...Checker(clang::ento::CheckerManager&)' should have been declared inside 'clang::ento'

In that case, check that you have ClangSACheckers.h included and that you did not misspelled filename in the two files above.

If the compilation is successful, you should see your checker in the clang checker list generated by:
clang -cc1 -analyzer-checker-help

Wednesday, December 30, 2009

2009 is over

Well, a year full of grief, death, crisis and bad status of politics in Czech Republic is at its end. Finally.

Wish smile to all. Hopefully 2010 will be better. Full of life, energy and satisfaction.

Saturday, August 08, 2009

To all farmers

I strongly ask all farmers to NOT lose their pea in corners. In spite of the dark yellow seeds are pretty visible on black asphalt, one can miss them and fall down (from a (motor)bike). :)

Saturday, July 11, 2009

First 5000 km on my ninja

Heya, my Kawasaki ZX-6R (known as Ninja, yr. 2002) odometer hit first 5000 km with me. I bought it on November, riding since February. No accidents (knock-knock), I met few crazy car drivers though. I hope it will remain that way for a long time. I'm trying hard to ride safely.

It did recall my memories from my first car journeys. I has been driving like an idiot. At least I feel it that way today. I think it's the same with the motorcycle now – that I'll see later.

I love it! Especially cornering is great adventure. I read about that much. Trying to catch up the information, still lea(r)ning. Who would say it'll turn right, when you push right handle forward?

Friday, May 29, 2009

Funeral

I'm sad, we all are. After we recovered from the shock a bit, another event happened. A funeral. Blah, I hate it.

Why this all happens? Just because... If only there was something to do, no, you can only stand still, stare and hope for a miracle. But it doesn't occur. Again and again.

Friday, May 22, 2009

R.I.P.

We all loved you.

Sometimes life is a fucking weirdo, we have to put up with that.

Saturday, March 07, 2009

I bought Nokia 5800

I may recommend this phone. Really. I had Nokia N80 for almost 3 years (a month after introduction to the czech market) and upgrade to Nokia 5800 was eligible choice.

It satisfied all my needs and expectations, especially what I hated on N80 the most has improved a heap – sound output. My Sennheiser CX 300 feels the difference, no noise, great music experience.

Saturday, November 08, 2008

ath5k as an AP

I got ath5k AP mode working at least with 5212/5213 cards (known to be defunct with 5413 and 2425 at the time being).
  1. One needs these patches to the kernel:

  2. Grab some later version (a git snapshot at best) of hostapd and compile

  3. Run hostapd hostapd.conf

Saturday, April 05, 2008

antlr is (not) broken (alias code too large)

After 2 hours of debugging this issue down, I've found out, that antlr is probably broken on too fast machines. My E6850 core 2 duo (3GHz) with antlr 3.0.1 generates simply too huge code, so that java can't compile it. (I don't hit the problems on same software configurations with different hardware – my notebook with core 2 duo neither another desktop AMD 64 dual core 4200+.)

If I run 2 this suckers:
cat /dev/zero > /dev/null &

and antlr under nice (nice java -cp ... org.antlr.Tool My.g) priority just for sure, it just gives out totally different code, shorter for about 15000 lines (diff). There must be some uglymoronic race.

EDIT: Ok, according to Terrence Parr (the antlr leader), it's not a bug from his point of view, see his comments below.

The trick is -Xconversiontimeout 600 on my machine.

Wednesday, April 02, 2008

Empty structure size in gcc and g++

Did you know that empty structure in GNU C has size 0, whereas in c++ it is 1 character?
#include <stdio.h>

struct A {
};

int main(void)
{
printf("%zu\n", sizeof(struct A));
return 0;
}

Output of this after gcc a.c -oac && ./ac is 0, g++ a.c -oac && ./ac will output 1...

See gnu cc manual, chapter 5.15.

Sunday, January 06, 2008

Něco o zákonodárcích

Tak jako informatik nemůže ladit programy v rutinním provozu, neměl by ani zákonodárce ladit své zákony až po uvedení v platnost.

-- RNDr. Jan Skula, CSc.

Saturday, November 24, 2007

Bakaláři SQL vulnerability

A few weeks ago (precisely Nov 7 2007) I've found out a way how to break into the bakaláři czech high school system database. I used probably the most known method called SQL injection. After something below an hour (got up about 9:30, sent an email to the school at 10:08) I got the magic formula to execute SQL queries.
fuj order by cas desc'; select 1; -- '

Ok, so I informed the school which I had been attending for 6 years in the past about the security hole. But then I realized that it's not school specific, I found many schools which use the same system, so I didn't hesitate to drop a message to bakalari.cz people. Their reaction was fast and they fixed the problem next morning with promise that they will post updates to all high schools. Nice.

Not that much, because this haven't happened so far, you can still find many schools which are still vulnerable against this attack. This pisses me off little bit, I only hope they weren't involved in any grant for this sloppy work.

EDIT (Dec 8) they finally either seem to distribute the upgrade or the school admins update the soft.

Monday, October 29, 2007

fglrx and x1450

After many fights with this driver, it finally works!

I started use it about 8.38* and it never worked with X 7.2 from Fedora 7. I had to use 7.1 from F6. After upgrading to F8 with changed glibc 7.1 X didn't work anymore. I had to install old X proto devel and recompile whole X from F6 and use it with fglrx up to 8.40. No hw acceleration, no video overlay. I couldn't use it with F6 packages too, fglrx kernel module had broken suspend/resume (did you know, that you can use X driver with no need to use the kernel module).

Now I have 8.42.3 with patches from livna package (to have compilable sources on 2.6.23) and lkml (to enable suspend stuff) running on X 7.3 from F8. Also I can have fglrx kernel module loaded, suspend seems to work, hw accel and video overlay enabled, so I'm happy.

Friday, October 26, 2007

gmail & imap

I love it!