My immigration story

How can I speak in 10 minutes about the bonds of women over three generations, about how the astonishing strength of those bonds took hold in the life of a four-year-old girl huddled with her young sister, her mother and her grandmother for five days and nights in a small boat in the China Sea more than 30 years ago. Bonds that took hold in the life of that small girl and never let go — that small girl now living in San Francisco and speaking to you today. This is not a finished story. It is a jigsaw puzzle still being put together. Let me tell you about some of the pieces.

Imagine the first piece: a man burning his life’s work. He is a poet, a playwright, a man whose whole life had been balanced on the single hope of his country’s unity and freedom. Imagine him as the communists enter Saigon — confronting the fact that his life had been a complete waste. Words, for so long his friends, now mocked him. He retreated into silence. He died broken by history. He is my grandfather. I never knew him in real life. But our lives are much more than our memories. My grandmother never let me forget his life. My duty was not to allow it to have been in vain, and my lesson was to learn that, yes, history tried to crush us, but we endured.

The next piece of the jigsaw is of a boat in the early dawn slipping silently out to sea. My mother, Mai, was 18 when her father died — already in an arranged marriage, already with two small girls. For her, life had distilled itself into one task: the escape of her family and a new life in Australia. It was inconceivable to her that she would not succeed. So after a four-year saga that defies fiction, a boat slipped out to sea disguised as a fishing vessel. All the adults knew the risks. The greatest fear was of pirates, rape and death. Like most adults on the boat, my mother carried a small bottle of poison. If we were captured, first my sister and I, then she and my grandmother would drink.

My first memories are from the boat — the steady beat of the engine, the bow dipping into each wave, the vast and empty horizon. I don’t remember the pirates who came many times, but were bluffed by the bravado of the men on our boat, or the engine dying and failing to start for six hours. But I do remember the lights on the oil rig off the Malaysian coast and the young man who collapsed and died, the journey’s end too much for him, and the first apple I tasted, given to me by the men on the rig. No apple has ever tasted the same.

After three months in a refugee camp, we landed in Melbourne. And the next piece of the jigsaw is about four women across three generations shaping a new life together. We settled in Footscray, a working-class suburb whose demographic is layers of immigrants. Unlike the settled middle-class suburbs, whose existence I was oblivious of, there was no sense of entitlement in Footscray. The smells from shop doors were from the rest of the world. And the snippets of halting English were exchanged between people who had one thing in common: They were starting again.

My mother worked on farms, then on a car assembly line, working six days, double shifts. Somehow, she found time to study English and gain IT qualifications. We were poor. All the dollars were allocated and extra tuition in English and mathematics was budgeted for regardless of what missed out, which was usually new clothes; they were always secondhand. Two pairs of stockings for school, each to hide the holes in the other. A school uniform down to the ankles, because it had to last for six years. And there were rare but searing chants of “slit-eye” and the occasional graffiti: “Asian, go home.” Go home to where? Something stiffened inside me. There was a gathering of resolve and a quiet voice saying, “I will bypass you.”

My mother, my sister and I slept in the same bed. My mother was exhausted each night, but we told one another about our day and listened to the movements of my grandmother around the house. My mother suffered from nightmares, all about the boat. And my job was to stay awake until her nightmares came so I could wake her. She opened a computer store, then studied to be a beautician and opened another business. And the women came with their stories about men who could not make the transition, angry and inflexible, and troubled children caught between two worlds.

Grants and sponsors were sought. Centers were established. I lived in parallel worlds. In one, I was the classic Asian student, relentless in the demands that I made on myself. In the other, I was enmeshed in lives that were precarious, tragically scarred by violence, drug abuse and isolation. But so many over the years were helped. And for that work, when I was a final-year law student, I was chosen as the Young Australian of the Year. And I was catapulted from one piece of the jigsaw to another, and their edges didn’t fit.

Tan Le, anonymous Footscray resident, was now Tan Le, refugee and social activist, invited to speak in venues she had never heard of and into homes whose existence she could never have imagined. I didn’t know the protocols. I didn’t know how to use the cutlery. I didn’t know how to talk about wine. I didn’t know how to talk about anything. I wanted to retreat to the routines and comfort of life in an unsung suburb — a grandmother, a mother and two daughters ending each day as they had for almost 20 years, telling one another the story of their day and falling asleep, the three of us still in the same bed. I told my mother I couldn’t do it. She reminded me that I was now the same age she had been when we boarded the boat. “No” had never been an option. “Just do it,” she said, “and don’t be what you’re not.”

