Thursday, May 15, 2014

A Comparison of Least Square

Ordinary Least Square (OLS),

Consider the following linear system:



via

Monday, May 5, 2014

Debugging AppleScript: print to a file

Debugging AppleScript is easy when you work with the script editor, simply use log to print out anything in the console. However, after you compiled it to an app, this cannot work anymore.

I find there are several ways to do it in this thread. The two approaches that work best for me are:

  1. Use logger to log to the syslog. E.g.,
1  
do shell script "logger -t 'AS DEBUG' " & myObj  

However, I don't know why sometimes this is not logged. So I will use the following:

  1. Echo to file
1  2  
do shell script "echo " & quoted form of (myObj as string) & ¬      " >> ~/Desktop/as_debug.txt"  


via Zigang Xiao http://bit.ly/1nWnLGH

Friday, March 7, 2014

It's birthday again :)

What I did in this birthday:

- Got up late & made myself a Latte.
- Brainstorm a bit and did an phone interview.
- Procrastinate: read some interesting articles on Frequentist vs Bayesian, brush up some Jazz chords, watch some anime.
- Got that Federal Tax Return done!
- Had dinner & bday cake with friends.
- Practice ballroom dancing with Illini Dancesport.

It's just another normal day. But I am quite happy with that :)

Friday, August 16, 2013

资源调配不均匀

最近看《进击的巨人》,里面有个 dilemma 很引起我共鸣。背景:地球突然出现身高10+米的巨人,以人类为食,人类为了自保,修建城墙阻挡巨人。同时训练士兵,成绩好的士兵可以选择留在最安全的地方成为保护国王的宪兵,而其他则必须去进入调查兵团,即前线的士兵,随时牺牲生命。tl;dr:有能力的人明哲保身,能力弱的反而要肩负起最重要的保护人类生命的责任。

我突然觉得跟我在现实生活的一些想法很有共鸣。我身边一些我觉得很有聪明才智的人,没有选择在学术道路上,而是选择安逸的生活;而像我有兴趣在科学道路上有所建树,却总是为自己没有他们的智商而着急。从资源调配角度来说,真是离最优解恰好相反。

这个问题其实跟在 quora 上的一个问题也有点类似。top answer 的大意是,Google 优越的条件吸引了世界上最聪明的一群人,然则大多数人在 google 其实 overqualified,因为 challenging 的东西总是已经被做完,或者说做决策的只能是高层更聪明的人。

当然我本意不是埋怨别人不好好利用它们的聪明才智,每个人都有做出自己选择的权利。我仅仅,只是在着急搞研究进展缓慢,觊觎别人的能力而已...

Thursday, August 1, 2013

关于 stty, erase, ^H, ^?

引用这位同学的问题,之前自己经常遇到但是没有好好总结。

表现就是,在 terminal 里面,backspace 经常会出现问题,偶尔会看到 ^? 或 ^H 这种东西的出现。

由于历史原因 (追溯到打卡机时代),要删除一个字符,必须先 ASCII BS (0x08, ^H) 回到前一个字母,然后再 ASCII DEL (0x7F, ^?) 删除它。

现代电脑里,backspace 的作用基本上就相当于上述 BS+DEL的功能,而delete真正发送的是"^[[3"。而事实上 backspace 究竟定义为 ^H 还是 ^? 只是一个个人的选择,并且没有标准,所以不同的 terminal emulator 可能会采用不同的值。

我们知道可以用不同的 terminal (emulator) login 到一个机器上。但是不同 terminal 有不同的 key mapping,具体来说,它们 backspace 发送的值可能 *不一样*. 比如 linux console 是模拟 vt220 的,backspace 发送的是 DEL,而 xterm 模拟 vt100,backspace 发送的是 BS。

而 stty 是用来控制 terminal options 的。简单来说,是控制 terminal 怎么理解输入的字符串的。如果 backspace 发送的值与 stty 的设置定义不一样,那么就可能出现问题,最常见的,就是 stty 里 erase (向前删除一个字符) 设置为 ^? 而 backspace 发送的是 ^H. 这时解决方法是:

1. 设置 stty 理解 ^H 为 erase: stty erase ^H,或者
2. 设置 terminal emulator, 使得 backspace 发送 ^? 而不是 ^H。


历史与详细解决方法:http://www.ibb.net/~anne/keyboard.html