first python code

July 8, 2011

it just strikes me odd that python’s structure depends on indentation … i started a function at a wrong place. by the time i realized and tried to move it, the code totally messed up

A new dawn

November 4, 2010

Just imported the old MSN blogs into the wordpress blog here. Lots of cleanup work waits ahead.

convert EPS to PDF with bounding box

June 3, 2010

On my Ubuntu somehow epstopdf doesn’t do job — giving me a full-paged pdf file.
This can be solved by calling
ps2pdf -EPSCrop XXX.eps

流水账

May 31, 2010
去了趟这里的walmart,又脏又破还没什么东西。 里面基本除了非裔就是拉丁裔。晃了一圈就买了一盒巧克力和一加仑牛奶。 这里的牛奶和明州的差不多,都要比宾州的便宜很多。 宾州的那些牛都是白养了。然后去了target, 感觉超级没有人气。 不知道这里的人都去哪家购物。

住的地方还好, 床很大,上面足足放了6 个枕头。 一晚上就感觉睡在枕头堆里。房间里只有电视没有书桌,这个暑假基本废了。

厨房就不评价了, 做饭肯定是没戏了。 昨天吃了个叫白城堡的快餐店,呃…… 基本就是油炸的东西,太不健康了。

再有就是打扫卫生的大妈只会说 "No English"。

two “new” features in c

March 15, 2010

Well, there are not really new at all. But still many beginners like me are totally unaware of them.

1. you can define an array with a variable length, e.g.

int i = 5; int a[i] = {0};

2.  const is also a keyword in C.

matlab question

March 15, 2010

Given  a matrix A, say

0    0    20
0    5    10
4    9     4
0    0      0

and a vector

a =[0 0 0 0]

How to determine a is 4-th row in A?

A quick matlab code looks like

find(ismember(A,a,’rows’))

Here is another solution which is harder to understand

e = A-repmat(a, [size(A, 1), 1]);
i = find(sum(e==0, 2)==size(A, 2));

grub 2

March 14, 2010

It’s pretty straightforward to upgrade from grub (legacy) to grub 2 (version 1.96) or later. Just be cautious that when running grub-pc, one needs to choose a proper device (by UP or DOWN or SPACE), even if you only have one hard drive.  Otherwise it will cause error 15 and a boot failure. I think this is very import and should draw much more attention than it does now. But somehow the grub2 developers didn’t think that way. And I am one of the woeful users who learn the error 15 the hard way. :(

The good news is that it’s not so hard to fix the boot failure. You need a live CD, chroot to your hard disk, sth. like this

$ sudo mount /dev/sda1 /mnt
$ sudo mount --bind /dev /mnt/dev
$ sudo mount --bind /proc /mnt/proc
$ sudo mount --bind /sys /mnt/sys
$ sudo chroot /mnt

And reconfigure the grub-pc.  And you get rewarded

This is one the default images in the debian repository. (grub2-splashimages), also my current splash image.

Avatar~~

December 24, 2009
年度环保大片 +  白人移民的自我救赎 + Terran PK Night Elf

感恩节聚餐 + 海报栏忽悠

December 12, 2009

Hijin 做的韩国菜很牛。


我的poster 就摆在酒水席旁边。 那天我绝对喝多了, 最后都快语无伦次了。

哇哈哈~~

November 26, 2009

刚才在 限速 60 英里 的 35W 上开 80 英里, 然后被警察拦了下来 ……

当时觉得完了感恩节要吃罚单了, 结果竟然只给了个警告, 哇哈哈~~

本来这个黑色礼拜五没有购物计划的,现在看来是没有也得有了。


Follow

Get every new post delivered to your Inbox.