So I spoke out on youth unemployment and education and the neglect of the marginalized and disenfranchised. And the more candidly I spoke, the more I was asked to speak. I met people from all walks of life, so many of them doing the thing they loved, living on the frontiers of possibility. And even though I finished my degree, I realized I could not settle into a career in law. There had to be another piece of the jigsaw. And I realized, at the same time, that it is OK to be an outsider, a recent arrival, new on the scene — and not just OK, but something to be thankful for, perhaps a gift from the boat. Because being an insider can so easily mean collapsing the horizons, can so easily mean accepting the presumptions of your province. I have stepped outside my comfort zone enough now to know that, yes, the world does fall apart, but not in the way that you fear.

Possibilities that would not have been allowed were outrageously encouraged. There was an energy there, an implacable optimism, a strange mixture of humility and daring. So I followed my hunches. I gathered around me a small team of people for whom the label “It can’t be done” was an irresistible challenge. For a year, we were penniless. At the end of each day, I made a huge pot of soup which we all shared. We worked well into each night. Most of our ideas were crazy, but a few were brilliant, and we broke through. I made the decision to move to the US after only one trip. My hunches again. Three months later, I had relocated, and the adventure has continued.

Before I close, though, let me tell you about my grandmother. She grew up at a time when Confucianism was the social norm and the local mandarin was the person who mattered. Life hadn’t changed for centuries. Her father died soon after she was born. Her mother raised her alone. At 17, she became the second wife of a mandarin whose mother beat her. With no support from her husband, she caused a sensation by taking him to court and prosecuting her own case, and a far greater sensation when she won.

(Laughter)

(Applause)

“It can’t be done” was shown to be wrong.

I was taking a shower in a hotel room in Sydney the moment she died, 600 miles away, in Melbourne. I looked through the shower screen and saw her standing on the other side. I knew she had come to say goodbye. My mother phoned minutes later. A few days later, we went to a Buddhist temple in Footscray and sat around her casket. We told her stories and assured her that we were still with her. At midnight, the monk came and told us he had to close the casket. My mother asked us to feel her hand. She asked the monk, “Why is it that her hand is so warm and the rest of her is so cold?” “Because you have been holding it since this morning,” he said. “You have not let it go.”

If there is a sinew in our family, it runs through the women. Given who we were and how life had shaped us, we can now see that the men that might have come into our lives would have thwarted us. Defeat would have come too easily. Now I would like to have my own children, and I wonder about the boat. Who could ever wish it on their own? Yet I am afraid of privilege, of ease, of entitlement. Can I give them a bow in their lives, dipping bravely into each wave, the unperturbed and steady beat of the engine, the vast horizon that guarantees nothing? I don’t know. But if I could give it and still see them safely through, I would.

(Applause)

Trevor Neilson: And also, Tan’s mother is here today, in the fourth or fifth row.

(Applause)

Posted in TED 演讲 | My immigration story已关闭评论

The family I lost in North Korea. And the family I gained.

I was born and raised in North Korea. Although my family constantly struggled against poverty, I was always loved and cared for first, because I was the only son and the youngest of two in the family.

But then the great famine began in 1994. I was four years old. My sister and I would go searching for firewood starting at 5 in the morning and come back after midnight. I would wander the streets searching for food, and I remember seeing a small child tied to a mother’s back eating chips, and wanting to steal them from him.

Hunger is humiliation. Hunger is hopelessness. For a hungry child, politics and freedom are not even thought of. On my ninth birthday, my parents couldn’t give me any food to eat. But even as a child, I could feel the heaviness in their hearts.

Over a million North Koreans died of starvation in that time, and in 2003, when I was 13 years old, my father became one of them. I saw my father wither away and die. In the same year, my mother disappeared one day, and then my sister told me that she was going to China to earn money, but that she would return with money and food soon. Since we had never been separated, and I thought we would be together forever, I didn’t even give her a hug when she left. It was the biggest mistake I have ever made in my life. But again, I didn’t know it was going to be a long goodbye. I have not seen my mom or my sister since then.

