A simple way to break a bad habit

When I was first learning to meditate, the instruction was to simply pay attention to my breath, and when my mind wandered, to bring it back.

Sounded simple enough. Yet I’d sit on these silent retreats, sweating through T-shirts in the middle of winter. I’d take naps every chance I got because it was really hard work. Actually, it was exhausting. The instruction was simple enough but I was missing something really important.

So why is it so hard to pay attention? Well, studies show that even when we’re really trying to pay attention to something — like maybe this talk — at some point, about half of us will drift off into a daydream, or have this urge to check our Twitter feed.

So what’s going on here? It turns out that we’re fighting one of the most evolutionarily-conserved learning processes currently known in science, one that’s conserved back to the most basic nervous systems known to man.

This reward-based learning process is called positive and negative reinforcement, and basically goes like this. We see some food that looks good, our brain says, “Calories! … Survival!” We eat the food, we taste it — it tastes good. And especially with sugar, our bodies send a signal to our brain that says, “Remember what you’re eating and where you found it.” We lay down this context-dependent memory and learn to repeat the process next time. See food, eat food, feel good, repeat. Trigger, behavior, reward.

Simple, right? Well, after a while, our creative brains say, “You know what? You can use this for more than just remembering where food is. You know, next time you feel bad, why don’t you try eating something good so you’ll feel better?” We thank our brains for the great idea, try this and quickly learn that if we eat chocolate or ice cream when we’re mad or sad, we feel better.

Same process, just a different trigger. Instead of this hunger signal coming from our stomach, this emotional signal — feeling sad — triggers that urge to eat.

Maybe in our teenage years, we were a nerd at school, and we see those rebel kids outside smoking and we think, “Hey, I want to be cool.” So we start smoking. The Marlboro Man wasn’t a dork, and that was no accident. See cool, smoke to be cool, feel good. Repeat. Trigger, behavior, reward. And each time we do this, we learn to repeat the process and it becomes a habit. So later, feeling stressed out triggers that urge to smoke a cigarette or to eat something sweet.

Now, with these same brain processes, we’ve gone from learning to survive to literally killing ourselves with these habits. Obesity and smoking are among the leading preventable causes of morbidity and mortality in the world.

So back to my breath. What if instead of fighting our brains, or trying to force ourselves to pay attention, we instead tapped into this natural, reward-based learning process … but added a twist? What if instead we just got really curious about what was happening in our momentary experience?

I’ll give you an example. In my lab, we studied whether mindfulness training could help people quit smoking. Now, just like trying to force myself to pay attention to my breath, they could try to force themselves to quit smoking. And the majority of them had tried this before and failed — on average, six times.

Now, with mindfulness training, we dropped the bit about forcing and instead focused on being curious. In fact, we even told them to smoke. What? Yeah, we said, “Go ahead and smoke, just be really curious about what it’s like when you do.”

And what did they notice? Well here’s an example from one of our smokers. She said, “Mindful smoking: smells like stinky cheese and tastes like chemicals, YUCK!” Now, she knew, cognitively that smoking was bad for her, that’s why she joined our program. What she discovered just by being curiously aware when she smoked was that smoking tastes like shit.

(Laughter)

Now, she moved from knowledge to wisdom. She moved from knowing in her head that smoking was bad for her to knowing it in her bones, and the spell of smoking was broken. She started to become disenchanted with her behavior.

Now, the prefrontal cortex, that youngest part of our brain from an evolutionary perspective, it understands on an intellectual level that we shouldn’t smoke. And it tries its hardest to help us change our behavior, to help us stop smoking, to help us stop eating that second, that third, that fourth cookie. We call this cognitive control. We’re using cognition to control our behavior. Unfortunately, this is also the first part of our brain that goes offline when we get stressed out, which isn’t that helpful.

Now, we can all relate to this in our own experience. We’re much more likely to do things like yell at our spouse or kids when we’re stressed out or tired, even though we know it’s not going to be helpful. We just can’t help ourselves.

When the prefrontal cortex goes offline, we fall back into our old habits, which is why this disenchantment is so important. Seeing what we get from our habits helps us understand them at a deeper level — to know it in our bones so we don’t have to force ourselves to hold back or restrain ourselves from behavior. We’re just less interested in doing it in the first place.

And this is what mindfulness is all about: Seeing really clearly what we get when we get caught up in our behaviors, becoming disenchanted on a visceral level and from this disenchanted stance, naturally letting go.

This isn’t to say that, poof, magically we quit smoking. But over time, as we learn to see more and more clearly the results of our actions, we let go of old habits and form new ones.

The paradox here is that mindfulness is just about being really interested in getting close and personal with what’s actually happening in our bodies and minds from moment to moment. This willingness to turn toward our experience rather than trying to make unpleasant cravings go away as quickly as possible. And this willingness to turn toward our experience is supported by curiosity, which is naturally rewarding.

What does curiosity feel like? It feels good. And what happens when we get curious? We start to notice that cravings are simply made up of body sensations — oh, there’s tightness, there’s tension, there’s restlessness — and that these body sensations come and go. These are bite-size pieces of experiences that we can manage from moment to moment rather than getting clobbered by this huge, scary craving that we choke on.

In other words, when we get curious, we step out of our old, fear-based, reactive habit patterns, and we step into being. We become this inner scientist where we’re eagerly awaiting that next data point.

Now, this might sound too simplistic to affect behavior. But in one study, we found that mindfulness training was twice as good as gold standard therapy at helping people quit smoking. So it actually works.

And when we studied the brains of experienced meditators, we found that parts of a neural network of self-referential processing called the default mode network were at play. Now, one current hypothesis is that a region of this network, called the posterior cingulate cortex, is activated not necessarily by craving itself but when we get caught up in it, when we get sucked in, and it takes us for a ride.

