Month: October 2011

[Libsvm]libsvm for matlab compilation error on mac

Error:

>> make
/bin/bash: -c: line 0: unexpected EOF while looking for matching `"'
/bin/bash: -c: line 1: syntax error: unexpected end of file
??? Error using ==> mex at 208
Unable to complete successfully.

Error in ==> make at 5
mex -O -largeArrayDims -I..\ -c ..\svm.cpp

Fix:

  1. Under folder ./libsvm-3.1/matlab
  2. Open file make.m
  3. replace backslash(\) to slash(/)
  4. save and close file
  5. execute the make command inside matlab


Error:

>> make
i686-apple-darwin10-gcc-4.2.1: svm.obj: No such file or directory
i686-apple-darwin10-gcc-4.2.1: svm_model_matlab.obj: No such file or directory

    mex: link of ' "svmtrain.mexmaci64"' failed.

??? Error using ==> mex at 208
Unable to complete successfully.

Error in ==> make at 7
mex -O -largeArrayDims -I../ svmtrain.c svm.obj svm_model_matlab.obj

Fix:

  1. Open the make.m file again
  2. Replace all the occurrences of .obj to .o
  3. Save and close
  4. Try again!

Hope these help :]

NSURL

码农Coding的时候有各种不好的习惯。
比如,不喜欢好好地看框架的文档,一旦找到某一个看起来简单易懂的接口,就一直用它。
如果需要之后的处理,往往简单粗暴。
我们以前管这种情况叫做“裸”。最近又不知不觉地写了比较“裸”的代码。
说实话,这个习惯得改,“裸”写的东西往往不健壮,不可读,效率还不高。成熟框架提供的直接可用的接口必须是第一选择。

NSURL是常用的类,用来描述一段URL的。
需要取得URL中不同部分的时候,我们应该用URL提供的接口,
而不是把它当做一个普通的字符串去手工分析。

比如:
http://www.testurl.com:8080/subpath/subsubpath?uid=123&gid=456

NSURL *url = [NSURL URLWithString:@"http://www.testurl.com:8080/subpath/subsubpath?uid=123&gid=456"];

下面是常用的几个接口,和它们的输出。接口意思都符合相关RFC里的定义。

[url scheme]
http

[url host]
www.testurl.com

[url port]
8080

[url path]
/subpath/subsubpath

[url lastPathComponent]
subsubpath

[url query]
uid=123&gid=456


NSURL 英文版 :]


NSURL is widely used, but sometimes we are not following the idiomatic usage.

When it comes to access part of the url, it is better to use the methods NSURL provide, instead of analysis its absoluteString manually.

Take this one for example:

http://www.testurl.com:8080/subpath/subsubpath?uid=123&gid=456

NSURL *url = [NSURL URLWithString:@"http://www.testurl.com:8080/subpath/subsubpath?uid=123&gid=456"];

Here listed some frequently-used accessors and results:

[url scheme]
http

[url host]
www.testurl.com

[url port]
8080

[url path]
/subpath/subsubpath

[url lastPathComponent]
subsubpath

[url query]
uid=123&gid=456