Suddenly, I became an orphan and homeless. My daily life became very hard, but very simple. My goal was to find a dusty piece of bread in the trash. But that is no way to survive. I started to realize, begging would not be the solution. So I started to steal from food carts in illegal markets. Sometimes, I found small jobs in exchange for food. Once, I even spent two months in the winter working in a coal mine, 33 meters underground without any protection for up to 16 hours a day. I was not uncommon. Many other orphans survived this way, or worse.

When I could not fall asleep from bitter cold or hunger pains, I hoped that, the next morning, my sister would come back to wake me up with my favorite food. That hope kept me alive. I don’t mean big, grand hope. I mean the kind of hope that made me believe that the next trash can had bread, even though it usually didn’t. But if I didn’t believe it, I wouldn’t even try, and then I would die. Hope kept me alive. Every day, I told myself, no matter how hard things got, still I must live.

After three years of waiting for my sister’s return, I decided to go to China to look for her myself. I realized I couldn’t survive much longer this way. I knew the journey would be risky, but I would be risking my life either way. I could die of starvation like my father in North Korea, or at least I could try for a better life by escaping to China.

I had learned that many people tried to cross the border to China in the nighttime to avoid being seen. North Korean border guards often shoot and kill people trying to cross the border without permission. Chinese soldiers will catch and send back North Koreans, where they face severe punishment. I decided to cross during the day, first because I was still a kid and scared of the dark, second because I knew I was already taking a risk, and since not many people tried to cross during the day, I thought I might be able to cross without being seen by anyone.

I made it to China on February 15, 2006. I was 16 years old. I thought things in China would be easier, since there was more food. I thought more people would help me. But it was harder than living in North Korea, because I was not free. I was always worried about being caught and sent back.

By a miracle, some months later, I met someone who was running an underground shelter for North Koreans, and was allowed to live there and eat regular meals for the first time in many years. Later that year, an activist helped me escape China and go to the United States as a refugee.

I went to America without knowing a word of English, yet my social worker told me that I had to go to high school. Even in North Korea, I was an F student. (Laughter) And I barely finished elementary school. And I remember I fought in school more than once a day. Textbooks and the library were not my playground. My father tried very hard to motivate me into studying, but it didn’t work. At one point, my father gave up on me. He said, “You’re not my son anymore.” I was only 11 or 12, but it hurt me deeply. But nevertheless, my level of motivation still didn’t change before he died. So in America, it was kind of ridiculous that they said I should go to high school. I didn’t even go to middle school. I decided to go, just because they told me to, without trying much.

But one day, I came home and my foster mother had made chicken wings for dinner. And during dinner, I wanted to have one more wing, but I realized there were not enough for everyone, so I decided against it. When I looked down at my plate, I saw the last chicken wing, that my foster father had given me his. I was so happy. I looked at him sitting next to me. He just looked back at me very warmly, but said no words. Suddenly I remembered my biological father. My foster father’s small act of love reminded me of my father, who would love to share his food with me when he was hungry, even if he was starving. I felt so suffocated that I had so much food in America, yet my father died of starvation. My only wish that night was to cook a meal for him, and that night I also thought of what else I could do to honor him. And my answer was to promise to myself that I would study hard and get the best education in America to honor his sacrifice.

I took school seriously, and for the first time ever in my life, I received an academic award for excellence, and made dean’s list from the first semester in high school.

(Applause)

That chicken wing changed my life. (Laughter)

Hope is personal. Hope is something that no one can give to you. You have to choose to believe in hope. You have to make it yourself. In North Korea, I made it myself. Hope brought me to America. But in America, I didn’t know what to do, because I had this overwhelming freedom. My foster father at that dinner gave me a direction, and he motivated me and gave me a purpose to live in America.

I did not come here by myself. I had hope, but hope by itself is not enough. Many people helped me along the way to get here. North Koreans are fighting hard to survive. They have to force themselves to survive, have hope to survive, but they cannot make it without help.

This is my message to you. Have hope for yourself, but also help each other. Life can be hard for everyone, wherever you live. My foster father didn’t intend to change my life. In the same way, you may also change someone’s life with even the smallest act of love. A piece of bread can satisfy your hunger, and having the hope will bring you bread to keep you alive. But I confidently believe that your act of love and caring can also save another Joseph’s life and change thousands of other Josephs who are still having hope to survive.