In contrast, when we let go — step out of the process just by being curiously aware of what’s happening — this same brain region quiets down.

Now we’re testing app and online-based mindfulness training programs that target these core mechanisms and, ironically, use the same technology that’s driving us to distraction to help us step out of our unhealthy habit patterns of smoking, of stress eating and other addictive behaviors.

Now, remember that bit about context-dependent memory? We can deliver these tools to peoples’ fingertips in the contexts that matter most. So we can help them tap into their inherent capacity to be curiously aware right when that urge to smoke or stress eat or whatever arises.

So if you don’t smoke or stress eat, maybe the next time you feel this urge to check your email when you’re bored, or you’re trying to distract yourself from work, or maybe to compulsively respond to that text message when you’re driving, see if you can tap into this natural capacity, just be curiously aware of what’s happening in your body and mind in that moment. It will just be another chance to perpetuate one of our endless and exhaustive habit loops … or step out of it.

Instead of see text message, compulsively text back, feel a little bit better — notice the urge, get curious, feel the joy of letting go and repeat.

Thank you.

(Applause)

Posted in TED 演讲 | A simple way to break a bad habit已关闭评论

Fake videos of real people — and how to spot them

Look at these images. Now, tell me which Obama here is real.

(Video) Barack Obama: To help families refinance their homes, to invest in things like high-tech manufacturing, clean energy and the infrastructure that creates good new jobs.

Supasorn Suwajanakorn: Anyone? The answer is none of them.

(Laughter)

None of these is actually real. So let me tell you how we got here. My inspiration for this work was a project meant to preserve our last chance for learning about the Holocaust from the survivors. It’s called New Dimensions in Testimony, and it allows you to have interactive conversations with a hologram of a real Holocaust survivor.

(Video) Man: How did you survive the Holocaust?

(Video) Hologram: How did I survive? I survived, I believe, because providence watched over me.

SS: Turns out these answers were prerecorded in a studio. Yet the effect is astounding. You feel so connected to his story and to him as a person. I think there’s something special about human interaction that makes it much more profound and personal than what books or lectures or movies could ever teach us.

So I saw this and began to wonder, can we create a model like this for anyone? A model that looks, talks and acts just like them? So I set out(start) to see if this could be done and eventually came up with a new solution that can build a model of a person using nothing but these: existing photos and videos of a person. If you can leverage(make use of) this kind of passive information, just photos and video that are out there, that’s the key to scaling to anyone.

By the way, here’s Richard Feynman, who in addition to being a Nobel Prize winner in physics was also known as a legendary teacher. Wouldn’t it be great if we could bring him back to give his lectures and inspire millions of kids, perhaps not just in English but in any language? Or if you could ask our grandparents for advice and hear those comforting words even if they’re no longer with us? Or maybe using this tool, book authors, alive or not, could read aloud all of their books for anyone interested.

The creative possibilities here are endless, and to me, that’s very exciting. And here’s how it’s working so far.

First, we introduce a new technique that can reconstruct a high-detailed 3D face model from any image without ever 3D-scanning the person. And here’s the same output model from different views. This also works on videos, by running the same algorithm on each video frame and generating a moving 3D model. And here’s the same output model from different angles.

It turns out this problem is very challenging, but the key trick is that we are going to analyze a large photo collection of the person beforehand. For George W. Bush, we can just search on Google, and from that, we are able to build an average model, an iterative, refined(accurate) model to recover the expression in fine details, like creases and wrinkles. What’s fascinating about this is that the photo collection can come from your typical photos. It doesn’t really matter what expression you’re making or where you took those photos. What matters is that there are a lot of them. And we are still missing color here, so next, we develop a new blending(mixed) technique that improves upon a single averaging method and produces sharp facial textures and colors. And this can be done for any expression.

Now we have a control of a model of a person, and the way it’s controlled now is by a sequence of static photos. Notice how the wrinkles come and go, depending on the expression. We can also use a video to drive the model.

(Video) Daniel Craig: Right, but somehow, we’ve managed to attract some more amazing people.

SS: And here’s another fun demo. So what you see here are controllable models of people I built from their internet photos. Now, if you transfer the motion from the input video, we can actually drive the entire party.

George W. Bush: It’s a difficult bill to pass, because there’s a lot of moving parts, and the legislative processes can be ugly.

(Applause)

SS: So coming back a little bit, our ultimate goal, rather, is to capture their mannerisms(special habits) or the unique way each of these people talks and smiles. So to do that, can we actually teach the computer to imitate the way someone talks by only showing it video footage of the person? And what I did exactly was, I let a computer watch 14 hours of pure Barack Obama giving addresses. And here’s what we can produce given only his audio.

(Video) BO: The results are clear. America’s businesses have created 14.5 million new jobs over 75 straight months.

SS: So what’s being synthesized here is only the mouth region, and here’s how we do it. Our pipeline uses a neural(神经) network to convert and input audio into these mouth points.

(Video) BO: We get it through our job or through Medicare or Medicaid.

SS: Then we synthesize the texture, enhance details and teeth, and blend it into the head and background from a source video.

(Video) BO: Women can get free checkups, and you can’t get charged more just for being a woman. Young people can stay on a parent’s plan until they turn 26.

SS: I think these results seem very realistic and intriguing(interesting), but at the same time frightening, even to me. Our goal was to build an accurate model of a person, not to misrepresent them. But one thing that concerns me is its potential for misuse. People have been thinking about this problem for a long time, since the days when Photoshop first hit the market. As a researcher, I’m also working on countermeasure technology, and I’m part of an ongoing effort at AI Foundation, which uses a combination of machine learning and human moderators to detect fake images and videos, fighting against my own work. And one of the tools we plan to release is called Reality Defender, which is a web-browser plug-in that can flag potentially fake content automatically, right in the browser.

