Dec 28, 2009

Why I believe that Microsoft and Yahoo! are dying

I use the Internet everyday. The two most things I do is checking emails and searching for information. For these two purposes, Microsoft and Yahoo are completely useless for me. I don't have to tell you Google is the best. But, there is a bigger application on which Microsoft and Yahoo! is dying, the social networking. Microsoft and Yahoo! can't make their services sticky to users by integrating their services. And, they can't follow the trends, like iPhone or Ajax.

Stickiness 

When I say social networking, I mean everything between me and friends in the cyber space, photos, videos, status, instant messages, blogs, etc. You may say, well, Microsoft and Yahoo! have them all. Right, the problem is that they didn't integrate them well.

Google integrates all these services very well. An instant messenger has no difference with an email. Thus, the chat log is an email. If I am offline and my friend send me a message, it will become an email for me. If my friend is lazy, they can leave me a voice message, even through telephone via Google Voice, and it will become an MP3 file in my Gmail. I just need to click the "Play" button inside my email.

My Gmail contacts are my contacts for everything, my Google Docs, my Google Talk, etc. I don't have to maintain different contact lists for different purposes.

For Facebook, everything is also integrated. I can share everything with my friends on Facebook. You must have seen "Share on Facebook" button on many news websites. They can stalk my life pretty well in Facebook.

One thing drives me crazy is that in Microsoft and Yahoo!, every service they provide is discrete. My instant messaging contacts are not the same as my Email contacts. The message people send me on their social website is not part of my email.

The trend: iPhone and Ajax

In the iPhone/iPod Touch era, I haven't heard any Microsoft or Yahoo! iPhone/iPod Touch application (let's call it iApp) or anyone using such an iApp. I use my iPod Touch as a portable Internet terminal. Google and Facebook have free iApps then I use their services.

Another trend is the Ajax technology. Very apparently, Microsoft and Yahoo! 's Ajax has many bugs, including the incompatibility with some browsers - I seriously mean Firefox, Chrome or Safari. And their Ajax sometimes fails on my browsers - maybe even the simple login at Microsoft Hotmail. The real Ajax program is like Google and Facebook's user interface, fast, small and neat.

So, they are dying. And don't worry. Just let them die - I have no stock share on them.

Dec 3, 2009

100% / disk usage ?

I got very freaked out today that my / is 100% used. I did not know why and this was really annoying since my program couldn't load due to not enough temp space.

$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1             19615736  18618140      1168 100% /

I googled a while and noticed many people mention it is because of some stupid backup program. But, I didn't use it.

So I focused on what I have downloaded since yesterday. Oh, I figured out, it must because of the phoronix-test-suite. I checked their doc and deleted its files under my home directory. And things became good again.

So, if you get the same trouble, just think what you have downloaded *unintentionally*.

Nov 26, 2009

lparse 1.1.1 conflicts with GCC 4.3.3

by Forrest Sheng Bao http://fsbao.net
If you are having problem compiling lparse 1.1.1 using GCC 4.3.3, specifically on Ubuntu 9.04, and your error happens to be like this
g++ -g -O3 -c instance.cc
In file included from instance.cc:23:
extern.h:86: error: previous declaration of ‘long int strtol(const char*, char**, int)’ with ‘C++’ linkage
/usr/include/stdlib.h:186: error: conflicts with new declaration with ‘C’ linkage
/usr/include/stdlib.h:186: error: declaration of ‘long int strtol(const char*, char**, int) throw ()’ throws different exceptions
extern.h:86: error: from previous declaration ‘long int strtol(const char*, char**, int)’
just do a simple step:
Open src/extern.h and comment the line
long int strtol(const char *nptr, char **endptr, int base); 
which is around line 86. strtol is a C++ standard library function used to convert numbers of different radixes (or bases). So it doesn't need to be redefined here.
This is my GCC version info:
$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.3-5ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) 

Solving Veena's adsolver conflicts with GCC 4.x