Thank you.

(Applause)

Adrian Hong: Joseph, thank you for sharing that very personal and special story with us. I know you haven’t seen your sister for, you said, it was almost exactly a decade, and in the off chance that she may be able to see this, we wanted to give you an opportunity to send her a message.

Joseph Kim: In Korean?

AH: You can do English, then Korean as well.

(Laughter)

JK: Okay, I’m not going to make it any longer in Korean because I don’t think I can make it without tearing up.

Nuna, it has been already 10 years that I haven’t seen you. I just wanted to say that I miss you, and I love you, and please come back to me and stay alive. And I — oh, gosh. I still haven’t given up my hope to see you. I will live my life happily and study hard until I see you, and I promise I will not cry again. (Laughter) Yes, I’m just looking forward to seeing you, and if you can’t find me, I will also look for you, and I hope to see you one day. And can I also make a small message to my mom?

AH: Sure, please.

JK: I haven’t spent much time with you, but I know that you still love me, and you probably still pray for me and think about me. I just wanted to say thank you for letting me be in this world. Thank you.

Posted in TED 演讲 | The family I lost in North Korea. And the family I gained.已关闭评论

Your fingerprints reveal more than you think

Do you ever stop and think, during a romantic dinner, “I’ve just left my fingerprints all over my wine glass.”

00:20
(Laughter)

00:21
Or do you ever worry, when you visit a friend, about leaving a little piece of you behind on every surface that you touch? And even this evening, have you paid any attention to sit without touching anything? Well, you’re not alone. Thankfully, criminals underestimate the power of fingerprints, too. And I’m not just talking about the twisted parting of lines that make our fingerprint unique. I’m talking about an entire world of information hiding in a small, often invisible thing. In fact, fingerprints are made up of molecules that belong to three classes: sweat molecules that we all produce in very different amounts … molecules that we introduce into our body and then we sweat out and molecules that we may contaminate our fingertips with when we come across substances like blood, paint, grease, but also invisible substances. And molecules are the storytellers of who we are and what we’ve been up to. We just need to have the right technology to make them talk.

01:34
So let me take you on a journey of unthinkable capabilities. Katie has been raped and her lifeless body has been found in the woods three days later, after her disappearance. The police is targeting three suspects, having narrowed down the search from over 20 men who had been seen in that area on the same day. The only piece of evidence is two very faint, overlapping fingerprints on the tape that was found wrapped around Katie’s neck. Often, faint and overlapping fingerprints cannot help the police to make an identification. And until recently, this might have been the end of the road, but this is where we can make the difference.

02:29
The tape is sent to our labs, where we’re asked to use our cutting-edge technology to help with the investigation. And here, we use an existing form of mass spectrometry imaging technology that we have further developed and adapted specifically for the molecular and imaging analysis of fingerprints. In essence, we fire a UV laser at the print, and we cause the desorption of the molecules from the print, ready to be captured by the mass spectrometer. Mass spectrometry measures the weight of the molecules — or as we say, the mass — and those numbers that you see there, they indicate that mass. But more crucially, they indicate who those molecules are — whether I’m seeing paracetamol or something more sinister, forensically speaking.

03:28
We applied this technology to the evidence that we have and we found the presence of condom lubricants. In fact, we’ve developed protocols that enable us to even suggest what brand of condom might have been used. So we pass this information to the police, who, meanwhile, have obtained a search warrant and they found the same brand of condom in Dalton’s premises. And with Dalton and Thomson also having records for sexual assaults, then it is Chapman that may become the less likely suspect. But is this information enough to make an arrest? Of course not, and we are asked to delve deeper with our investigation.

04:16
So we found out, also, the presence of other two very interesting molecules. One is an antidepressant, and one is a very special molecule. It only forms in your body if you drink alcohol and consume cocaine at the same time. And alcohol is known to potentiate the effects of cocaine, so here, we now have a hint on the state of mind of the individual whilst perpetrating the crime. We passed this information to the police, and they found out that, actually, Thomson is a drug addict, and he also has a medical record for psychotic episodes, for which presumably the antidepressant was prescribed. So now Thomson becomes the more likely suspect. But the reality is that I still don’t know where these molecules are coming from, from which fingerprint, and who those two fingerprints belong to.