(Applause)

Despite all this, though, fake videos could do a lot of damage, even before anyone has a chance to verify, so it’s very important that we make everyone aware of what’s currently possible so we can have the right assumption and be critical about what we see.

There’s still a long way to go before we can fully model individual people and before we can ensure the safety of this technology. But I’m excited and hopeful, because if we use it right and carefully, this tool can allow any individual’s positive impact on the world to be massively scaled and really help shape our future the way we want it to be.

Thank you.

(Applause)

Posted in TED 演讲 | Fake videos of real people — and how to spot them已关闭评论

If a story moves you, act on it

So earlier this year, I was informed that I would be doing a TED Talk. So I was excited, then I panicked(upset), then I was excited, then I panicked, and in between the excitement and the panicking, I started to do my research, and my research primarily consisted of Googling how to give a great TED Talk.

(Laughter)

And interspersed with that, I was Googling Chimamanda Ngozi Adichie. How many of you know who that is?

(Cheers)

So I was Googling her because I always Google her because I’m just a fan, but also because she always has important and interesting things to say. And the combination of those searches kept leading me to her talk on the dangers of a single story, on what happens when we have a solitary lens through which to understand certain groups of people, and it is the perfect talk. It’s the talk that I would have given if I had been famous first.

(Laughter)

You know, and you know, like, she’s African and I’m African, and she’s a feminist and I’m a feminist, and she’s a storyteller and I’m a storyteller, so I really felt like it’s my talk.

(Laughter)

So I decided that I was going to learn how to code, and then I was going to hack the internet and I would take down all the copies of that talk that existed, and then I would memorize it, and then I would come here and deliver it as if it was my own speech. So that plan was going really well, except the coding part, and then one morning a few months ago, I woke up to the news that the wife of a certain presidential candidate had given a speech that

(Laughter)

(Applause)

that sounded eerily like a speech given by one of my other faves, Michelle Obama.

(Cheers)

And so I decided that I should probably write my own TED Talk, and so that is what I am here to do. I’m here to talk about my own observations about storytelling. I want to talk to you about the power of stories, of course, but I also want to talk about their limitations, particularly for those of us who are interested in social justice.

So since Adichie gave that talk seven years ago, there has been a boom in storytelling. Stories are everywhere, and if there was a danger in the telling of one tired old tale, then I think there has got to be lots to celebrate about the flourishing of so many stories and so many voices. Stories are the antidote to bias. In fact, today, if you are middle class and connected via the internet, you can download stories at the touch of a button or the swipe of a screen. You can listen to a podcast about what it’s like to grow up Dalit in Kolkata. You can hear an indigenous man in Australia talk about the trials and triumphs of raising his children in dignity and in pride. Stories make us fall in love. They heal rifts and they bridge divides. Stories can even make it easier for us to talk about the deaths of people in our societies who don’t matter, because they make us care. Right?

I’m not so sure, and I actually work for a place called the Centre for Stories. And my job is to help to tell stories that challenge mainstream narratives about what it means to be black or a Muslim or a refugee or any of those other categories that we talk about all the time. But I come to this work after a long history as a social justice activist, and so I’m really interested in the ways that people talk about nonfiction storytelling as though it’s about more than entertainment, as though it’s about being a catalyst for social action. It’s not uncommon to hear people say that stories make the world a better place. Increasingly, though, I worry that even the most poignant(sad) stories, particularly the stories about people who no one seems to care about, can often get in the way of action towards social justice. Now, this is not because storytellers mean any harm. Quite the contrary. Storytellers are often do-gooders like me and, I suspect, yourselves. And the audiences of storytellers are often deeply compassionate and empathetic people. Still, good intentions can have unintended consequences, and so I want to propose that stories are not as magical as they seem. So three — because it’s always got to be three — three reasons why I think that stories don’t necessarily make the world a better place.

Firstly, stories can create an illusion of solidarity. There is nothing like that feel-good factor you get from listening to a fantastic story where you feel like you climbed that mountain, right, or that you befriended that death row inmate. But you didn’t. You haven’t done anything. Listening is an important but insufficient step towards social action.

Secondly, I think often we are drawn towards characters and protagonists who are likable and human. And this makes sense, of course, right? Because if you like someone, then you care about them. But the inverse is also true. If you don’t like someone, then you don’t care about them. And if you don’t care about them, you don’t have to see yourself as having a moral obligation to think about the circumstances that shaped their lives.

I learned this lesson when I was 14 years old. I learned that actually, you don’t have to like someone to recognize their wisdom, and you certainly don’t have to like someone to take a stand by their side. So my bike was stolen while I was riding it —

(Laughter)

which is possible if you’re riding slowly enough, which I was.

(Laughter)

So one minute I’m cutting across this field in the Nairobi neighborhood where I grew up, and it’s like a very bumpy path, and so when you’re riding a bike, you don’t want to be like, you know —

(Laughter)

And so I’m going like this, slowly pedaling, and all of a sudden, I’m on the floor. I’m on the ground, and I look up, and there’s this kid peddling away in the getaway vehicle, which is my bike, and he’s about 11 or 12 years old, and I’m on the floor, and I’m crying because I saved a lot of money for that bike, and I’m crying and I stand up and I start screaming. Instinct steps in, and I start screaming, “Mwizi, mwizi!” which means “thief” in Swahili. And out of the woodworks, all of these people come out and they start to give chase. This is Africa, so mob justice in action. Right? And I round the corner, and they’ve captured him, they’ve caught him. The suspect has been apprehended, and they make him give me my bike back, and they also make him apologize. Again, you know, typical African justice, right? And so they make him say sorry. And so we stand there facing each other, and he looks at me, and he says sorry, but he looks at me with this unbridled fury. He is very, very angry. And it is the first time that I have been confronted with someone who doesn’t like me simply because of what I represent. He looks at me with this look as if to say, “You, with your shiny skin and your bike, you’re angry at me?”