by Forrest Sheng Bao http://fsbao.net
There are many open source projects called adsolver. Here I mean this one http://www.cs.ttu.edu/~mellarko/adsolver.html , made by an alumni of my lab, combining Answer Set Programming and Constraint Logic Programming. If you download her solver, you will find many problems on compiling it on *modern* Linux and gcc. So, here is the solution.
Following procedures are tested on Ubuntu Linux 9.04 with gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) .
First batch of errors:
$ make
g++ -DHAVE_CONFIG_H -I. -I. -I..     -g -O2 -c array.cc
In file included from literal.h:33,
                 from predicate.h:30,
                 from array.cc:33:
instance.h:161: error: ‘RBTreeIterator’ does not name a type
instance.h:162: error: ‘HashSetIterator’ does not name a type
In file included from array.cc:33:
predicate.h:140: error: extra qualification ‘Predicate::’ on member ‘getMixedInstance’
predicate.h:187: error: ISO C++ forbids declaration of ‘InstanceIterator’ with no type
predicate.h:187: error: expected ‘;’ before ‘*’ token
For the 1st error at instance.h:161, add
class HashSetIterator;
class RBTreeIterator; 
at the end of the block of #include statements in instance.h.
For the 2nd error at predicate.h:140, change line 140 from
long Predicate::getMixedInstance(long i); 
to
long getMixedInstance(long i);
since you don't need namespace when declaring a function inside a class .
Second batch of errors:
Now run make again and *hopefully* you will see this error:
sm_smodels.cc:21:22: error: iostream.h: No such file or directory
sm_smodels.cc: In member function ‘void SM_Rule::print()’:
sm_smodels.cc:806: error: ‘cout’ was not declared in this scope
sm_smodels.cc:825: error: ‘endl’ was not declared in this scope
sm_smodels.cc: In member function ‘void SM_Rule::print_internal()’:
sm_smodels.cc:831: error: ‘cout’ was not declared in this scope
sm_smodels.cc:845: error: ‘endl’ was not declared in this scope
sm_smodels.cc: In member function ‘void Dcl::print()’:
sm_smodels.cc:1114: error: ‘cout’ was not declared in this scope
sm_smodels.cc:1114: error: ‘endl’ was not declared in this scope
sm_smodels.cc: In member function ‘void Program::print()’:
sm_smodels.cc:1419: error: ‘cout’ was not declared in this scope
sm_smodels.cc:1438: error: ‘endl’ was not declared in this scope
sm_smodels.cc: In member function ‘void Program::print_internal(long int)’:
sm_smodels.cc:1458: error: ‘cout’ was not declared in this scope
sm_smodels.cc:1458: error: ‘endl’ was not declared in this scope
sm_smodels.cc: In member function ‘void Smodels::print()’:
sm_smodels.cc:1671: error: ‘cout’ was not declared in this scope
sm_smodels.cc:1675: error: ‘endl’ was not declared in this scope
sm_smodels.cc: In member function ‘void Smodels::printAnswer()’:
sm_smodels.cc:1694: error: ‘cout’ was not declared in this scope
sm_smodels.cc:1698: error: ‘endl’ was not declared in this scope
sm_smodels.cc: In member function ‘void Tree::check_consistency(Tree::Node*)’:
sm_smodels.cc:1882: error: ‘cerr’ was not declared in this scope
sm_smodels.cc:1883: error: ‘endl’ was not declared in this scope
sm_smodels.cc:1888: error: ‘cerr’ was not declared in this scope
sm_smodels.cc:1889: error: ‘endl’ was not declared in this scope
make: *** [sm_smodels.o] Error 1
The reason is in C++, including library does not need .h suffix. So, open sm_smodels.cc and remove the .h suffix for iostream library. And do not forget to insert this line
using namespace std;
after #include blocks.
Now you are should have no problems to finish compiling adsolver.

Nov 19, 2009

You have a parallel pin array on your *modern* motherboard

For anyone who works with MCU, DSP or in general embedded systems, you must know how important the parallel port on your PC is. But, it seems in lately few years, fewer and fewer motherboards have a pink parallel port.

Well, I just found the trick lately. There is a parallel pin array on your boardboard, like USB extension pins. On the PCB, around the parallel pin array, it prints something like "J_PRINTER"