05:18
Fear not. Mass spectrometry imaging can help us further. In fact, the technology is so powerful that we can see where these molecules are on a fingerprint. Like you see in this video, every single one of those peaks corresponds to a mass, every mass to a molecule, and we can interrogate the software, by selecting each of those molecules, as to where they are present on a fingermark. And some images are not very revealing, some are better, some are really good. And we can create multiple images of the same mark — in theory, hundreds of images of the same fingerprint — for as many of the molecules that we have detected.

06:09
So step one … for overlapping fingerprints, chances are, especially if they come from different individuals, that the molecular composition is not identical, so let’s ask the software to visualize those unique molecules just present in one fingermark and not in the other one. By doing so, that’s how we can separate the two ridge patterns. And this is really important because the police now are able to identify one of the two fingerprints, which actually corresponds to Katie. And they’ve been able to say so because they’ve compared the two separate images with one taken posthumously from Katie. So now, we can concentrate on one fingerprint only — that of the killer’s.

07:04
So then, step two … where are these three molecules that I’ve seen? Well, let’s interrogate the software — show me where they are. And by doing this, only portions of the image of the killer’s fingerprint show up. In other words, those substances are only present in the killer’s print. So now our molecular findings start matching very nicely the police intelligence about Thomson, should that fingerprint belong to him. But the reality is that that print is still not good enough to make an identification.

07:46
Step three: since we can generate hundreds of images of the same fingerprint, why don’t we superimpose them, and by doing so, try to improve the rich pattern of continuity and clarity?

08:02
That’s the result. Striking. We now have a very clear image of the fingerprint and the police can run it through the database. The match comes out to Thomson. Thomson is our killer.

08:17
(Applause)

08:21
Katie, the suspects and the circumstances of the crime aren’t real, but the story contains elements of the real police casework we’ve been confronted with, and is a composite of the intelligence that we can provide — that we have been able to provide the police. And I’m really, really thrilled that after nine years of intense research, as of 2017, we are able to contribute to police investigations.

08:53
Mine is no longer a dream; it’s a goal. We’re going to do this wider and wider, bigger and bigger, and we’re going to know more about the suspect, and we’re going to build an identikit. I believe this is also a new era for criminal profiling. The work of the criminologist draws on the expert recognition of behavioral patterns that have been observed before to belong to a certain type, to a certain profile. As opposed to this expert but subjective evaluation, we’re trying to do the same thing, but from the molecular makeup of the fingerprint, and the two can work together.

09:36
I did say that molecules are storytellers, so information on your health, your actions, your lifestyle, your routines, they’re all there, accessible in a fingerprint. And molecules are the storytellers of our secrets in just a touch.

09:58
Thank you.

09:59
(Audience) Wow.

10:01
(Applause)

Posted in TED 演讲 | Your fingerprints reveal more than you think已关闭评论

learn English with pictures

Because pictures are always more interesting than words, so they may help you to remember more words and grammar.

1

2

3

4

5

6

7

8

9

Posted in learn English with pictures | learn English with pictures已关闭评论

suse 上apache 启用 module_headers 并配置 cache-control

启用 headers_moule

在 centos 配置比较简单,只需要 loadmodules 即可:

cat /etc/httpd/conf.modules.d/00-base.conf | grep headers
LoadModule headers_module modules/mod_headers.so

但在 suse 上,却是通过 sysconfig 来配置的:


cat /etc/sysconfig/apache2 | grep MODULES | grep -v "^#"
APACHE_MODULES="actions alias auth_basic authn_core authn_file authz_core authz_groupfile authz_host authz_user autoindex cgi dir env expires include log_config mime negotiation perl reqtimeout setenvif socache_shmcb ssl userdir headers"

需要编辑这行内容,并且如果 /usr/lib64/apache2 下有 so 文件即可。查看模块方式如下:

/usr/sbin/apache2ctl -t -D DUMP_MODULES | grep shared
AH00557: httpd-prefork: apr_sockaddr_info_get() failed for mirrors
AH00558: httpd-prefork: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
actions_module (shared)
alias_module (shared)
auth_basic_module (shared)
authn_core_module (shared)
authn_file_module (shared)
authz_core_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
cgi_module (shared)
dir_module (shared)
env_module (shared)
expires_module (shared)
include_module (shared)
log_config_module (shared)
mime_module (shared)
negotiation_module (shared)
perl_module (shared)
reqtimeout_module (shared)
setenvif_module (shared)
socache_shmcb_module (shared)
ssl_module (shared)
userdir_module (shared)
headers_module (shared)

其中静态和动态加载的都显示出来了。

## 配置header中的cache-control

比如其中的一个配置为:


PerlRequire "/etc/apache2/smt-mod_perl-startup.pl"

Alias "/SUSE" "/srv/www/htdocs/repo/SUSE"
Alias repo "/srv/www/htdocs/repo"

<Directory "/srv/www/htdocs/repo">
    Options +Indexes +FollowSymLinks
    IndexOptions +NameWidth=*
    PerlAuthenHandler NU::SMTAuth
    AuthName SMTAuth
    AuthType Basic
    Require valid-user

    <IfModule mod_headers.c>
            Header set Via "host-name"
            Header set Cache-Control "max-age=43200"
            <FilesMatch "\.(xml|xm_|gz|sh|conf|tar|repo|bz2)$">
                    Header set Cache-Control "max-age=300"
            </FilesMatch>
    </IfModule>

    # Allow unauthenticated access to /repo/tools/ directory
    Require expr %{REQUEST_URI} =~ m#^/repo/tools/.*#
</Directory>



设置了两个 header, 并且根据文件后缀来设置不同的值。

验证效果

xml 文件


curl -I http://localhost/repo/SUSE/Updates/SLE-SAP/12-SP2/x86_64/update/repodata/repomd.xml
HTTP/1.1 200 OK
Date: Thu, 27 Sep 2018 03:41:23 GMT
Server: Apache
Last-Modified: Tue, 25 Sep 2018 16:06:01 GMT
ETag: "c22-576b448324c40"
Accept-Ranges: bytes
Content-Length: 3106
Via: smt-root-b
Cache-Control: max-age=300
Content-Type: text/xml

其他文件


curl -I http://localhost/repo/SUSE/Updates/SLE-SAP/12-SP2/x86_64/update/x86_64/MozillaFirefox-52.8.0esr-109.31.2.x86_64.rpm
HTTP/1.1 200 OK
Date: Thu, 27 Sep 2018 03:41:01 GMT
Server: Apache
Last-Modified: Fri, 18 May 2018 06:05:07 GMT
ETag: "2bfe4cd-56c74bbd72ac0"
Accept-Ranges: bytes
Content-Length: 46130381
Via: smt-root-b
Cache-Control: max-age=43200
Content-Type: application/x-rpm

Posted in web和容器 | suse 上apache 启用 module_headers 并配置 cache-control已关闭评论

秋分作画

对照婚纱照乱画一通,果然还是失败了。人物确实很难画。

Posted in 个人作品 | 秋分作画已关闭评论

nginx + uwsgi 配置 flask 开发框架

介绍

类似于,nginx 结合 php-fpm 可以支持跳转到 php 程序一样,nginx 后端也可以挂 uwsgi 来用 python 程序作为server端。

参考文档

《一个UWSGI的例子》:https://blog.csdn.net/crazyhacking/article/details/18617873
主要是关于flask + python 的代码开发例子。
《uWSGI+Nginx+Flask在Linux下的部署》https://www.cnblogs.com/zhangjpn/p/6876412.html?utm_source=itdadao&utm_medium=referral
主要是关于部署

软件安装

pip install uwsgi
yum install python-flask
yum install nginx

配置

nginx 配置

使用 http/http-socket 协议

server {
            listen       80 default_server;
            server_name  _;

        location ~ /pptserver { 
            proxy_pass http://127.0.0.1:8888;
            }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }

}

使用unix socket 协议(本地文件)

server {
            listen       80 default_server;
            server_name  _;

        location ~ /pptserver { 
        include uwsgi_params;
        uwsgi_pass unix://tmp/ppt.sock;
            }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }

}

注意,要确保 sock 文件可以被访问,一般设置为 777 即可。

uwsgi 配置