So it was a hard lesson that he didn’t like me, but you know what, he was right. I was a middle-class kid living in a poor country. I had a bike, and he barely had food. Sometimes, it’s the messages that we don’t want to hear, the ones that make us want to crawl out of ourselves, that we need to hear the most. For every lovable storyteller who steals your heart, there are hundreds more whose voices are slurred and ragged, who don’t get to stand up on a stage dressed in fine clothes like this. There are a million angry-boy-on-a-bike stories and we can’t afford to ignore them simply because we don’t like their protagonists or because that’s not the kid that we would bring home with us from the orphanage.

The third reason that I think that stories don’t necessarily make the world a better place is that too often we are so invested in the personal narrative that we forget to look at the bigger picture. And so we applaud someone when they tell us about their feelings of shame, but we don’t necessarily link that to oppression. We nod understandingly when someone says they felt small, but we don’t link that to discrimination. The most important stories, especially for social justice, are those that do both, that are both personal and allow us to explore and understand the political.

But it’s not just about the stories we like versus the stories we choose to ignore. Increasingly, we are living in a society where there are larger forces at play, where stories are actually for many people beginning to replace the news. Yeah? We live in a time where we are witnessing the decline of facts, when emotions rule and analysis, it’s kind of boring, right? Where we value what we feel more than what we actually know. A recent report by the Pew Center on trends in America indicates that only 10 percent of young adults under the age of 30 “place a lot of trust in the media.” Now, this is significant. It means that storytellers are gaining trust at precisely the same moment that many in the media are losing the confidence in the public. This is not a good thing, because while stories are important and they help us to have insights in many ways, we need the media. From my years as a social justice activist, I know very well that we need credible facts from media institutions combined with the powerful voices of storytellers. That’s what pushes the needle forward in terms of social justice.

In the final analysis, of course, it is justice that makes the world a better place, not stories. Right? And so if it is justice that we are after, then I think we mustn’t focus on the media or on storytellers. We must focus on audiences, on anyone who has ever turned on a radio or listened to a podcast, and that means all of us.

So a few concluding thoughts on what audiences can do to make the world a better place. So firstly, the world would be a better place, I think, if audiences were more curious and more skeptical and asked more questions about the social context that created those stories that they love so much. Secondly, the world would be a better place if audiences recognized that storytelling is intellectual work. And I think it would be important for audiences to demand more buttons on their favorite websites, buttons for example that say, “If you liked this story, click here to support a cause your storyteller believes in.” Or “click here to contribute to your storyteller’s next big idea.” Often, we are committed to the platforms, but not necessarily to the storytellers themselves. And then lastly, I think that audiences can make the world a better place by switching off their phones, by stepping away from their screens and stepping out into the real world beyond what feels safe.

Alice Walker has said, “Look closely at the present you are constructing. It should look like the future you are dreaming.” Storytellers can help us to dream, but it’s up to all of us to have a plan for justice.

Thank you.

(Applause)

Posted in TED 演讲 | If a story moves you, act on it已关闭评论

Why doctors are offering free tax prep in their waiting rooms

How many of you have had your doctor ask you about sex? Your mental health? Alcohol use? These questions are almost universal. But how many of you have had your doctor ask you about money? Most of us haven’t. But that is strange, because compared to most high-income countries, child poverty is an epidemic(sickness that can spread from one to more) in the United States. It creates conditions that may elevate(increase) stress hormone levels and impair(destroye) brain development. Poor children in the US are one and a half times more likely to die and twice as likely to be hospitalized as their middle-class counterparts.

So my colleague Dr. Michael Hole and I started asking moms about money. We knew we needed to reimagine(rebuild the impression of sb) what a doctor’s visit looks like, to get kids out of poverty and to give them a fair(equal) shot at a healthy life.

Our questions led to a surprising solution: tax credits. It turns out, the earned income tax credit, or EITC, is the best poverty prescription we have in the US. The average mom gets two to three thousand dollars a year from it. When families get it, moms and babies are healthier: fewer depressed(to have a bad emotion) moms, babies weighing more at birth. But one out of five families who could get it doesn’t, and most who do lose of hundreds of dollars to the for-profit(set the purpose to earn money) tax-preparation industry.

One day, a mom asked us why we couldn’t do her taxes while she waited for the doctor.

(Laughter)

We all know that purgatory(炼狱,苦难). Why not make good use of that time?

So we started StreetCred, an organization prescribing tax preparation in clinics serving kids. This is a brand-new approach and one that left some questioning our sanity(to make someone doubt if you are saintly). After all, we’re doctors, not accountants. But we have something accountants don’t: access to families. Over 90 percent of kids in the US see a doctor at least once a year. Their parents trust us and will do anything to give them a better life.

Doctors in every clinic around the country could be doing this work, too — it’s simple, really. The hospital registers as a tax-preparation site, and everyone, from medical students to retirees(peole who are retired), can volunteer as a tax preparer after passing an IRS exam. It’s not as hard as it sounds, I promise. I certainly never thought I would be doing other people’s taxes, but here I am.

We’re nearing the end of our third year. In the first two, we returned 1.6 million dollars to 750 families in Boston alone. This year —

(Applause)

This year, we’ve expanded to nine sites in four states. Sixty-three percent of our families have never heard of the EITC. How can you claim something you haven’t heard of? And half have never used free tax preparation.

