转载《读《思旧赋》》

《思旧赋》是魏晋时期向秀所作，大家可以轻易在网上找到，就不抄了。大概是向秀到京城去做官的途中，专门到曾经和好友嵇康一起喝酒吹牛的地方去看了一看。嵇康在14年前已经被杀，而眼前的景色依旧，听到一个人在吹笛，仿佛是嵇康的琴声，不由思绪万千，就此写下这一名篇。

Hardware hack and supply chain security

Bloomberg just made big news.

In its recent issue, it featured a cover story: “The Big Hack: How China Used a Tiny Chip to Infiltrate U.S. Companies“, detailed how Chinese military planted malicious chips into motherboards manufactured by Taiwanese supplier, supplying motherboards to a major server provider whose servers were used by almost 30 US companies, including Amazon and Apple. And by  doing this, Chinese military gains potential access to these companies and even US military.

Here’s the malicious chip on the motherboard:

Here’s a illustration of that process directly from their website:

You don’t have to be a genius to know how big this is, in many ways.

Technically, this is very advanced. Just compare to what the NSA was found doing back in 2014:

I mean, what the NSA has done can be accomplished by just any organization with a team of security experts. What the Bloomberg described, needs collaboration of experts from different areas spanning different industries. It needs state level sponsorship. The only thing that comes comparable, is the Stuxnet.

But even Stuxnet pales in comparison in terms of long term impact. When Stuxnet was made public in 2010, it has already done its tasks. There were a lot of speculation before US and Israeli officials “half confirmed” its origin, but ultimately, its impact is largely limited to technology world.

The hack described in Bloomberg’s article on the other hand, will help re-shape the global supply chain in the years to come. It would be naive to think this is pure coincident that this hack was published almost the same time when Mike Pence spoke at the Hudson Institution.

Despite its length, the article actually doesn’t describe the hacking in detail. The chip in its cover photo (shown below) was dismissed by experts as a very cheap passive component, “not possible to do anything remotely related to hacking”.

The way the chip supposed to work is also vague. From the article, it seems the chip may hijack the code verification process to bypass some security check. But it is unclear whether it was the IPMI code verification or the UEFI code verification or both.

As of this writing, both Apple and Amazon have denied the claim the hack claim. However, the shell has been dropped and the storm is still brewing. Because despite all these refusals, it successfully made people believe that this kind of hack is possible, and it is only possible in mainland China. The seed has been planted. How lucky we are, to witness such historical drama unfolding before our eyes.

Call for smart asses

Some of you may have seen this video, since it has been around for several years:

(For those you feel so compelled to up-vote this video, sorry I don’t have such a button on my blog, but you are welcome to go to YouTube and search for “Short Comedy Sketch” and express your sympathy there. :))

After being exposed to it several times, I started to think, well, maybe, just maybe, it is not entirely, ridiculously impossible? So after some sketching, I came up with something like this:

It’s just a re-interpretation of what the business people are saying.

• When they say 7 lines perpendicular to each other, they probably mean some lines are perpendicular to others;
• When they say draw red lines with transparent ink, they probably mean red line with some transparency;
• When they say draw red lines with green ink, they probably mean green ink overlaying red lines;

I proudly showed this to some friends and was called (not surprisingly) a smart ass. But that didn’t stop me from showing this in lectures and explaining to the audience how you can manage conflicting requirements – make sense out of it.

But then, today, I just found a even better solution to this seemingly impossible requirement:

[YouTube link here: https://www.youtube.com/watch?v=xNWt0VuMbHA]

This solution is way better than mine in 2 aspects:

• It actually draws red lines with blue ink;
• All 7 lines are perpendicular to each other;

It is still not perfect, but it makes me think, maybe there are even better solutions? Smart asses out there, wanna try it out?

The sum of all natural numbers…

The notion of 1+2+3+4+…=-1/12 has become so wide spread that quite a few of my friends actually feel convinced that it’s actually a true statement in general, even though it is very counter intuitive.

The point is, in order to evaluate an expression, that expression has to be well-defined.

Expressions like a+b is well defined in the sense that we know it is a binary operation, we know what are we supposed to do to get the result.

Expressions like a+b+c+… is not well defined, because there are multiple operators involved, and the order of evaluation is not clearly specified.

Take the sum of the alternating series as an example:

《形而上学》亚里士多德

2.1 埃及乘法

$$1a=a$$                                   （2.1）

$$(n+1)a=na+a$$                 （2.2）

int multiply0(int n, int a){
if (n==1) return a;
return multiply0(n-1, a)+a;
}

Ahmes所描述的算法，这个算法在古希腊被称为“埃及乘法”，而很多现代作者则称之为“俄罗斯农民算法”，建立在如下洞察上：

$$4a=((a+a)+a)+a=(a+a)+(a+a)$$

$$a+(b+c)=(a+b)+c$$

1        ♦         59
2                  118
4                  236
8        ♦        472
16                944
32      ♦      1888

$$41*59=(1*59)+(8*59)+(32*59)$$

$$n=n/2+n/2$$    说明n是偶数
$$n=(n-1)/2+(n-1)/2+1$$  说明n是奇数

odd(n) 意味着 half(n)=half(n-1)

int multiply1(int n, int a){
if (n==1) return a;
int result=multiply1(half(n), a+a);
if (odd(n)) result=result +a;
return result;
}

odd(x)很容易实现，测试x的最低位就可以了，half(x)则可以通过对x进行一次右移实现：

bool odd(int n) { return n&0x1;}
int half(int n) { return n>>1; }

multiply1需要进行多少次加法运算？每次调用这个函数，我们需要在a+a的地方进行一次加法，因为我们是不断对n取半，我们需要调用这个函数logn次。在某些时候，我们还需要在result+a的地方进行加法运算，因此加法运算的总次数为：

$$\#(n)=logn + v(n)-1$$

$$\#(15)=3+4-1=6$$

int multiply_by_15(int a){
int b=(a+a)+a;    //b == 3*a
int c+b+b;        //c == 6*a
return (c+c)+b;   //12*a + 3*a
}

2.2 改进算法

r+na

int mult_acc0{int r, int n, int a) {
if (n==1) return r+a;
if (odd(n)){
return mult_acc0(r+a, half(n), a+a);
}else{
return mult_acc0(r, half(n), a+a);
}
}

int mult_acc1(int r, int n, int a) {
if (n==1) return r+a;
if (odd(n)) r=r+a;
return mult_acc1(r, half(n), a+a);
}

• n=1的情况很少发生；
• 如果n是偶数，则完全没有必要判断它还是不是1.

int mult_acc2(int r, int n, int a) {
if (odd(n)) {
r=r+a;
if (n==1) return r;
}
return mult_acc2(r, half(n), a+a);
}

int mult_acc3 (int r, int n, int a) {
if (odd(n)) {
r=r+a;
if (n==1) return r;
}
n=half(n);
a=a+a;
return mult_acc3(r,n,a);
}

int mult_acc4(int r, int n, int a) {
while (true) {
if (odd(n)) {
r=r+a;
if (n==1) return r;
}
n=half(n);
a=a+a;
}
}

int multiply2(int n, int a) {
if (n==1) return a;
return mult_acc4(a, n-1, a);
}

int multiply3(int n, int a) {
while (!odd(n)) {
a=a+a;
n=half(n);
}
if (n==1) return a;
return mult_acc4(a, n-1, a);
}

int multiply4(int n, int a) {
while (!odd(n)) {
a=a+a;
n=half(n);
}
if (n==1) return n;
return mult_acc4(a, half(n-1), a+a);
}

2.3 本章的思考

Writing Pix4D compatible tags into pictures

If you’re looking for a method to write camera pose information into JPG files so that it can be read by Pix4D, as shown in the below screenshot:

Here is how to do it with exiftool:

• First, you need a configuration file for exiftool. In the configuration file, you need the following content:
%Image::ExifTool::UserDefined = (
'Image::ExifTool::XMP::Main' => {
Camera=> {
SubDirectory => {
TagTable => 'Image::ExifTool::UserDefined::Camera',
},
},
},
);
%Image::ExifTool::UserDefined::Camera = (
GROUPS => { 0 => 'XMP', 1 => 'XMP-Camera', 2 => 'Other' },
NAMESPACE => { 'Camera' => 'http://ns.flyingfishtechs.com/Camera/1.0/' },
WRITABLE => 'string',
GPSXYAccuracy=> {},
GPSZAccuracy => {},
Pitch => {},
Roll=>{},
Yaw => {},
);
• Then you can using exiftool to add the information to any JPG file.
exiftool.exe -config config.min.cfg -Pitch="1.02" -Roll="2.03" -Pitch="3.04" original.jpg

If the command outputs: 1 image files updated. Then you’re done. Now the JPG file has the camera pose information encoded in. If you have more than 3 such pictures (only because Pix4D needs at least 3 pictures to work), you can see that Pix4D can get the data from the pictures.

The final twist, Pix4D displays Omega, Phi and Kappa instead of Pitch, Roll and Yaw. Basically, Pitch, Roll and Yaw are angles relative to the horizontal plane – orthogonal to the gravity while Omega, Phi and Kappa are related to earth. That means, with a fixed set of Pitch, Roll and Yaw, if you change your GPS location, you’ll get a different set Omega, Phi and Kappa. Personally I don’t see why should Pix4D use earth as the frame of reference instead of horizontal plane. Maybe just to hide the raw information in the pictures. Anyway, know you know how.

To My Dear Fellow Misfits

So I know TED is about a lot of things that are big, but I want to talk to you about something very small. So small, it’s a single word. The word is “misfit.” It’s one of my favorite words, because it’s so literal. I mean, it’s a person who sort of missed fitting in. Or a person who fits in badly. Or this: “a person who is poorly adapted to new situations and environments.” I’m a card-carrying misfit. And I’m here for the other misfits in the room, because I’m never the only one. I’m going to tell you a misfit story.

0:54 Somewhere in my early 30s, the dream of becoming a writer came right to my doorstep. Actually, it came to my mailbox in the form of a letter that said I’d won a giant literary prize for a short story I had written. The short story was about my life as a competitive swimmer and about my crappy home life, and a little bit about how grief and loss can make you insane. The prize was a trip to New York City to meet big-time editors and agents and other authors. So kind of it was the wannabe writer’s dream, right? You know what I did the day the letter came to my house? Because I’m me, I put the letter on my kitchen table, I poured myself a giant glass of vodka with ice and lime, and I sat there in my underwear for an entire day, just staring at the letter. I was thinking about all the ways I’d already screwed my life up. Who the hell was I to go to New York City and pretend to be a writer? Who was I?

2:06 I’ll tell you. I was a misfit. Like legions of other children, I came from an abusive household that I narrowly escaped with my life. I already had two epically failed marriages underneath my belt. I’d flunked out of college not once but twice and maybe even a third time that I’m not going to tell you about.

2:29 (Laughter)

2:31 And I’d done an episode of rehab for drug use. And I’d had two lovely staycations in jail. So I’m on the right stage.

2:44 (Laughter)

2:47 But the real reason, I think, I was a misfit, is that my daughter died the day she was born, and I hadn’t figured out how to live with that story yet. After my daughter died I also spent a long time homeless, living under an overpass in a kind of profound state of zombie grief and loss that some of us encounter along the way. Maybe all of us, if you live long enough. You know, homeless people are some of our most heroic misfits, because they start out as us. So you see, I’d missed fitting in to just about every category out there: daughter, wife, mother, scholar. And the dream of being a writer was really kind of like a small, sad stone in my throat.

3:45 It was pretty much in spite of myself that I got on that plane and flew to New York City, where the writers are. Fellow misfits, I can almost see your heads glowing. I can pick you out of a room. At first, you would’ve loved it. You got to choose the three famous writers you wanted to meet, and these guys went and found them for you. You got set up at the Gramercy Park Hotel, where you got to drink Scotch late in the night with cool, smart, swank people. And you got to pretend you were cool and smart and swank, too. And you got to meet a bunch of editors and authors and agents at very, very fancy lunches and dinners. Ask me how fancy.

4:30 Audience: How fancy?

4:33 Lidia Yuknavitch: I’m making a confession: I stole three linen napkins —

4:37 (Laughter)

（笑声）

4:39 from three different restaurants. And I shoved a menu down my pants.

4:43 (Laughter)

（笑声）

4:45 I just wanted some keepsakes so that when I got home, I could believe it had really happened to me. You know?

4:54 The three writers I wanted to meet were Carole Maso, Lynne Tillman and Peggy Phelan. These were not famous, best-selling authors, but to me, they were women-writer titans. Carole Maso wrote the book that later became my art bible. Lynne Tillman gave me permission to believe that there was a chance my stories could be part of the world. And Peggy Phelan reminded me that maybe my brains could be more important than my boobs. They weren’t mainstream women writers, but they were cutting a path through the mainstream with their body stories, I like to think, kind of the way water cut the Grand Canyon.

5:40 It nearly killed me with joy to hang out with these three over-50-year-old women writers. And the reason it nearly killed me with joy is that I’d never known a joy like that. I’d never been in a room like that. My mother never went to college. And my creative career to that point was a sort of small, sad, stillborn thing. So kind of in those first nights in New York I wanted to die there. I was just like, “Kill me now. I’m good. This is beautiful.” Some of you in the room will understand what happened next.

6:15 First, they took me to the offices of Farrar, Straus and Giroux. Farrar, Straus and Giroux was like my mega-dream press. I mean, T.S. Eliot and Flannery O’Connor were published there. The main editor guy sat me down and talked to me for a long time, trying to convince me I had a book in me about my life as a swimmer. You know, like a memoir. The whole time he was talking to me, I sat there smiling and nodding like a numb idiot, with my arms crossed over my chest, while nothing, nothing, nothing came out of my throat. So in the end, he patted me on the shoulder like a swim coach might. And he wished me luck and he gave me some free books and he showed me out the door.

7:08 Next, they took me to the offices of W.W. Norton, where I was pretty sure I’d be escorted from the building just for wearing Doc Martens. But that didn’t happen. Being at the Norton offices felt like reaching up into the night sky and touching the moon while the stars stitched your name across the cosmos. I mean, that’s how big a deal it was to me. You get it? Their lead editor, Carol Houck Smith, leaned over right in my face with these beady, bright, fierce eyes and said, “Well, send me something then, immediately!” See, now most people, especially TED people, would have run to the mailbox, right? It took me over a decade to even imagine putting something in an envelope and licking a stamp.

7:59 On the last night, I gave a big reading at the National Poetry Club. And at the end of the reading, Katharine Kidde of Kidde, Hoyt & Picard Literary Agency, walked straight up to me and shook my hand and offered me representation, like, on the spot. I stood there and I kind of went deaf. Has this ever happened to you? And I almost started crying because all the people in the room were dressed so beautifully, and all that came out of my mouth was: “I don’t know. I have to think about it.” And she said, “OK, then,” and walked away. All those open hands out to me, that small, sad stone in my throat …

8:50 You see, I’m trying to tell you something about people like me. Misfit people — we don’t always know how to hope or say yes or choose the big thing, even when it’s right in front of us. It’s a shame we carry. It’s the shame of wanting something good. It’s the shame of feeling something good. It’s the shame of not really believing we deserve to be in the room with the people we admire.

9:15 If I could, I’d go back and I’d coach myself. I’d be exactly like those over-50-year-old women who helped me. I’d teach myself how to want things, how to stand up, how to ask for them. I’d say, “You! Yeah, you! You belong in the room, too.” The radiance falls on all of us, and we are nothing without each other. Instead, I flew back to Oregon, and as I watched the evergreens and rain come back into view, I just drank many tiny bottles of airplane “feel sorry for yourself.” I thought about how, if I was a writer, I was some kind of misfit writer. What I’m saying is, I flew back to Oregon without a book deal, without an agent, and with only a headful and heart-ful of memories of having sat so near the beautiful writers. Memory was the only prize I allowed myself.

10:16 And yet, at home in the dark, back in my underwear, I could still hear their voices. They said, “Don’t listen to anyone who tries to get you to shut up or change your story.” They said, “Give voice to the story only you know how to tell.” They said, “Sometimes telling the story is the thing that saves your life.”

10:42 Now I am, as you can see, the woman over 50. And I’m a writer. And I’m a mother. And I became a teacher. Guess who my favorite students are. Although it didn’t happen the day that dream letter came through my mailbox, I did write a memoir, called “The Chronology of Water.” In it are the stories of how many times I’ve had to reinvent a self from the ruins of my choices, the stories of how my seeming failures were really just weird-ass portals to something beautiful. All I had to do was give voice to the story.

11:26 There’s a myth in most cultures about following your dreams. It’s called the hero’s journey. But I prefer a different myth, that’s slightly to the side of that or underneath it. It’s called the misfit’s myth. And it goes like this: even at the moment of your failure, right then, you are beautiful. You don’t know it yet, but you have the ability to reinvent yourself endlessly. That’s your beauty.

11:58 You can be a drunk, you can be a survivor of abuse, you can be an ex-con, you can be a homeless person, you can lose all your money or your job or your husband or your wife, or the worst thing of all, a child. You can even lose your marbles. You can be standing dead center in the middle of your failure and still, I’m only here to tell you, you are so beautiful. Your story deserves to be heard, because you, you rare and phenomenal misfit, you new species, are the only one in the room who can tell the story the way only you would. And I’d be listening.

12:43 Thank you.

12:45 (Applause)