cat /data/install/conf/uwsgi.conf 
[uwsgi]
## For directlly http access
http-socket=127.0.0.1:8888

### For nginx proxy
#socket=/tmp/ppt.sock

wsgi-file=/data/install/bin/pptserver.py
#plugins = python
callable = app
#chdir = /data/install/bin
touch-reload=/data/install/bin/
processes = 2
threads = 2
stats = 127.0.0.1:9191
post-buffering = 8192
buffer-size = 65535
socket-timeout = 10
uid = apache
gid = apache
master = true
#protocol = uwsgi

注意:使用 http或者socket协议时,只需要切换下(socket或者http)即可。

运行程序

启动 nginx

service nginx restart

启动 uwsgi

/usr/bin/uwsgi --ini /data/install/conf/uwsgi.conf

测试

# curl "localhost/pptserver?uid=3434&name=get_jingle" -d "name=post_jigang"
{"get_name":"get_jingle","post_name":"post_jigang"}

附件

pptserver.py

# cat /data/install/bin/pptserver.py 
from flask import Flask,render_template, jsonify
from flask import request

app = Flask(__name__)

@app.route('/pptserver', methods=['GET', 'POST'])
#def index():
def index():
    requester = request.remote_addr
        #logging.info('Data request from: %s' % requester)
        url = request.url
        uid = url.split('uid=')[-1]
    get_name=request.args.get("name")
    post_name=request.form.get("name")
    #return "Test message, your input uid=%s, method=%s, get_name=%s, post_name=%s  from %s\n" % (uid, request.method, get_name, post_name, requester)
    return jsonify(get_name=get_name,post_name=post_name)
if __name__ == '__main__':
    app.run()

git 工程

参考我的 git 示例工程

https://github.com/duanjigang1983/study

Posted in web和容器 | nginx + uwsgi 配置 flask 开发框架已关闭评论

nginx + php-fpm 的简易配置

nginx 转发到 php-fpm

安装软件

yum install nginx -y
yum install php-fpm -y

配置nginx

在 /etc/nginx/conf.d/default.conf 基础上直接修改,就可以作为你的应用使用:

server {
    listen       80 default_server;
    server_name  _;
    root         /usr/share/nginx/html;
    include /etc/nginx/default.d/*.conf;

    location / {
    }

        #location ~ .php$ { ## 针对所有php跳转
        location ~ /testapi { ## 针对testapi底下的文件跳转。
            #root /var/www/html/opsxapi;
            root /var/www/html;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
            }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }

}

比如我们在 /var/www/html 下部署了 testapi 这个目录,其中放置了 test.php
当启动 nginx 和 php-fpm 后,可以测试

curl http://127.0.0.1/testapi/test.php

就能够请求到这页面了。
其实的原理就是,匹配到 “/testapixxxx”这个规则后,然后返回:
/var/www/html + /testapixxxx 执行的结果。

Posted in DEVOPS, web和容器 | nginx + php-fpm 的简易配置已关闭评论

Your phone company is watching


Hi. This is my mobile phone. A mobile phone can change your life, and a mobile phone gives you individual freedom. With a mobile phone, you can shoot a crime against humanity in Syria. With a mobile phone, you can tweet a message and start a protest in Egypt. And with a mobile phone, you can record a song, load it up to SoundCloud and become famous. All this is possible with your mobile phone.

I’m a child of 1984, and I live in the city of Berlin. Let’s go back to that time, to this city. Here you can see how hundreds of thousands of people stood up and protested for change. This is autumn 1989, and imagine that all those people standing up and protesting for change had a mobile phone in their pocket.

Who in the room has a mobile phone with you? Hold it up. Hold your phones up, hold your phones up! Hold it up. An Android, a Blackberry, wow. That’s a lot. Almost everybody today has a mobile phone.

But today I will talk about me and my mobile phone, and how it changed my life. And I will talk about this. These are 35,830 lines of information. Raw data. And why are these informations there? Because in the summer of 2006, the E.U. Commission tabled a directive.

This directive [is] called Data Retention Directive. This directive says that each phone company in Europe, each Internet service company all over Europe, has to store a wide range of information about the users. Who calls whom? Who sends whom an email? Who sends whom a text message? And if you use your mobile phone, where you are. All this information is stored for at least six months, up to two years by your phone company or your Internet service provider.

And all over Europe, people stood up and said, “We don’t want this.” They said, we don’t want this data retention. We want self-determination in the digital age, and we don’t want that phone companies and Internet companies have to store all this information about us. They were lawyers, journalists, priests, they all said: “We don’t want this.”

And here you can see, like 10 thousands of people went out on the streets of Berlin and said, “Freedom, not fear.” And some even said, this would be Stasi 2.0. Stasi was the secret police in East Germany.

And I also ask myself, does it really work? Can they really store all this information about us? Every time I use my mobile phone? So I asked my phone company, Deutsche Telekom, which was at that time the largest phone company in Germany, and I asked them, please, send me all the information you have stored about me. And I asked them once, and I asked them again, and I got no real answer. It was only blah blah answers.

But then I said, I want to have this information, because this is my life you are protocoling. So I decided to start a lawsuit against them, because I wanted to have this information. But Deutsche Telekom said, no, we will not give you this information. So at the end, I had a settlement with them. I’ll put down the lawsuit and they will send me all the information I ask for. Because in the mean time, the German Constitutional Court ruled that the implementation of this E.U. directive into German law was unconstitutional.

So I got this ugly brown envelope with a C.D. inside. And on the C.D., this was on. Thirty-five thousand eight hundred thirty lines of information. At first I saw it, and I said, okay, it’s a huge file. Okay. But then after a while I realized, this is my life. This is six months of my life, into this file.

So I was a little bit skeptical, what should I do with it? Because you can see where I am, where I sleep at night, what I am doing. But then I said, I want to go out with this information. I want to make them public. Because I want to show the people what does data retention mean.

So together with Zeit Online and Open Data City, I did this. This is a visualization of six months of my life. You can zoom in and zoom out, you can wind back and fast forward. You can see every step I take. And you can even see how I go from Frankfurt by train to Cologne, and how often I call in between.

All this is possible with this information. That’s a little bit scary. But it is not only about me. It’s about all of us. First, it’s only like, I call my wife and she calls me, and we talk to each other a couple of times. And then there are some friends calling me, and they call each other. And after a while you are calling you, and you are calling you, and you have this great communication network.

But you can see how your people are communicating with each other, what times they call each other, when they go to bed. You can see all of this. You can see the hubs, like who are the leaders in the group. If you have access to this information, you can see what your society is doing. If you have access to this information, you can control your society.

This is a blueprint for countries like China and Iran. This is a blueprint how to survey your society, because you know who talks to whom, who sends whom an email, all this is possible if you have access to this information. And this information is stored for at least six months in Europe, up to two years.

Like I said at the beginning, imagine that all those people on the streets of Berlin in autumn of 1989 had a mobile phone in their pocket. And the Stasi would have known who took part at this protest, and if the Stasi would have known who are the leaders behind it, this may never have happened. The fall of the Berlin Wall would maybe not [have been] there. And in the aftermath, also not the fall of the Iron Curtain. Because today, state agencies and companies want to store as much information as they can get about us, online and offline. They want to have the possibility to track our lives, and they want to store them for all time.

But self-determination and living in the digital age is no contradiction. But you have to fight for your self-determination today. You have to fight for it every day. So, when you go home, tell your friends that privacy is a value of the 21st century, and it’s not outdated. When you go home, tell your representative only because companies and state agencies have the possibility to store certain information, they don’t have to do it. And if you don’t believe me, ask your phone company what information they store about you.

So, in the future, every time you use your mobile phone, let it be a reminder to you that you have to fight for self-determination in the digital age. Thank you.

(Applause)

Posted in TED 演讲 | Your phone company is watching已关闭评论

使用 expect 封装自动 rpmsign 签名

由于 rpmsign 会要求使用者输入 pass phras, 所以可用 exepct 包装下自动输入,完成自动化签名过程:

#!/usr/bin/expect -f  

set key [lindex $argv 0 ]   
set fname [lindex $argv 1 ]   
set timeout 30                   
spawn rpmsign --resign -D  "_gpg_name $key" --quiet  $fname  
expect {                
     "Enter pass phrase:" { send "111111\r" }    
 }  
expect eof
Posted in 系统管理 | 使用 expect 封装自动 rpmsign 签名已关闭评论
« Older