That two to three thousand dollars a year goes a long way. Take hunger. An adequately nutritious, low-cost diet for a mom and two young kids costs 477 dollars a month. With EITC money, that family can eat for five to six months. Or think about medical care. Twenty million children in the US lack access to care meeting modern pediatric(clinics for children) standards. And yet, the average cost of that care is only 400 dollars per kid per year. EITC money can help fix this access problem. Perhaps most powerfully of all, this money gives moms hope. One mom used her refund(money retured) for her son to study abroad in Spain. She was struggling to pay her rent, but she saw EITC money as his shot(hope) at a better future.

We have an opportunity, as doctors and as citizens, to get to the root of this problem. We can reimagine health care as a place addressing(pointing) the causes of poor health, be it infections or finances.

Thank you.

(Applause)

Posted in TED 演讲 | Why doctors are offering free tax prep in their waiting rooms已关闭评论

centos 配置 nginx 和 uwsgi 运行 python 脚本

安装 uwsgit

pip install uwsgi

添加响应文件。

vim /data/install/bin/pptserver.py

内容是:

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

app = Flask(__name__)

@app.route('/pptserver')
def index():
 return "Test message, you get it"

if __name__ == '__main__':
 app.run()

然后配置文件修改:

cat /data/install/conf/uwsgi.conf

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

### For nginx proxy
#socket=127.0.0.1:8888
wsgi-file=/data/install/bin/pptserver.py
#plugins = python
callable = app
#chdir = /data/install/bin
touch-reload=/data/install/conf/
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

运行 uwsgi:
注意:当直接curl测试uwsgi的时候,配置为 http-socket=xxx
当使用nginx进行代理时,要配置为 socket=xxx

nohup uwsgi --ini /data/install/conf/uwsgi.conf &

检查服务:

#netstat -atnp | grep uwsgi
tcp        0      0 127.0.0.1:9191              0.0.0.0:*                   LISTEN      584/uwsgi           
tcp        0      0 127.0.0.1:8888              0.0.0.0:*                   LISTEN      584/uwsgi 

可以看到 9191端口是健康检查服务, 8888 端口是服务端口

测试下业务口:

#curl http://localhost:8888/pptserver
Test message, you get it

测试监控

#curl "http://localhost:9191"
 "version":"2.0.17.1",
 "listen_queue":0,
 "listen_queue_errors":0,
 "signal_queue":0,
 "load":0,
 "pid":584,
 "uid":48,
 "gid":0,
 "cwd":"/root",
 "locks":[
  {
   "user 0":0
  },
  {
   "signal":0
  },
  {
   "filemon":0
  },
  {
   "timer":0
  },
  {
   "rbtimer":0
  },
  {
   "cron":0
  },
  {
   "rpc":0
  },
  {
   "snmp":0
  }
 ],
 "sockets":[
  {
   "name":"127.0.0.1:8888",
   "proto":"http",
   "queue":0,
   "max_queue":100,
   "shared":0,
   "can_offload":0
  }
 ],
 "workers":[
  {
   "id":1,
   "pid":589,
   "accepting":1,
   "requests":0,
   "delta_requests":0,
   "exceptions":0,
   "harakiri_count":0,
   "signals":0,
   "signal_queue":0,
   "status":"idle",
   "rss":0,
   "vsz":0,
   "running_time":0,
   "last_spawn":1532316757,
   "respawn_count":1,
   "tx":0,
   "avg_rt":0,
   "apps":[
    {
     "id":0,
     "modifier1":0,
     "mountpoint":"",
     "startup_time":0,
     "requests":0,
     "exceptions":0,
     "chdir":""
    }
   ],
   "cores":[
    {
     "id":0,
     "requests":0,
     "static_requests":0,
     "routed_requests":0,
     "offloaded_requests":0,
     "write_errors":0,
     "read_errors":0,
     "in_request":0,
     "vars":[

     ],
     "req_info":     {

     }
    },
    {
     "id":1,
     "requests":0,
     "static_requests":0,
     "routed_requests":0,
     "offloaded_requests":0,
     "write_errors":0,
     "read_errors":0,
     "in_request":0,
     "vars":[

     ],
     "req_info":     {

     }
    }
   ]
  },
  {
   "id":2,
   "pid":590,
   "accepting":1,
   "requests":2,
   "delta_requests":2,
   "exceptions":0,
   "harakiri_count":0,
   "signals":0,
   "signal_queue":0,
   "status":"idle",
   "rss":0,
   "vsz":0,
   "running_time":2914,
   "last_spawn":1532316757,
   "respawn_count":1,
   "tx":206,
   "avg_rt":889,
   "apps":[
    {
     "id":0,
     "modifier1":0,
     "mountpoint":"",
     "startup_time":0,
     "requests":2,
     "exceptions":0,
     "chdir":""
    }
   ],
   "cores":[
    {
     "id":0,
     "requests":1,
     "static_requests":0,
     "routed_requests":0,
     "offloaded_requests":0,
     "write_errors":0,
     "read_errors":0,
     "in_request":0,
     "vars":[

     ],
     "req_info":     {

     }
    },
    {
     "id":1,
     "requests":1,
     "static_requests":0,
     "routed_requests":0,
     "offloaded_requests":0,
     "write_errors":0,
     "read_errors":0,
     "in_request":0,
     "vars":[

     ],
     "req_info":     {

     }
    }
   ]
  }
 ]
curl: (56) Failure when receiving data from the peer
}

配置 nginx 转发

配置 nginx 文件内容为:

location ~ /pptserver {
        include      uwsgi_params;
        uwsgi_pass   127.0.0.1:8888; # 指向uwsgi 所应用的内部地址,所有请求将转发给uwsgi 处理
    }

修改 uwsgi的配置为:

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

### For nginx proxy
socket=127.0.0.1:8888
wsgi-file=/data/install/bin/pptserver.py
#plugins = python
callable = app
#chdir = /data/install/bin
touch-reload=/data/install/conf/
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