So, what you need is a socket to parallel port, the IEEE 1284 D-sub connector. You just need to google something like "Motherboard Parallel Port Adapter," then you can get it within few dollars from places like eBay. Then you can have a regular parallel port on your computer.

In general, *modern* motherboard will say it has a "Printer port" at the "Internal I/O Connectors" section of its specification.

Nov 12, 2009

How Republicans screwed up America from 1998 to 2008

I checked the currency rate between US dollar and Canadian dollar today. It shocked me that one USD is only 1.04 CAD now! So I used Google Finance to figure out how this change happened. (Full URL http://www.google.com/finance?chdnp=1&chdd=1&chds=1&chdv=1&chvs=Linear&chdeh=0&chdet=1258005666708&chddm=2144693&q=CURRENCY:USDCAD&ntsp=0)

I compared USD to Euro and Canadian dollars in past 5 years. You can see two greatest changes, late 2004 and late 2008, when Bush Jr. and Obama won the presidency respectively. It went down a lot when Bush Jr. won and came up a lot when Obama won.

So, can I infer that the whole world got disappointed when Bush Jr. won in 2004 and got pleased when Obama won in 2008?

Can we say most countries out there are American allies? Why did they dislik Bush and preferred Obama? Why did only a few countries join US  actions in Afhganistan and Iraq? Remember that, they joined America in World War II and the Cold War.

From the currency rate plot, I have to say that the whole world had seen that Republicans screwed up this country.

I am conservative and religious. But I dislike anyone taking advantage of religion or ethics to get their ballots. I really got confused on things as follows:

  • Abortion is wrong; so war is right? Even when war is not the last option?
  • Jesus healed people in the Bible; so we can refuse giving people medical service since they are illegal immigrants? Did Jesis ever ask them "Are you legal in Israel?" before taking care of them?
  • Not accepting the Gospel of God is wrong; so death penalty is right? Banning criminals to know the name of Jesus and be saved through His name? 
  • We are made from the image of God - I assume someone out there agrees this. Including terrorists, right? So can you torture them? Torture a being made from the image of God, thru the hand of God, with the spirit of God? 
I have no answers to above debates but I do struggle a lot on them. I really don't like anyone influencing others' choice and claiming it's based on the Bible. Repeating a lie a thousand times will make it a truth. That's the trick of Nazi and Communists. You should inspire people to think and refer the Bible by themselves. I don't believe torturing, death penalty, wars or banning illegal immigrants to get free medicare are consistent with the ideas of Bible.

I don't think American allies, Europeans and Canadians, are all wrong or they are all bad people. Just see the currency and stock market in past few years - the economy has been screwed up. Things are not good.

To the best of my understanding to my religion, if we insist to do something, and things are getting worse during a long time, probably we are not on the track that God want us to go.

It's hard to know the plan of God. So don't pretend you know and make claims. What I can do is to think rather than listen to your repeating. That's how Martin Luther noticed the problems of Catholic church, right?

Nov 6, 2009

AVR32 development on Linux

by Forrest Sheng Bao http://forrest.bao.googlepages.com
I have to say that ATMEL is the most Linux-friendly company among all MCU/DSP makers in the world, followed by TI. Both TI and ATMEL use tons of open source toolchains so Linux zealots can build their apps on Linux.
I learned how to play with AVR 8-bit instruction set when I was an undergraduate. Now, I am gonna use AVR32, which is a 32-bit instruction set.
Here is some good information:
AVR32 32-bit MCU - Tools & Software: http://www.atmel.com/dyn/products/tools.asp?family_id=682#1443
ATEVK1100 development kit: http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4114 only $129
AVR32 Studio: http://www.atmel.com/dyn/Products/tools_card.asp?tool_id=4116 IDE on Linux, better than TI's solution
And, ATMEL has a tool chain, buildroot, to build Linux OS targetting AVR32 MCU. It says a very funny sentence on their website: Buildroot will not run under Windows. Atmel recommends beginners to use Ubuntu Linux, available from www.ubuntu.com.

Oct 24, 2009

EEG Signal Processing in Python and Scipy.Signal (1): Spectrum Estimation, FIR Filter Design, Convolution and Windowing

by Forrest Sheng Bao http://fsbao.net

I am doing a take-home midterm test of a class I am taking. So, I decided to use Python to to it. Below is a code for one problem. It includes several frequency used functions in classical signal spectral analysis and FIR filter design. The problem itself is to design bandpass filters over alpha to theta bands and apply them onto a EEG series, and plot the time domain and frequency domain signal, as well as the frequency response of filters. I used window methods to design FIR bandpass filters. The filters coefficients are smoothed by a Kaiser window. Filtering is implemented by convolving original signal with coefficients of filters.

The result of running this code is given below. Black lines in the bottom plot is the amplitude property of different filters. As you can see, signals outside filter bands are kicked out respectively.






# This software is a free software that comes with NO WARRANTY
# You have the right to obtain, modify and redistribute this code 
# under the terms of  GNU General Public License ver. 3 or later
# Copyleft 2009 Forrest Sheng Bao http://fsbao.net

from numpy import *
from scipy.signal import *
from numpy.fft import * 
from matplotlib import *
from scipy import *
from pylab import *

f=open('./EEG1_1c31.txt','r')
chno = 16   # total number of channels
eeg = [] 

while True:
 testline = f.readline()
 if len(testline) == 0:
  break #EOF
 testline = testline.split()
 eeg.append([])
 for i in xrange(0,chno):
  eeg[-1].append(float(testline[i])) 

ch = 1 # particualr channel to study 
eeg = array(eeg)
y = eeg[:,ch]         # the signal, study channel 'ch'
L = len(y)            # signal length
fs = 500.0              # sampling rate
T = 1/fs                # sample time
t= linspace(1,L,L)*T   # time vector

f = fs*linspace(0,L/10,L/10)/L  # single side frequency vector, real frequency up to fs/2
Y = fft(y)

figure()
filtered = []
b= [] # store filter coefficient
cutoff = [0.5,4.0,7.0,12.0,30.0]

for band in xrange(0, len(cutoff)-1):
 wl = 2*cutoff[band]/fs*pi
 wh = 2*cutoff[band+1]/fs*pi
 M = 512      # Set number of weights as 128
 bn = zeros(M)
 
 for i in xrange(0,M):     # Generate bandpass weighting function
  n = i-  M/2       # Make symmetrical
  if n == 0:
   bn[i] = wh/pi - wl/pi;
  else:
   bn[i] = (sin(wh*n))/(pi*n) - (sin(wl*n))/(pi*n)   # Filter impulse response
 
 bn = bn*kaiser(M,5.2)  # apply Kaiser window, alpha= 5.2
 b.append(bn)
 
 [w,h]=freqz(bn,1)
 filtered.append(convolve(bn, y)) # filter the signal by convolving the signal with filter coefficients

figure(figsize=[16, 10])
subplot(2, 1, 1)
plot(y)
for i in xrange(0, len(filtered)):
  y_p = filtered[i]
  plot(y_p[ M/2:L+M/2])
axis('tight')
title('Time domain')
xlabel('Time (seconds)')

subplot(2, 1, 2)
plot(f,2*abs(Y[0:L/10]))
for i in xrange(0, len(filtered)):
  Y = filtered[i]
  Y = fft(Y [ M/2:L+M/2])
  plot(f,abs(Y[0:L/10]))
axis('tight')
legend(['original','delta band, 0-4 Hz','theta band, 4-7 Hz','alpha band, 7-12 Hz','beta band, 12-30 Hz'])

for i in xrange(0, len(filtered)):   # plot filter's frequency response
  H = abs(fft(b[i], L))
  H = H*1.2*(max(Y)/max(H))
  plot(f, 3*H[0:L/10], 'k')    
axis('tight')
title('Frequency domain')
xlabel('Frequency (Hz)')
subplots_adjust(left=0.04, bottom=0.04, right=0.99, top=0.97)
savefig('filtered.png')
Reference: Signal Processing Toolbox of Scipy, http://docs.scipy.org/doc/scipy/reference/signal.html

Oct 5, 2009

Some great books

by Forrest Sheng Bao http://fsbao.net

There are some great books I always want too read. Following books are so famous that you can find them in online bookstore so easily. I cannot guarantee that you can find them in local bookstores coz they won't be as popular as movie stars' biographies. But they will definitely be in stock in next hundreds of years whereas movie stars' biographies will be dust in next 100 years.

General
The Analects by Confucius and his disciples

Is there a God? Or, are there Gods?
The Varieties of Scientific Experience: A Personal View of the Search for God by Carl Sagan
The Language of God: A Scientist Presents Evidence for Belief by Francis Collins
Things A Computer Scientist Rarely Talks About by Donald E. Knuth

Mathematics
Five Golden Rules : Great Theories of 20th-Century Mathematics -and Why They Matter, by John Casti
Mathematics-Its Content, Methods and Meaning, by A. D. Aleksandrov, A. N. Kolmogorov and M. A. Lavrent'ev, Original in Russian, being translated into many languages.
Men of Mathematics, by E. T. Bell

About Chinese
Chinese Characteristics, by Arthur H. Smith

Linux and Open Source
The Art of UNIX Programming, By Eric Raymond

Sep 30, 2009

Butterworth, Chebyshev I/II and Elliptic filters in MATLAB

by Forrest Sheng Bao http://fsbao.net

% Copyleft (C) Forrest Sheng Bao 1984-2009 http://fsbao.net
% with Dept. of Electrical and Computer Engineering and Dept. of Computer Science, Texas Tech University, Lubbock, Texas, USA
%
% This program shows the order and frequency/phase properties of four different kinds of filters, Butterworth, Chebyshev Type I, Chebyshev Type II and Elliptic.
% The filter is expected to have a cutoff frequency at 200 Hz with attenuation 40 db/octave. The sampling frequency is 2000 Hz.
%
% This program is a free software.
% It is licensed in GNU GENERAL PUBLIC LICENSE (GPL) v3 or later.
% So this program comes with ABSOLUTELY NO WARRANTY.
%
% You have the rights to freely COPY, MODIFY and REDISTRIBUTE this program under the terms of GNU GPL v3 or later, including KEEP the modified
% and/or redistributed code in GNU GPL v3 or later.
%
% If you do not know what GNU GPL is, please visit http://www.gnu.org/copyleft/gpl.html

close all
clear all

cutoff = 200;
Fs = 2000;
wp = cutoff/(Fs/2);
ws = 400/(Fs/2);
rp = 3;
rs = 43;
for i=1:4
if i == 1
[order, wn] = buttord(wp, ws, rp, rs);
sprintf('the min. order of Butterworth filter is %d', order)
[b,a] = butter(order,wn);
figure()
freqz(b,a,512,Fs)
title('Butterworth filter, attenuation = 40 db/octave, cutoff=200')
elseif i==2
[order, wn] = cheb1ord(wp, ws, rp, rs);
sprintf('the min. order of Chebyshev Type 1 filter is %d', order)
[b,a] = cheby1(order,rp,wn);
figure()
freqz(b,a,512,Fs)
title('Chebyshev Type I filter, attenuation = 40 db/octave, cutoff=200')
elseif i==3
[order, wn] = cheb2ord(wp, ws, rp, rs);
sprintf('the min. order of Chebyshev Type II filter is %d', order)
[b,a] = cheby2(order,rp,wn);
figure()
freqz(b,a,512,Fs)
title('Chebyshev Type II filter, attenuation = 40 db/octave, cutoff=200')
elseif i==4
[order, wn] = ellipord(wp, ws, rp, rs);
sprintf('the min. order of elliptic filter is %d', order)
[b,a] = ellip(order,rp,rs,wn);
figure()
freqz(b,a,512,Fs)
title('Elliptic filter, attenuation = 40 db/octave, cutoff=200')
else
disp('error')
end
end
ans =

the min. order of Butterworth filter is 7

ans =

the min. order of Chebyshev Type 1 filter is 4

ans =

the min. order of Chebyshev Type II filter is 4

ans =

the min. order of elliptic filter is 3

Plot images are omitted here. Please run the code to get them.

 
Copyleft and Copywrite 1984 -2008 Forrest Sheng Bao Contact me
Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.