然后测试nginx的接口:

curl "http://ginkgoo.org/pptserver"
Test message, you get it
Posted in 运维相关 | centos 配置 nginx 和 uwsgi 运行 python 脚本已关闭评论

Say your truths and seek them in others

Like many of us, I’ve had several careers in my life, and although they’ve been varied, my first job set the foundation for all of them. I was a home-birth midwife(a nurse helping a pregnant to deliver baby) throughout my 20s. Delivering babies taught me valuable and sometimes surprising things, like how to start a car at 2am. when it’s 10 degrees below zero.

(Laughter)

Or how to revive(make some one clear when he is fainted) a father who’s fainted at the sight of blood.

(Laughter)

Or how to cut the umbilical cord(the cord connecting the now-born baby and its mother) just so, to make a beautiful belly button.

But those aren’t the things that stuck(give somebody an surprising impression) with me or guided me when I stopped being a midwife and started other jobs. What stuck with me was this bedrock(basic) belief that each one of us comes into this world with a unique worth. When I looked into the face of a newborn, I caught a glimpse of that worthiness, that sense of unapologetic selfhood(personality), that unique spark. I use the word “soul” to describe that spark, because it’s the only word in English that comes close to naming what each baby brought into the room.

Every newborn was as singular as a snowflake, a matchless mash-up of biology and ancestry and mystery. And then that baby grows up, and in order to fit into the family, to conform to the culture, to the community, to the gender, that little one begins to cover its soul, layer by layer. We’re born this way, but —

(Laughter)

But as we grow, a lot of things happen to us that make us … want to hide our soulful eccentricities and authenticity. We’ve all done this. Everyone in this room is a former baby —

(Laughter)

with a distinctive birthright. But as adults, we spend so much of our time uncomfortable in our own skin, like we have ADD: authenticity deficit disorder. But not those babies — not yet. Their message to me was: uncover your soul and look for that soul-spark in everyone else. It’s still there.

And here’s what I learned from laboring women. Their message was about staying open, even when things are painful. A woman’s cervix normally looks like this. It’s a tight little muscle at the base of the uterus. And during labor, it has to stretch from this to this. Ouch! If you fight against that pain, you just create more pain, and you block what wants to be born.

I’ll never forget the magic that would happen when a woman stopped resisting the pain and opened. It was as if the forces of the universe took notice and sent in a wave of help. I never forgot that message, and now, when difficult or painful things happen to me in my life or my work, of course at first I resist them, but then I remember what I learned from the mothers: stay open. Stay curious. Ask the pain what it’s come to deliver. Something new wants to be born.

And there was one more big soulful lesson, and that one I learned from Albert Einstein. He wasn’t at any of the births, but —

(Laughter)

It was a lesson about time. At the end of his life, Albert Einstein concluded that our normal, hamster-wheel experience of life is an illusion. We run round and round, faster and faster, trying to get somewhere. And all the while, underneath surface time is this whole other dimension where the past and the present and the future merge and become deep time. And there’s nowhere to get to.

Albert Einstein called this state, this dimension, “only being.” And he said when he experienced it, he knew sacred awe. When I was delivering babies, I was forced off the hamster wheel. Sometimes I had to sit for days, hours and hours, just breathing with the parents; just being. And I got a big dose of sacred awe.

So those are the three lessons I took with me from midwifery. One: uncover your soul. Two: when things get difficult or painful, try to stay open. And three: every now and then, step off your hamster wheel into deep time.

Those lessons have served me throughout my life, but they really served me recently, when I took on the most important job of my life thus far.

Two years ago, my younger sister came out of remission from a rare blood cancer, and the only treatment left for her was a bone marrow transplant. And against the odds, we found a match for her, who turned out to be me. I come from a family of four girls, and when my sisters found out that I was my sister’s perfect genetic match, their reaction was, “Really? You?”

(Laughter)

“A perfect match for her?” Which is pretty typical for siblings. In a sibling society, there’s lots of things. There’s love and there’s friendship and there’s protection. But there’s also jealousy and competition and rejection and attack. In siblinghood, that’s where we start assembling many of those first layers that cover our soul.

When I discovered I was my sister’s match, I went into research mode. And I discovered that the premise(pre condition) of transplants is pretty straightforward. You destroy all the bone marrow in the cancer patient with massive doses of chemotherapy, and then you replace that marrow with several million healthy marrow cells from a donor(some one who contribute his marrow for the patient). And then you do everything you can to make sure that those new cells engraft(cell moved from one body to another and start growing) in the patient. I also learned that bone marrow transplants are fraught(be together with) with danger. If my sister made it through the near-lethal chemotherapy, she still would face other challenges. My cells might attack her body. And her body might reject my cells. They call this rejection or attack, and both could kill her.

Rejection. Attack. Those words had a familiar ring in the context of being siblings. My sister and I had a long history of love, but we also had a long history of rejection and attack, from minor misunderstandings to bigger betrayals. We didn’t have the kind of the relationship where we talked about the deeper stuff; but, like many siblings and like people in all kinds of relationships, we were hesitant(not sure) to tell our truths, to reveal our wounds, to admit our wrongdoings.

But when I learned about the dangers of rejection or attack, I thought, it’s time to change this. What if we left the bone marrow transplant up to the doctors, but did something that we later came to call our “soul marrow transplant?” What if we faced any pain we had caused each other, and instead of rejection or attack, could we listen? Could we forgive? Could we merge? Would that teach our cells to do the same?

To woo(show your interests to sb) my skeptical(easy to be doubtful) sister, I turned to my parents’ holy text: the New Yorker Magazine.

(Laughter)

I sent her a cartoon from its pages as a way of explaining why we should visit a therapist before having my bone marrow harvested and transplanted into her body. Here it is.

“I have never forgiven him for that thing I made up in my head.”

(Laughter)

I told my sister we had probably been doing the same thing, carting around made-up stories in our heads that kept us separate. And I told her that after the transplant, all of the blood flowing in her veins would be my blood, made from my marrow cells, and that inside the nucleus of each of those cells is a complete set of my DNA. “I will be swimming around in you for the rest of your life,” I told my slightly horrified(scared) sister.

(Laughter)

“I think we better clean up our relationship.”

A health crisis makes people do all sorts of risky things, like quitting a job or jumping out of an airplane and, in the case of my sister, saying “yes” to several therapy sessions, during which we got down to the marrow. We looked at and released years of stories and assumptions about each other and blame and shame until all that was left was love.

People have said I was brave to undergo(endure) the bone marrow harvest, but I don’t think so. What felt brave to me was that other kind of harvest and transplant, the soul marrow transplant, getting emotionally naked with another human being, putting aside pride and defensiveness, lifting the layers and sharing with each other our vulnerable souls. I called on those midwife lessons: uncover your soul. Open to what’s scary and painful. Look for the sacred awe.

Here I am with my marrow cells after the harvest. That’s they call it — “harvest,” like it’s some kind of bucolic(poem) farm-to-table event —

(Laughter)

Which I can assure you it is not. And here is my brave, brave sister receiving my cells. After the transplant, we began to spend more and more time together. It was as if we were little girls again. The past and the present merged. We entered deep time. I left the hamster wheel of work and life to join my sister on that lonely island of illness and healing(recovery). We spent months together — in the isolation unit, in the hospital and in her home.

Our fast-paced society does not support or even value this kind of work. We see it as a disruption(destroy) of real life and important work. We worry about the emotional drain and the financial cost — and, yes, there is a financial cost. But I was paid in the kind of currency our culture seems to have forgotten all about. I was paid in love. I was paid in soul. I was paid in my sister.

My sister said the year after transplant was the best year of her life, which was surprising. She suffered so much. But she said life never tasted as sweet, and that because of the soul-baring and the truth-telling we had done with each other, she became more unapologetically herself with everyone. She said things she’d always needed to say. She did things she always wanted to do. The same happened for me. I became braver about being authentic with the people in my life. I said my truths, but more important than that, I sought the truth of others.

It wasn’t until the final chapter of this story that I realized just how well midwifery had trained me. After that best year of my sister’s life, the cancer came roaring back, and this time there was nothing more the doctors could do. They gave her just a couple of months to live.

The night before my sister died, I sat by her bedside. She was so small and thin. I could see the blood pulsing in her neck. It was my blood, her blood, our blood. When she died, part of me would die, too.

I tried to make sense of it all, how becoming one with each other had made us more ourselves, our soul selves, and how by facing and opening to the pain of our past, we’d finally been delivered to each other, and how by stepping out of time, we would now be connected forever.

My sister left me with so many things, and I’m going to leave you now with just one of them. ** You don’t have to wait for a life-or-death situation to clean up the relationships that matter to you, to offer the marrow of your soul and to seek it in another. We can all do this. We can be like a new kind of first responder, like the one to take the first courageous(being brave) step toward the other, and to do something or try to do something other than rejection or attack. We can do this with our siblings and our mates and our friends and our colleagues. We can do this with the disconnection and the discord all around us. We can do this for the soul of the world.**

Thank you.

(Applause)

Posted in TED 演讲 | Say your truths and seek them in others已关闭评论

The power of diversity within yourself


We’re holding hands, staring at the door. My siblings(brothers and sisters) and I were waiting for my mother to come back from the hospital. She was there because my grandmother had cancer surgery(手术) that day. Finally, the doors opened, and she said, “She’s gone. She’s gone.” She started sobbing(cry in a low voice) and immediately said, “We must make arrangements. Your grandmother’s dying wish was to be buried back home in Korea.”

I was barely 12 years old, and when the shock wore off(disappeared), my mother’s words were ringing in my ears. My grandmother wanted to be buried back home. We had moved from Korea to Argentina six years prior, without knowing any Spanish, or how we were going to make a living. And upon arrival, we were immigrants who had lost everything, so we had to work really hard to rebuild our lives. So it hadn’t occurred to me that after all these years, back home was still in Korea. It made me ponder(the staus of thinking something for a long time) where I would want to be buried someday, where home was for me, and the answer was not obvious. And this really bothered me. So this episode(interesting and somall story before some story starts) launched a lifelong quest for my identity.

I was born in Korea — the land of kimchi(韩国泡菜); raised in Argentina, where I ate so much steak that I’m probably 80 percent cow by now; and I was educated in the US, where I became addicted(being fascinated by) to peanut butter.

(Laughter)

During my childhood, I felt very much Argentinian, but my looks betrayed me at times.

I remember on the first day of middle school, my Spanish literature teacher came into the room. She scanned all of my classmates, and she said, “You — you have to get a tutor(assistant of a teacher), otherwise, you won’t pass this class.” But by then I was fluent in Spanish already, so it felt as though I could be either Korean or Argentinian, but not both. It felt like a zero-sum game, where I had to give up my old identity to be able to gain or earn a new one.

So when I was 18, I decided to go to Korea, hoping that finally I could find a place to call home. But there people asked me, “Why do you speak Korean with a Spanish accent?”

(Laughter)

And, “You must be Japanese because of your big eyes and your foreign body language.” And so it turns out that I was too Korean to be Argentinian, but too Argentinian to be Korean.

And this was a pivotal(key or important) realization to me. I had failed to find that place in the world to call home. But how many Japanese-looking Koreans who speak with a Spanish accent — or even more specific, Argentinian accent — do you think are out there? Perhaps this could be an advantage. It was easy for me to stand out, which couldn’t hurt in a world that was rapidly changing, where skills could become obsolete overnight. So I stopped looking for that 100 percent commonality with the people that I met. Instead, I realized that oftentimes, I was the only overlap between groups of people that were usually in conflict with each other.

So with this realization in mind, I decided to embrace all of the different versions of myself — even allow myself to reinvent(invent again) myself at times. So for example, in high school, I have to confess(acknowledge) I was a mega-nerd. I had no sense of fashion — thick glasses, simple hairstyle — you can get the idea. I think, actually, I only had friends because I shared my homework. That’s the truth. But once at university, I was able to find a new identity for myself, and the nerd(someone who can only read book) became a popular girl. But it was MIT, so I don’t know if I can take too much credit for that. As they say over there, “The odds are good, but the goods are odd.”

(Laughter)

I switched majors so many times that my advisors joked that I should get a degree in “random studies.”

(Laughter)

I told this to my kids.

And then over the years, I have gained a lot of different identities. I started as an inventor, entrepreneur, social innovator. Then I became an investor, a woman in tech, a teacher. And most recently, I became a mom, or as my toddler(a child who is learning how to walk) says repeatedly, “Mom!” day and night. Even my accent was so confused — its origin was so obscure, that my friends called it, “Rebecanese.”

(Laughter)

But reinventing yourself can be very hard. You can face a lot of resistance at times. When I was nearly done with my PhD, I got bitten by that entrepreneurial bug. I was in Silicon Valley, and so writing a thesis in the basement didn’t seem as interesting as starting my own company. So I went to my very traditional Korean parents, who are here today, with the task of letting them know that I was going to drop out from my PhD program. You see, my siblings and I are the first generation to go to university, so for a family of immigrants, this was kind of a big deal. You can imagine how this conversation was going to go. But fortunately, I had a secret weapon with me, which was a chart that had the average income of all of the graduates from Stanford PhD programs, and then the average income of all the dropouts(he who leveas the school) from Stanford graduate programs.

(Laughter)

I must tell you — this chart was definitely skewed(understand discorrectly) by the founders of Google.

(Laughter)

But my mom looked at the chart, and she said, “Oh, for you — follow your passion.”

(Laughter)

Hi, Mom.

Now, today my identity quest is no longer to find my tribe(ancient family members). It’s more about allowing myself to embrace all of the possible permutations(exchange) of myself and cultivating(help something to grow) diversity within me and not just around me. My boys now are three years and five months old today, and they were already born with three nationalities and four languages. I should mention now that my husband is actually from Denmark — just in case I don’t have enough culture shocks in my life, I decided to marry a Danish guy. In fact, I think my kids will be the first Vikings who will have a hard time growing a beard when they become older.

(Laughter)

Yeah, we’ll have to work on that. But I really hope that they will find that their multiplicity is going to open and create a lot of doors for them in their lives, and that they can use this as a way to find commonality in a world that’s increasingly global today. I hope that instead of feeling anxious and worried that they don’t fit in that one box or that their identity will become irrelevant(have nothing to do) someday, that they can feel free to experiment and to take control of their personal narrative(personal resume) and identity. I also hope that they will use their unique combination of values and languages and cultures and skills to help create a world where identities are no longer used to alienate what looks different, but rather, to bring together people. And most importantly, I really hope that they find tremendous(greate) joy in going through these uncharted(unknown) territories, because I know I have.

Now, as for my grandmother, her last wish was also her last lesson to me. It turns out that it was never about going back to Korea and being buried there. It was about resting next to her son, who had died long before she moved to Argentina. What mattered to her was not the ocean that divided her past and new world; it was about finding common ground.

Thank you.

Posted in TED 演讲 | The power of diversity within yourself已关闭评论

git 使用技巧

push时报错:

git push origin master
error: The requested URL returned error: 403 Forbidden while accessing https://github.com

如下解决:

在远程主机生成 ssh key 文件

ssh-keygen -t rsa

然后把文件

/root/.ssh/id_rsa.pub

的内容添加到 github 的工程对应开发者 key 里面保存。

修改git配置

编辑

.git/config

文件,修改:

url = https://github.com/user/test.git,

url = ssh://git@github.com/user/test.git

然后再次 push 即可。

Posted in DEVOPS | 1 Comment

wordpress 手动升级

缘由

   有些服务器不能打开 ftp 服务来升级,或者升级失败,就需要手动来升级。

怎么升级

WordPress 本身升级

wordpress 本身升级比较容易,手动 wget 下载 zip 包,解压缩后,记得删除里面的 wp-content 目录,然后 rsync 到已经部署的目录中即可。

当你刷新页面时,一般会提示升级数据库,很快就能完成升级。

插件升级

插件很少的化,直接手动下载 zip 包,解压缩,然后 rsync 到  wordpress 目录下的 wp-content/plugins 目录里,覆盖即可。

刷新页面会提示最新版升级完成。

主题升级

主题的升级很简单,下载文件,解压缩,然后 rsync 到 wp-content/themes 目录下即可,如果 主体比较多,可以复制下载链接,使用如下的脚本来升级。

#!/bin/bash
TOPDIR="/data/web/cmesoft"
cat them.txt | while read url
do
	fname=`basename $url`
	wget $url
	if ! [ -f "$fname" ]
	then
		echo "wget $url failed"
		continue
	fi
	ndir=`echo $fname | awk '{print substr($1,1, index($1, ".")-1)}'`
	if [ -d "./$ndir" ]
	then
		rm -fr "./$ndir"
	fi
	unzip $fname
	cmd="rsync -avz $ndir $TOPDIR/wp-content/themes/"
	echo "Run command:$cmd"
	$cmd
done

实际运行时,注意修改 TOPDIR 为你部署wordpress 的目录。

Posted in 运维相关 | 1 Comment