Taste for Makers

February 2002

"...Copernicus' aesthetic objections to [equants] provided one essential motive for his rejection of the Ptolemaic system...."
- Thomas Kuhn, The Copernican Revolution
"All of us had been trained by Kelly Johnson and believed fanatically in his insistence that an airplane that looked beautiful would fly the same way."
- Ben Rich, Skunk Works
"Beauty is the first test: there is no permanent place in this world for ugly mathematics."
- G. H. Hardy, A Mathematician's Apology

I was talking recently to a friend who teaches at MIT. His field is hot now and every year he is inundated by applications from would-be graduate students. "A lot of them seem smart," he said. "What I can't tell is whether they have any kind of taste."
Taste. You don't hear that word much now. And yet we still need the underlying concept, whatever we call it. What my friend meant was that he wanted students who were not just good technicians, but who could use their technical knowledge to design beautiful things.
Mathematicians call good work "beautiful," and so, either now or in the past, have scientists, engineers, musicians, architects, designers, writers, and painters. Is it just a coincidence that they used the same word, or is there some overlap in what they meant? If there is an overlap, can we use one field's discoveries about beauty to help us in another?
For those of us who design things, these are not just theoretical questions. If there is such a thing as beauty, we need to be able to recognize it. We need good taste to make good things. Instead of treating beauty as an airy abstraction, to be either blathered about or avoided depending on how one feels about airy abstractions, let's try considering it as a practical question: how do you make good stuff?
If you mention taste nowadays, a lot of people will tell you that "taste is subjective." They believe this because it really feels that way to them. When they like something, they have no idea why. It could be because it's beautiful, or because their mother had one, or because they saw a movie star with one in a magazine, or because they know it's expensive. Their thoughts are a tangle of unexamined impulses.
Most of us are encouraged, as children, to leave this tangle unexamined. If you make fun of your little brother for coloring people green in his coloring book, your mother is likely to tell you something like "you like to do it your way and he likes to do it his way."
Your mother at this point is not trying to teach you important truths about aesthetics. She's trying to get the two of you to stop bickering.
Like many of the half-truths adults tell us, this one contradicts other things they tell us. After dinning into you that taste is merely a matter of personal preference, they take you to the museum and tell you that you should pay attention because Leonardo is a great artist.
What goes through the kid's head at this point? What does he think "great artist" means? After having been told for years that everyone just likes to do things their own way, he is unlikely to head straight for the conclusion that a great artist is someone whose work is better than the others'. A far more likely theory, in his Ptolemaic model of the universe, is that a great artist is something that's good for you, like broccoli, because someone said so in a book.
Saying that taste is just personal preference is a good way to prevent disputes. The trouble is, it's not true. You feel this when you start to design things.
Whatever job people do, they naturally want to do better. Football players like to win games. CEOs like to increase earnings. It's a matter of pride, and a real pleasure, to get better at your job. But if your job is to design things, and there is no such thing as beauty, then there is no way to get better at your job. If taste is just personal preference, then everyone's is already perfect: you like whatever you like, and that's it.
As in any job, as you continue to design things, you'll get better at it. Your tastes will change. And, like anyone who gets better at their job, you'll know you're getting better. If so, your old tastes were not merely different, but worse. Poof goes the axiom that taste can't be wrong.
Relativism is fashionable at the moment, and that may hamper you from thinking about taste, even as yours grows. But if you come out of the closet and admit, at least to yourself, that there is such a thing as good and bad design, then you can start to study good design in detail. How has your taste changed? When you made mistakes, what caused you to make them? What have other people learned about design?
Once you start to examine the question, it's surprising how much different fields' ideas of beauty have in common. The same principles of good design crop up again and again.
Good design is simple. You hear this from math to painting. In math it means that a shorter proof tends to be a better one. Where axioms are concerned, especially, less is more. It means much the same thing in programming. For architects and designers it means that beauty should depend on a few carefully chosen structural elements rather than a profusion of superficial ornament. (Ornament is not in itself bad, only when it's camouflage on insipid form.) Similarly, in painting, a still life of a few carefully observed and solidly modelled objects will tend to be more interesting than a stretch of flashy but mindlessly repetitive painting of, say, a lace collar. In writing it means: say what you mean and say it briefly.
It seems strange to have to emphasize simplicity. You'd think simple would be the default. Ornate is more work. But something seems to come over people when they try to be creative. Beginning writers adopt a pompous tone that doesn't sound anything like the way they speak. Designers trying to be artistic resort to swooshes and curlicues. Painters discover that they're expressionists. It's all evasion. Underneath the long words or the "expressive" brush strokes, there is not much going on, and that's frightening.
When you're forced to be simple, you're forced to face the real problem. When you can't deliver ornament, you have to deliver substance.
Good design is timeless. In math, every proof is timeless unless it contains a mistake. So what does Hardy mean when he says there is no permanent place for ugly mathematics? He means the same thing Kelly Johnson did: if something is ugly, it can't be the best solution. There must be a better one, and eventually someone will discover it.
Aiming at timelessness is a way to make yourself find the best answer: if you can imagine someone surpassing you, you should do it yourself. Some of the greatest masters did this so well that they left little room for those who came after. Every engraver since Durer has had to live in his shadow.
Aiming at timelessness is also a way to evade the grip of fashion. Fashions almost by definition change with time, so if you can make something that will still look good far into the future, then its appeal must derive more from merit and less from fashion.
Strangely enough, if you want to make something that will appeal to future generations, one way to do it is to try to appeal to past generations. It's hard to guess what the future will be like, but we can be sure it will be like the past in caring nothing for present fashions. So if you can make something that appeals to people today and would also have appealed to people in 1500, there is a good chance it will appeal to people in 2500.
Good design solves the right problem. The typical stove has four burners arranged in a square, and a dial to control each. How do you arrange the dials? The simplest answer is to put them in a row. But this is a simple answer to the wrong question. The dials are for humans to use, and if you put them in a row, the unlucky human will have to stop and think each time about which dial matches which burner. Better to arrange the dials in a square like the burners.
A lot of bad design is industrious, but misguided. In the mid twentieth century there was a vogue for setting text in sans-serif fonts. These fonts are closer to the pure, underlying letterforms. But in text that's not the problem you're trying to solve. For legibility it's more important that letters be easy to tell apart. It may look Victorian, but a Times Roman lowercase g is easy to tell from a lowercase y.
Problems can be improved as well as solutions. In software, an intractable problem can usually be replaced by an equivalent one that's easy to solve. Physics progressed faster as the problem became predicting observable behavior, instead of reconciling it with scripture.
Good design is suggestive. Jane Austen's novels contain almost no description; instead of telling you how everything looks, she tells her story so well that you envision the scene for yourself. Likewise, a painting that suggests is usually more engaging than one that tells. Everyone makes up their own story about the Mona Lisa.
In architecture and design, this principle means that a building or object should let you use it how you want: a good building, for example, will serve as a backdrop for whatever life people want to lead in it, instead of making them live as if they were executing a program written by the architect.
In software, it means you should give users a few basic elements that they can combine as they wish, like Lego. In math it means a proof that becomes the basis for a lot of new work is preferable to a proof that was difficult, but doesn't lead to future discoveries; in the sciences generally, citation is considered a rough indicator of merit.
Good design is often slightly funny. This one may not always be true. But Durer's engravings and Saarinen's womb chair and the Pantheon and the original Porsche 911 all seem to me slightly funny. Godel's incompleteness theorem seems like a practical joke.
I think it's because humor is related to strength. To have a sense of humor is to be strong: to keep one's sense of humor is to shrug off misfortunes, and to lose one's sense of humor is to be wounded by them. And so the mark-- or at least the prerogative-- of strength is not to take oneself too seriously. The confident will often, like swallows, seem to be making fun of the whole process slightly, as Hitchcock does in his films or Bruegel in his paintings-- or Shakespeare, for that matter.
Good design may not have to be funny, but it's hard to imagine something that could be called humorless also being good design.
Good design is hard. If you look at the people who've done great work, one thing they all seem to have in common is that they worked very hard. If you're not working hard, you're probably wasting your time.
Hard problems call for great efforts. In math, difficult proofs require ingenious solutions, and those tend to be interesting. Ditto in engineering.
When you have to climb a mountain you toss everything unnecessary out of your pack. And so an architect who has to build on a difficult site, or a small budget, will find that he is forced to produce an elegant design. Fashions and flourishes get knocked aside by the difficult business of solving the problem at all.
Not every kind of hard is good. There is good pain and bad pain. You want the kind of pain you get from going running, not the kind you get from stepping on a nail. A difficult problem could be good for a designer, but a fickle client or unreliable materials would not be.
In art, the highest place has traditionally been given to paintings of people. There is something to this tradition, and not just because pictures of faces get to press buttons in our brains that other pictures don't. We are so good at looking at faces that we force anyone who draws them to work hard to satisfy us. If you draw a tree and you change the angle of a branch five degrees, no one will know. When you change the angle of someone's eye five degrees, people notice.
When Bauhaus designers adopted Sullivan's "form follows function," what they meant was, form should follow function. And if function is hard enough, form is forced to follow it, because there is no effort to spare for error. Wild animals are beautiful because they have hard lives.
Good design looks easy. Like great athletes, great designers make it look easy. Mostly this is an illusion. The easy, conversational tone of good writing comes only on the eighth rewrite.
In science and engineering, some of the greatest discoveries seem so simple that you say to yourself, I could have thought of that. The discoverer is entitled to reply, why didn't you?
Some Leonardo heads are just a few lines. You look at them and you think, all you have to do is get eight or ten lines in the right place and you've made this beautiful portrait. Well, yes, but you have to get them in exactly the right place. The slightest error will make the whole thing collapse.
Line drawings are in fact the most difficult visual medium, because they demand near perfection. In math terms, they are a closed-form solution; lesser artists literally solve the same problems by successive approximation. One of the reasons kids give up drawing at ten or so is that they decide to start drawing like grownups, and one of the first things they try is a line drawing of a face. Smack!
In most fields the appearance of ease seems to come with practice. Perhaps what practice does is train your unconscious mind to handle tasks that used to require conscious thought. In some cases you literally train your body. An expert pianist can play notes faster than the brain can send signals to his hand. Likewise an artist, after a while, can make visual perception flow in through his eye and out through his hand as automatically as someone tapping his foot to a beat.
When people talk about being in "the zone," I think what they mean is that the spinal cord has the situation under control. Your spinal cord is less hesitant, and it frees conscious thought for the hard problems.
Good design uses symmetry. I think symmetry may just be one way to achieve simplicity, but it's important enough to be mentioned on its own. Nature uses it a lot, which is a good sign.
There are two kinds of symmetry, repetition and recursion. Recursion means repetition in subelements, like the pattern of veins in a leaf.
Symmetry is unfashionable in some fields now, in reaction to excesses in the past. Architects started consciously making buildings asymmetric in Victorian times and by the 1920s asymmetry was an explicit premise of modernist architecture. Even these buildings only tended to be asymmetric about major axes, though; there were hundreds of minor symmetries.
In writing you find symmetry at every level, from the phrases in a sentence to the plot of a novel. You find the same in music and art. Mosaics (and some Cezannes) get extra visual punch by making the whole picture out of the same atoms. Compositional symmetry yields some of the most memorable paintings, especially when two halves react to one another, as in the Creation of Adam or American Gothic.
In math and engineering, recursion, especially, is a big win. Inductive proofs are wonderfully short. In software, a problem that can be solved by recursion is nearly always best solved that way. The Eiffel Tower looks striking partly because it is a recursive solution, a tower on a tower.
The danger of symmetry, and repetition especially, is that it can be used as a substitute for thought.
Good design resembles nature. It's not so much that resembling nature is intrinsically good as that nature has had a long time to work on the problem. It's a good sign when your answer resembles nature's.
It's not cheating to copy. Few would deny that a story should be like life. Working from life is a valuable tool in painting too, though its role has often been misunderstood. The aim is not simply to make a record. The point of painting from life is that it gives your mind something to chew on: when your eyes are looking at something, your hand will do more interesting work.
Imitating nature also works in engineering. Boats have long had spines and ribs like an animal's ribcage. In some cases we may have to wait for better technology: early aircraft designers were mistaken to design aircraft that looked like birds, because they didn't have materials or power sources light enough (the Wrights' engine weighed 152 lbs. and generated only 12 hp.) or control systems sophisticated enough for machines that flew like birds, but I could imagine little unmanned reconnaissance planes flying like birds in fifty years.
Now that we have enough computer power, we can imitate nature's method as well as its results. Genetic algorithms may let us create things too complex to design in the ordinary sense.
Good design is redesign. It's rare to get things right the first time. Experts expect to throw away some early work. They plan for plans to change.
It takes confidence to throw work away. You have to be able to think, there's more where that came from. When people first start drawing, for example, they're often reluctant to redo parts that aren't right; they feel they've been lucky to get that far, and if they try to redo something, it will turn out worse. Instead they convince themselves that the drawing is not that bad, really-- in fact, maybe they meant it to look that way.
Dangerous territory, that; if anything you should cultivate dissatisfaction. In Leonardo's drawings there are often five or six attempts to get a line right. The distinctive back of the Porsche 911 only appeared in the redesign of an awkward prototype. In Wright's early plans for the Guggenheim, the right half was a ziggurat; he inverted it to get the present shape.
Mistakes are natural. Instead of treating them as disasters, make them easy to acknowledge and easy to fix. Leonardo more or less invented the sketch, as a way to make drawing bear a greater weight of exploration. Open-source software has fewer bugs because it admits the possibility of bugs.
It helps to have a medium that makes change easy. When oil paint replaced tempera in the fifteenth century, it helped painters to deal with difficult subjects like the human figure because, unlike tempera, oil can be blended and overpainted.
Good design can copy. Attitudes to copying often make a round trip. A novice imitates without knowing it; next he tries consciously to be original; finally, he decides it's more important to be right than original.
Unknowing imitation is almost a recipe for bad design. If you don't know where your ideas are coming from, you're probably imitating an imitator. Raphael so pervaded mid-nineteenth century taste that almost anyone who tried to draw was imitating him, often at several removes. It was this, more than Raphael's own work, that bothered the Pre-Raphaelites.
The ambitious are not content to imitate. The second phase in the growth of taste is a conscious attempt at originality.
I think the greatest masters go on to achieve a kind of selflessness. They just want to get the right answer, and if part of the right answer has already been discovered by someone else, that's no reason not to use it. They're confident enough to take from anyone without feeling that their own vision will be lost in the process.
Good design is often strange. Some of the very best work has an uncanny quality: Euler's Formula, Bruegel's Hunters in the Snow, the SR-71, Lisp. They're not just beautiful, but strangely beautiful.
I'm not sure why. It may just be my own stupidity. A can-opener must seem miraculous to a dog. Maybe if I were smart enough it would seem the most natural thing in the world that ei*pi = -1. It is after all necessarily true.
Most of the qualities I've mentioned are things that can be cultivated, but I don't think it works to cultivate strangeness. The best you can do is not squash it if it starts to appear. Einstein didn't try to make relativity strange. He tried to make it true, and the truth turned out to be strange.
At an art school where I once studied, the students wanted most of all to develop a personal style. But if you just try to make good things, you'll inevitably do it in a distinctive way, just as each person walks in a distinctive way. Michelangelo was not trying to paint like Michelangelo. He was just trying to paint well; he couldn't help painting like Michelangelo.
The only style worth having is the one you can't help. And this is especially true for strangeness. There is no shortcut to it. The Northwest Passage that the Mannerists, the Romantics, and two generations of American high school students have searched for does not seem to exist. The only way to get there is to go through good and come out the other side.
Good design happens in chunks. The inhabitants of fifteenth century Florence included Brunelleschi, Ghiberti, Donatello, Masaccio, Filippo Lippi, Fra Angelico, Verrocchio, Botticelli, Leonardo, and Michelangelo. Milan at the time was as big as Florence. How many fifteenth century Milanese artists can you name?
Something was happening in Florence in the fifteenth century. And it can't have been heredity, because it isn't happening now. You have to assume that whatever inborn ability Leonardo and Michelangelo had, there were people born in Milan with just as much. What happened to the Milanese Leonardo?
There are roughly a thousand times as many people alive in the US right now as lived in Florence during the fifteenth century. A thousand Leonardos and a thousand Michelangelos walk among us. If DNA ruled, we should be greeted daily by artistic marvels. We aren't, and the reason is that to make Leonardo you need more than his innate ability. You also need Florence in 1450.
Nothing is more powerful than a community of talented people working on related problems. Genes count for little by comparison: being a genetic Leonardo was not enough to compensate for having been born near Milan instead of Florence. Today we move around more, but great work still comes disproportionately from a few hotspots: the Bauhaus, the Manhattan Project, the New Yorker, Lockheed's Skunk Works, Xerox Parc.
At any given time there are a few hot topics and a few groups doing great work on them, and it's nearly impossible to do good work yourself if you're too far removed from one of these centers. You can push or pull these trends to some extent, but you can't break away from them. (Maybe you can, but the Milanese Leonardo couldn't.)
Good design is often daring. At every period of history, people have believed things that were just ridiculous, and believed them so strongly that you risked ostracism or even violence by saying otherwise.
If our own time were any different, that would be remarkable. As far as I can tell it isn't.
This problem afflicts not just every era, but in some degree every field. Much Renaissance art was in its time considered shockingly secular: according to Vasari, Botticelli repented and gave up painting, and Fra Bartolommeo and Lorenzo di Credi actually burned some of their work. Einstein's theory of relativity offended many contemporary physicists, and was not fully accepted for decades-- in France, not until the 1950s.
Today's experimental error is tomorrow's new theory. If you want to discover great new things, then instead of turning a blind eye to the places where conventional wisdom and truth don't quite meet, you should pay particular attention to them.
As a practical matter, I think it's easier to see ugliness than to imagine beauty. Most of the people who've made beautiful things seem to have done it by fixing something that they thought ugly. Great work usually seems to happen because someone sees something and thinks, I could do better than that. Giotto saw traditional Byzantine madonnas painted according to a formula that had satisfied everyone for centuries, and to him they looked wooden and unnatural. Copernicus was so troubled by a hack that all his contemporaries could tolerate that he felt there must be a better solution.
Intolerance for ugliness is not in itself enough. You have to understand a field well before you develop a good nose for what needs fixing. You have to do your homework. But as you become expert in a field, you'll start to hear little voices saying, What a hack! There must be a better way. Don't ignore those voices. Cultivate them. The recipe for great work is: very exacting taste, plus the ability to gratify it.
Notes
Sullivan actually said "form ever follows function," but I think the usual misquotation is closer to what modernist architects meant.
Stephen G. Brush, "Why was Relativity Accepted?" Phys. Perspect. 1 (1999) 184-214.

[转]创造者的鉴赏力


"哥白尼对天动说美学上的反对是他拒绝托勒密体系的重要原因..."
- Thomas Kuhn, The Copernican Revolution
"在Kelly Johnson的训练之下,我们狂热地坚信他的主张: 一架看上去很美的飞机飞得也会同样的美."
- Ben Rich, Skunk Works
"美是第一道检验: 世上没有永久的地方容纳丑陋的数学."
- G. H. Hardy, A Mathematician's Apology

我最近与一位在MIT任教的朋友聊天. 他的领域现在很热门,来自即将成为研究生的申请表每年都潮水般地涌向他. "他们中的大多数看上去都很聪明,"他说. "我不能确定的是他们是否有鉴赏力."
鉴赏力. 你现在不常听到这个词了. 不过我们仍然需要其中的概念,不管人们叫它什么. 我朋友的意思是,他希望学生不仅是好的技术人员, 而且会用他们的技术知识设计出美好的事物.
数学家称出色的工作是"美的", 就象不论是过去还是现在,科学家,工程师,音乐家,建筑师,设计师,作家和画家用"美"来形容作品一样. 他们使用同一个形容词,是一种巧合,还是他们所说的有某种含义上的重合? 如果有重合, 我们能否利用一个领域里关于美的发现,去找到另一个领域(的美)?
对于我们设计者来说,这些不仅是理论问题. 如果的确有叫做美的东西,我们必须能够认识它. 我们需要好的鉴赏力来做出好的事物. 与其视美为空洞的抽象物, 我们不如把它看成一个实际的问题: 你如何做出好的物品?
如果你现在提起鉴赏力, 许多人会告诉你"鉴赏力是主观的". 他们实际上是这样感觉的,所以他们这样认为. 当他们喜欢某样东西的时候,也不知道是为什么. 可能是因为它美,也可能是他们的妈妈有同样的东西,或者是在杂志上看到某个电影明星有同样的东西,或者他们知道这东西很昂贵. 他们的思维处于未经权衡的随心所欲的混乱状态.
大多数人从小就被鼓励让这种随心所欲处在未经权衡的状态下. 如果你取笑你的弟弟在图画书上把人的皮肤涂成绿色, 你妈妈可能会说"你喜欢你的方式,他喜欢他的方式"之类的话.
你妈妈这时并不是想教你重要的美学理论,她只不过想让你俩停止斗嘴.
就象成人告诉我们的许多半真半假的事一样, 这件事与他们说的其它的事矛盾. 再三地跟你说了"鉴赏力只不过是个人的喜好"之后, 他们带你去了博物馆, 并告诉你,你得用点心, 因为达芬奇是一个伟大的艺术家.
这时闪过孩子脑海里的是什么? 他会认为"伟大的艺术家"是什么意思呢? 经过多年的"每个人喜欢用他自己的方式做事"的灌输之后,他不太可能直接得出结论:所谓伟大的艺术家,就是他的作品要比别人的好. 在他托勒密式的宇宙观里,更可能的结论是:伟大的艺术家是对你有好处的,就象书上说椰菜对人的身体有好处一样.
说鉴赏力是个人喜好是避免争论的好办法. 问题是,它不是真的. 当你开始设计事物时,你会感觉到这点.
无论人们做什么工作,他们自然地想做得好些. 足球队员想赢得比赛, CEO想增加收入. 在工作中做得更好, 使人感到愉快和骄傲. 不过如果你的工作是设计,而且其中没有美这码事, 那么就没有办法把工作做得更好. 如果鉴赏力仅是个人喜好, 那每个人都是完美的: 你无论喜欢什么都行,不必多说了.
就象任何一项工作, 当你持续地设计物体,你会得到更好的效果. 你的鉴赏力会改变. 而且就象任何在工作中越做越好的人一样,你知道你也在进步. 如果是这样的话,你原来的鉴赏力不仅和现在不同,而且比现在的坏. 让鉴赏力不会有错的公理见鬼去吧.
现在盛行的相对主义可能会妨碍你对鉴赏力的思考,即使你自己的鉴赏力正在发展. 但是如果你面对现实并承认,至少对你而言,存在着好的设计和坏的设计, 然后你可以开始仔细研究好的设计. 你的鉴赏力是如何改变的? 当你犯错误的时候,想想什么使你犯这个错误? 其他人从设计中学到了什么?
你一旦开始思索这些问题, 就会惊讶地发现美的观念在多少不同的领域是相通的. 同样的完美设计的原则一遍又一遍地出现在人们的面前.
好的设计是简单的. 从数学到绘画,你都能听到它. 在数学里它意味着一个较短的证明往往较好. 特别是公理,越少越好. 在程序设计领域,也是同样的道理. 对建筑师和设计者来说,这意味着美应该依赖于一些精心选择的结构性的元素,而不是过多的表面装饰. (装饰本身并不坏,坏在被用来掩饰平淡的实体.) 类似地, 在绘画领域, 经过仔细观察和扎实临摹的静物画往往比一幅浮华但没头脑的画(比如带花边的衣领)更令人感兴趣. 在写作领域,它意味着简洁地说出你想说的.
当你被迫做得简单,说明你正在面对实际的问题. 如果你不能放弃装饰,你就得放弃本质.
好的设计是永恒的. 数学里的每个证明都是永久的,除非它有错误. 那哈代说 "世上没有永久的地方容纳丑陋的数学"是什么意思呢? 他的意思和Kelly Johnson的一样: 丑陋的东西不可能是最好的解决办法. 一定有更好的办法,最终有人会发现它.
以永恒为目标是发现最佳答案的一个方法: 如果你能想象到别人能超过你,你还是自己来吧. 一些最伟大的大师在这方面做得如此之好,几乎没给后来者留下多少空间. 丢勒之后的雕刻师不得不生活在他的阴影下.
奇怪的是, 如果你想做出吸引将来的人类的事物,一种方法是设法吸引过去的人类. 很难猜测将来会怎样, 但我们可以肯定, 将来会象过去一样,不会关心现在的时尚. 因此如果你能做出吸引当代的人和1500年的人的东西,极有可能它会吸引2500年的人类.
好的设计解决正确的问题. 典型的(烹饪用的)炉子有四个出火口,形成一个正方形,各有一个开关控制它们. 你如何安排这些开关? 最简单的答案是把它们排成一行. 但这是答非所问. 开关是给人用的,如果你把它们排成一行,不幸的厨师不得不每次都停下来思考一下哪个开关是控制哪个出火口的. 更好的办法是象出火口那样安排成一个正方形.
许多坏的设计是勤勉的,但是被误导了. 二十世纪中叶有一股使用无衬线(sans-serif)字体的风气. 这些字体的确更接近纯粹的基本的字形. 但这不是你在文本里要解决的问题. 字母能被容易地认出是更重要的事情. 虽然象是维多利亚时代的风格, 但Times Roman的小写字母g很容易与小写字母y区分.
问题可以解决也可以改进. 在软件领域, 一个难以对付的问题通常可以被一个等价的较易解决的问题代替. 物理学因为要解决的问题变为预测可观察事物的行为,而不是把它与经典著作调和起来,而发展得更快了.
好的设计是有启发性的. 简奥斯汀的小说几乎没有描写,不是告诉你每样事物是什么样子的, 她讲故事如此之好以至于你可以自己想象出场景. 类似地, 有启发的画通常比合盘托出的画更有吸引力. 每个看过蒙娜丽莎的人都有他自己的关于她的故事.
此原则在建筑或设计界的体现是,建筑物或物体应该让你自如地使用: 比如说一幢好的建筑物,能充当这样一个背景,让住在此处的人过任何他们想过的生活, 而不是生活起居就象在执行建筑师的程序.
在软件领域,它意味着你应该给用户一些基本的元素,它们可以象拼装玩具一样自由地组合. 在数学里,它意味着一个能成为许多新工作的基础的证明比一个因难但不能引出什么新发现的证明更可取. 在科学领域,一般来说,(被别人)引用的多少是自身价值的粗略指标.
好的设计常常有点滑稽. 这点并不总是正确. 但丢勒(Durer)的雕刻, 沙里宁(Saarinen)的womb char, pantheon, 以及最初的Porsche 911在我看来都有点儿滑稽. 哥德尔的不完全定理就象一个恶作剧.
我想这是因为幽默与力量有关吧. 有幽默感就有力量: 保持幽默感就是对不幸一笑了之, 而失去幽默感就会被它伤害. 因此力量的标志,或至少是特长,是不要把事情看得太严重. 自信会你显得对全过程采取一种轻松的态度. 就象希区柯克(Hitchcock)在他的电影中, 勃鲁盖尔(Brueghel)在他的绘画中,莎士比亚(Shakespeare)在他的戏剧中所表现的一样.
好的设计不必表现得滑稽,但很难想象没有幽默感的东西会是好的设计.
好的设计是困难的. 看一下有过伟大成就的人物,有一点是共同的:他们曾经努力地工作. 如果你不努力,可能你在浪费时间.
困难的问题需要巨大的努力. 困难的数学证明需要天才的解答,而且它往往是令人着迷的. 工程界也是这样.
你爬山的时候会把所有不必要的东西从背包里拿出来. 同样一个要在困难的地点,或只有很小的预算的条件下造房的建筑师,会发现他必须做出优雅的设计. 流行和浮华的东西只能被撇在一边了.
并不是所有的努力都是好的. 苦痛也有优劣之分. 你希望那种飞奔起来的痛,而不是站在钉子上的痛, 困难的问题可能对设计师有好处, 而刁难的顾客和不可靠的原料可没什么好处.
传统上美术领域的最高位置留给了人物画. 传统是有原因的,不是因为人物画在我们头脑里留下印象,而其它画种没有. 我们是如此善于观察人脸,迫使画脸的人不懈努力使我们感到满意. 如果你画树的时候把树枝画偏了五度,没人会发现. 如果你把人眼画偏了五度, 人人都会注意到.
当Bauhaus学派采纳Sullivan的"形式跟随功能"的时候,他们指的是,形式应该跟随功能. 而且如果功能足够困难, 形式也必须跟随,因为没有出错的余地. 野生动物是美丽的,因为它们有艰苦的生活.
好的设计看上去很容易. 就象优秀的运动员,伟大的设计者使人觉得设计很容易. 通常这是一种表象. 经过好几遍的修改, 才会有读起来朗朗上口的文章.
在科技界,一些最伟大的发现看上去是如此简单,你会对自己说,我也想得到. 发现者有资格回答这个问题: 哪你为什么没有(想到)呢?
达芬奇的一些头像画仅寥寥数笔. 你注视着这些画,心里暗想,你所要做的只是把这八九条线画到正确的位置,然后一幅杰作就产生了. 是的, 但你必须把它们画到恰好正确的位置. 一点儿偏差就会让整幅画失败.
线条画要求近乎完美,因此事实上它是最难的视觉媒体. 用数学的术语说,它是封闭的解. 不那么优秀的艺术家用逐渐逼近的方法解决同样的问题. 十岁左右的孩子放弃绘画的一个原因是,他们决心象大人一样画画,而且第一次就尝试画一张人脸. 当头一棒!
在许多领域,容易是和练习联系在一起的. 也许练习训练你用潜意识来完成得用意识来完成的任务. 在一些情况下, 你精确地训练你的身体. 专业钢琴家按键快于大脑传给手的信号. 经过一段时间训练的画家,可以把视觉感知从眼传到手, 尤如条件反射.
当说一个人"进入化境"时, 我认为他们是指脊髓控制了身体,脊髓少些犹豫, 而且解放了意识,让它思考更难的问题.
好的设计使用对称. 我认为对称可能只是取得简单性的途径之一,但它很重要,值得单独提出来. 自然界大量地应用它, 这是一个好迹象.
有两类对称: 重复和递归. 递归是指在亚层次上重复,就象树叶的脉络.
对称在一些领域里不流行了,作为对以前过多使用的反弹. 建筑师在维多利亚时代开始有意识地使用不对称, 到了1920年代,不对称成为现代主义建筑的明确前提. 但即使是这类建筑也只是在中轴线上不对称,还有许多小的地方是对称的.
在写作中各个层次上都有对称,从句子中的词组到小说的结构. 音乐和绘画也是如此. 由相同颗粒组成的马赛克画(和某些塞尚的画)有特别的视觉冲击力. 组合而成的对称产生了一些最难忘的作品: 亚当的诞生美洲哥特式教堂.
在数学和工程里递归特别有用. 归纳法惊人地简洁. 能够用递归解决的软件问题几乎肯定是最好的解决办法. 埃菲尔铁塔引人注意的部分原因是它是递归的: 一个塔叠着一个塔.
对称,尤其是重复的危险在于,它可能会代替思考.
好的设计模仿自然. 与其说模仿自然有本质上的好处,还不如说大自然已经花了亿万年的时间探索问题的解决方案. 如果你的答案模仿了自然,那是个好迹象.
复制并不是作弊. 没人会否认故事应该象生活. 从生活中找到灵感也是绘画的法宝, 虽然它的任务经常被误解. 目标是不要简单地作个记录, 要点是它给你某些值得玩味的东西: 当你的目光注视着一个物体,你的手会做出更有趣的工作.
效法自然在工程领域也是起作用的. 船很久以来就有脊骨和加强筋,好象动物的胸腔. 在某些情况下我们不得不等待更好的技术出现: 早期的飞机设计者错误地把飞机设计成鸟的样子, 但是他们没有足够轻的材料或动力(莱特兄弟的引擎重152磅,却只有12马力的输出.),也没有精巧的导航系统使得机器象鸟一样飞翔. 不过我预测小型的能象鸟一样飞行的无人驾驶飞机会在五十年内出现.
既然有了强大的计算能力,我们不但可以模仿大自然的结果,也可以模拟大自然的方法. 基因算法能让我们创造出因为太复杂而在通常条件下设计不出的东西.
好的设计是再设计. 第一次就把事情做对的可能性是很小的. 专家料到会扔掉一些初期的作品,他们为计划的改变作了计划.
把作品扔掉需要自信. 你必须这样想,会有更多的成果出现. 举个例子,人们刚开始学画的时候,不情愿重画那些不好的地方. 他们觉得做到这步已经很幸运了,如果重做的话,可能会更糟. 于是他们说服自己这画还没有那么糟, 真的 -- 事实上,也许就该这么画.
(这样说服自己)真是危险; 为了培养一种不满足的精神而犯错会更好. 达芬奇的素描里,经常是五六次尝试才能画出一条线的准确位置. 与众不同的Porsche 911的背后,是笨拙的原型. Wright原先的Guggenheim的设计里, 右半部是个金字塔形的建筑(ziggurat),他把它倒转成现在的模样.
犯错是正常的. 不要把错误视为灾难, 而要把它们弄得容易证实和修复. 达芬奇或多或少发明了素描, 使得画画能够承受更多的负荷和探索. 开发源代码的软件错误少些,因为它承认犯错误的可能性.
如果介质能使改变变得容易, 是有帮助的. 油画颜料在十五世纪取代蛋彩的时候, 画家开始能够处理一些诸如人像画等困难的题材, 因为不象蛋彩,油画颜料可以混合和覆盖.
好的设计可以复制. 对复制的态度通常会走一条弯路. 新手还没有了解就开始模仿; 然后他有意识地试图原创; 最后,他认识到正确比原创更重要.
无知的模仿几乎就是坏设计的秘方. 如果你不知道你的想法从哪里来,你可能在模仿一个模仿者. 拉斐尔风格在十九世纪中期是如此流行,以至于每个学画的人都要模仿他, 甚至是模仿的模仿. 正是这种风气,而不是拉斐尔本人的作品,惹恼了拉斐尔前派艺术家.
有雄心的人不满足于模仿. 鉴赏力成长的第二阶段是有意识地以原创为目标.
我认为最伟大的大师们有一种忘我的精神. 他们一心想得到正确的答案,因此如果正确答案的某些部分已经被人发现了,那么没有理由不用它. 他们有足够的自信从别人那儿汲取养料,而不担心在此过程中失去自己的观念.
好的设计通常是奇特的.一些最杰出的作品有不可思议的品质: 欧拉公式, 勃鲁盖尔(Brueghel)的雪中猎人 ,SR-71, Lisp. 它们不仅是美的, 而且是奇异地美.
我不知道原因. 可能是我自己愚昧无知. 开罐器对狗来说一定也是不可思议的. 如果我足够聪明的话, 会觉得ei*pi = -1 是世界上最自然的事情. 不论如何,此公式肯定是真理.
我在本文里提到的大多数品质是可以培养的, 但我不认为奇异性可以培养. 你能做的最好的事情是有这个苗头的时候,不要去压制它. 爱因斯坦没有试图把相对论弄得奇特. 他试图找出真理, 而这真理显得很奇特.
唯一值得拥有的风格是你不能刻意追求的那种. 对奇异性来说, 尤其是这样. 没有捷径可走. 风格主义派(Mannerists), 浪漫派(Romantics)和两代美国高中生苦苦寻找的西北航路是不存在的. 到达它(奇异性)的唯一办法是经受好的(设计),然后从另一头出来.
好的设计成批出现.十五世纪佛罗伦萨的居民包括:布鲁内勒斯基 (Brunelleschi), 吉尔伯提(Ghiberti), 多纳泰罗 (Donatello), 马萨其奥(Masaccio), 菲利波·利比(Filippo Lippi), 弗拉·安吉利科(Fra Angelico), 维洛及欧(Verrocchio), 波提切利(Botticelli), 达芬奇(Leonardo da Vinci), 和米开朗基罗 (Michelangelo). 米兰当时和佛罗伦萨一样大, 你能说出多少米兰艺术家?
十五世纪的佛罗伦萨发生了一些事情,而且它是不可遗传的, 因为现在不发生了. 你必须假定无论达芬奇和米开朗基罗有什么先天的因素,米兰人也应该有. 可以米兰的达芬奇呢?
美国现在的人口大约是十五世纪佛罗伦萨的一千倍. 一千个达芬奇和一千个米开朗基罗生活在我们中间. 如果仅由DNA支配一切, 我们天天会碰到艺术杰作. 我们没有, 原因是你要创造达芬奇, 不仅需要他天生的能力, 还要1450年的佛罗伦萨.
没有什么比一群有才能的人在相关问题上进行探索更强大的了. 比较起来, 基因无足轻重: 具有达芬奇的基因不足以补偿住得离米兰近而离佛罗伦萨远. 现代人迁移得更多了, 但伟大的作品仍然不成比例地来自几个热点地区: 鲍豪斯 (Bauhaus), 曼哈顿计划, 纽约客, 洛克希德的Skunk Works, 施乐的帕洛阿尔托研究中心(Xerox Parc).
在任何时候,只有有限的课题和有限的做出伟大工作的小组. 如果你离这些中心太远, 就几乎不可能有出色的工作. 你可以在某种程度上顺应或反对这种趋势, 但你不能脱离它.(也许你能, 但米兰的达芬奇没有成功.)
好的设计通常是大胆的.历史上的每个时期,人们都会相信一些荒谬的东西, 而且是如此坚定, 你得冒着被排斥甚至暴力的风险说出不同的意见.
如果我们的时代有不同的话,真是太好了. 就我目前的观察,还没有.
这个问题不仅折磨着每个时代,而且某种程度上折磨着每个领域. 许多文艺复兴时期的作品在那个时代长期被认为是可怕的:根据Vasari的说法,Botticelli忏悔并放弃了绘画,Fra Bartolommeo和Lorenzo di Credi actually居然烧掉了部分作品. 爱因斯坦的相对论令许多同时代的物理学家感到不快, 几十年来没有被完全接受, 在法国,直到1950年代.
今天的实验性的错误是明天的理论. 如果你想发现伟大的新事物, 不该对传统智慧和理论不太涉及到的地方视而不见, 而要特别地注意它们.
作为特例,我认为看见丑陋要比想象出美丽容易. 大多数创造出美丽事物的人是通过修改他们觉得丑陋的地方来达到目标的. 伟大的作品往往是这样产生的: 某人看到某物并想, 我可以做得比这好. 乔托(Giotto)看到传统的按公式刻画出来的圣母像让几个世纪的人们感到满意,但他却觉得看上去笨拙和不自然. 哥白尼为一个同时代人普遍接受的理论深深苦恼, 觉得一定有更好的解决办法.
不能忍受丑陋还不够. 在发展出知道哪儿需要修改的嗅觉之前, 你得对该领域非常理解. 你得埋头苦干. 你成为专家之后, 你会听到内心的声音: What a hack! 一定会有更好的办法. 不要忽略这种声音,培养它们. 伟大作品的秘决是: 非常准确的鉴赏力加上能使它满足的能力.


原注
Sullivan 实际上说的是: 形式永远跟随功能. (form ever follows function.) 不过我认为这个不准确的引用更接近现代主义建筑师的意思.
Stephen G. Brush, "Why was Relativity Accepted?" Phys. Perspect. 1 (1999) 184-214.

YouTube允许日本版权所有人通过盗版创收

新浪科技讯 北京时间11月26日消息,据国外媒体报道,YouTube日前与一个由日本23家最大的电视广播商和版权机构组成的联盟签署了一项许可协议,并表示用户上传的版权内容并非是一种威胁。两年前,该联盟曾谴责YouTube放任用户上传盗版内容。
YouTube表示,部署的一项新技术能够识别用户上传内容的版权所有人,为内容合作伙伴带来收入。YouTube负责内容合作业务的副总裁大卫·埃文(David Eun)在东京举行的一次新闻发布会上阐述了YouTube的商业计划,称将重点解决创收问题。
YouTube利用视频内容创收计划的核心是Content ID,该系统首先扫描用户上传的视频内容,然后与由版权人提供的参考视频数据库进行比对。埃文说,“这一技术将继续得到改进,但它的表现已经令我们相当吃惊了。”
在发现盗版内容后,内容提供商有三种选择:封杀盗版内容;跟踪盗版内容,了解哪些用户在何时观看了盗版内容;在盗版内容中插播广告获得收入。埃文表示,目前已经有约300家合作伙伴使用了Content ID,在约90%的情况下他们会选择插播广告。
埃文称,“在被观看次数最多的视频内容中,被合作伙伴声称拥有版权的用户上传内容多于合作伙伴自己上传的内容。对于一些合作伙伴而言,内容的被观看次数因此而增长了50倍,不但会提高广告收入,还使他们能够更了解用户喜欢哪些类型的内容。”
YouTube还在试验视频内置广告。埃文表示,试验表明,按点进率计算,视频内置广告的有效性比标准显示广告高8-10倍。
过去两年中,YouTube在日本的地位得到了巩固。日本已经成为YouTube最大的海外市场。

Discuz!源代码分析[模板使用include template(discuz)]:./include/template.func.php

本帖不仅仅是分析文件,还把Discuz中模板解析这一原理分析了一下。转自www.discuz.net 作者:郭鑫
我记得我刚开始学PHP的时候,对模板解析实在是觉得很奇怪,不知道这个原理怎么实现的,后来看书看多了也明白有一个著名的Smarty在那,曾经也用过一段,不过感觉不是很好,就开始分析Discuz的模板技术是怎么实现的了,然后我把这个模板解析的代码分离出来了,觉得很好用,用了一段时间, Discuz的模板解析是用正则表达式替换一些模板中的规定的语言标记,然后呢,写到forumdata/templates中,再用include引用到index, forumdisplay等等中,和smarty的原理基本上相同,只是功能没有smarty那么多,smarty内建了一个cache来着…连个 User Guide都几百页…
  呵呵,不过现在基本上两个都没用过,正则表达式好是好用,不过正则的效率不是很高,以前看PHP技术文档的时候说能不用正则就尽量不要用,那东西烦着,现在做什么项目基本上用的是框架,MVC的模式,View中的代码一般不用模板解析出来,混杂php代码在里面,也觉得不错,OOP的开发效率比较高,很多地方重用代码是很开心的~!
  Discuz的模板解析要分析出来只要用到两个文件:./include/global.func.php和. /include/template.func.php,global只要一个函数就够了,template要全部的文件下面我就分开讲一下,会比较详细,大家耐心看:
Section One--./include/global.func.php---->template function

这个函数一共有三个传入参数:
$file 表示模板名
$templateid 表示模板id
$tpldir 表示模板目录

这个是把$tplrefresh作为一个全局变量,tplrefresh表示是不是刷新模板

$tpldir和$templateid赋值,如果没有传进来就用常量TPLDIR和TEMPLATEID给它们值

这里是把$tplfile(表示的是模板文件)和$objfile(表示的是要编译成的文件)赋值

防止TEMPLATEID不等于1且$templateid不等于1,而且模板文件不存在导致空白问题。
这里也可以算一个迭代,也可以不算,就是把1作为第二个参数再调用函数本身。

很巧妙的一段,Discuz的模板缓存就体现在这里,如果你没打开模板刷新的话(config.inc.php->$tplrefresh=0),这里就直接返回一个$objfile了,而这个文件是你第一次建论坛的时候就写入的,如果你不改模板的话,关了是能提高相当一部分效率的!反之,如果你打开了模板刷新的话就接着判断是不是模板文件的建立时间大于 forumdata/templates下的文件,是的话就引用./include/template.func.php写入模板文件到 forumdata/templates中,否则的话还是直接返回一个已经编译好的模板文件。
关于template.func.php文件中函数的分析在下面:

如何快速的呈现我们的网页

一、我们需达解决的麻烦

  • 减少HTTP请求数. 减少HTTP请求数有什么好处
    • 降低服务器跟客户端的建立和消除HTTP请求和响应Header的开销
    • 减少服务器为HTTP连接的进程和线程的开销,如果可能,还会包括GZIP压缩的CPU开销.
  • 减小被请求文件大小, 减少请求数据占用的网络带宽.
  • 让用户更快的看到想要的结果.
  • 提高客户端渲染速度.
  • 让浏览器同时能请求更多的数据.
  • 提高服务器相应速度.
  • 通过版本化控制客户端Cache.

二、如何解决我们的麻烦
A.如何减少HTTP请求数

  1. 合并JS文件跟CSS文件。
  2. 合并框架图片以及相对变动较少的图片成一张,通过CSS背景切割来完成渲染,比如:加速图片显示
  3. 合理使用本地Cache来缓存JS/CSS/IMAGE。
  4. 合理使用UserData缓存JS文件,对于FF用户可以单独请求服务器,这样能解决80%用户的问题.代码可以蓉儿(meizz)的js framework1(标注1)。
  5. 把JS跟CSS合并成一个文件

B.减小被请求文件大小,减少请求数据占用的网络带宽

  1. 压缩JS体积:删除JS中空白换行,注释,混淆把长变量换成短变量;
  2. 压缩CSS体积:删除CSS注释、写法尽量用简写;
  3. 使用(X)HTML+CSS方式搭建网站结构,提高CSS重用性,来减少(X)HTML文件大小;
  4. 使用服务器端GZIP压缩JS/ CSS文件,缩小传输文件大小。附注:Apache1跟Apache2的GZIP的效率跟方式不一样的,根据需要自行选择。
    嗷嗷补充说明:压缩、合并JS和CSS都由程序处理。而不是自己手动去缩删,不然不利于后期维护。

C.让用户更快的看到想要的结果
用户对于一个站点的白页的忍受时间根据统计是8-12秒。白页的产生可能由于各种原因引起,我们能做的就是怎么让用户能变的稍微能等待更久。

  1. 方案1:多做一个引导页,让用户体会其中的变化
    案例:mail.aol.com中的loading引导页
  2. 方案2:优先载入页面结构以及结构图片,后一步载入当前页面数据,再后一步载入Iframe,Flash等数据.让用户尽早的看到被打开页面的希望.

D.提高客户端渲染速度
这个问题就比较泛泛了,影响客户端的渲染速度有多方面的,主要目的都是提高程序方面的效率.

  1. 对于大索引的结构,尽可能的少用索引访问,能用访问兄弟节点的方式尽可能用访问兄弟节点的方式.
  2. 字符串拼接尽可能用数组方式
  3. 大规模添加节点数据,请不要使用appendChild方式,尽量使用类似innerHTML的insertAdjacentHTML方式,FF下需修正(标注1)

E.让浏览器同时能请求更多的数据.
浏览器默认只是支持单域名同时有两个HTTP请求,使用多域名将能把请求数提高,在网络条件优良的情况下,能更快的下载数据,呈现结果.
F.提高服务器相应速度
对于需快速响应的文件,把其放入快速响应的服务器,应该是不错的方案,优化方案请系统储备组提供.
G.通过版本化控制客户端Cache
通常js/css这类文件改动比较频繁,但是为了加载速度变快,我们有可能需要设定这类文件的过期时间为几天后,这样我们碰到的问题就是,如何及时更新这些在cache的文件?
通过一个简单的配置,通过修改JS的版本来及时告诉浏览器,这些文件必须重新请求了,不要继续使用浏览器cache中的数据. 方案有好几个:

  1. 手动改这些js的文件名
  2. 手动改这些js的路径
  3. 通过URL Rewrite方式来改重定位js路径
  4. 通过一个在高响应服务器上的一个js配置告知页面,这个页面该链接哪些JS文件
  5. 大版本不变,小版本不断追加,等一定时间后,统一更新,高效利用cache

标注

  1. meizz的js framework还没出正式版,有兴趣在CSDN的页面翻一下
  2. Firefox修正方式

转载于:http://www.blueidea.com/tech/site/2007/4822.asp

[转]关于大家问的uc开发手册不能同步登陆问题

最近在做一个整合 UCenter 的项目,下载了一份 uc开发手册,测试结果是这样的:
通过uch 登陆 可以同步登陆到论坛,但是不能登陆到 ucexample_1.php 和 2 这个开发手册自带的例子中。
但是通过ucexample_1.php 和 2 的例子登陆是可以登陆到 uch 和 论坛的
所有都是在配置正确的前提下进行,在 uc管理中的 应用管理 通信是要成功的。
那么问题是如何出现的呢?
看一下 api/uc.php
99-110行

  1. //同步登录 API 接口
  2. include './include/db_mysql.class.php';
  3. $db = new dbstuff;
  4. $db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
  5. unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
  6. $uid = intval($get['uid']);
  7. $query = $db->query("SELECT uid, username FROM {$tablepre}members WHERE uid='$uid'");
  8. if($member = $db->fetch_array($query)) {
  9. header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
  10. dsetcookie('Example_auth', authcode($member['uid']."\t".$member['username'], 'ENCODE'), 86400 * 365);
  11. }

复制代码

你会发现是一个读取数据库的操作,读取到才能设置咱们自己应用的 cookies 的
那么样例中似乎说的是要连接到自己的数据库中,可想如果咱们自己的数据库没有会员数据那么就登陆不成功了,所以解决办法就是读取uc自己的数据库!
在 app 的 config.inc.php 中
21-28行,不要看提示说是设置自己的,咱们直接设置 uc 的数据库

  1. //ucexample_2.php 用到的应用程序数据库连接参数
  2. $dbhost = 'localhost';                        // 数据库服务器
  3. $dbuser = 'root';                        // 数据库用户
  4. $dbpw = '';                                // 数据库密码
  5. $dbname = 'uc';                        // 数据库名
  6. $pconnect = 0;                                // 数据库持久连接 0=关闭, 1=打开
  7. $tablepre = 'uc_';                   // 表名前缀, 同一数据库安装多个论坛请修改此处
  8. $dbcharset = 'gbk';                        // MySQL 字符集, 可选 'gbk', 'big5', 'utf8', 'latin1', 留空为按照论坛字符集设定

然后你在测试一下,通过论坛 uch登陆 也可以直接同步登陆到 示例的应用中了!
转自:http://www.discuz.net/viewthread.php?tid=1043330&extra=page%3D1&frombbs=1

CHKDSK(磁盘检测)命令的运用

CHKDSK命令可检查磁盘状态并显示状态报告,还能修正磁盘错误。
  状态报告显示MS-DOS文件系统中的逻辑错误,该文件系统由文件分配表(FAT)和目录组成(CHKDSK不验证文件中的信息能否准确读出)。如果磁盘有错误,CHKDSK便会给出一条警告信息。所以,应不时地用CHKDSK来检查一下磁盘有无错误,以保证系统的正常运行。
  一、CHKDSK命令的语法
  CHKDSK drive:[[path]filename][/F][/V]
  若要显示当前驱动器的磁盘状态,可用命令:
  CHKDSK
  二、CHKDSK命令的参数解释
  (1)drive
  指定要用CHKDSK检查的磁盘所在的驱动器。
  (2)[path]filename
  指定要用CHKDSK进行碎片检查的一个或一组文件的路径及名称,可用通配符(*或?)指定多上文件。
  三、CHKDSK命令的开关项
  (1)/F
  修正磁盘错误。需要注意的是从其它应用程序(如Windows等)运行CHKDSK时不要选此项。
  (2)/V
  磁盘检查时,显示每个目录下的文件。
  四、帮助信息的获取
  如果不知道CHKDSK命令的用法也没关系,在DOS下随时打入CHKDSK/?便可了解其用法。
  五、关于CHKDSK命令的注释
  (1)状态报告的形式
  MS-DOS按类似下列的形式显示CHKDSK的状态报告:
  Volume MS-DOS_6 created 07-16-1996 10:40a
  Volume Serial Number is 2111-59F0
  629,424,128 bytes total disk space
  638,976 bytes in 15 hidden files
  1,146,880 bytes in 70 directories
  120,766,464 bytes in 1,802 user files
  506,871,808 bytes available on disk
  (2)修正磁盘错误
  在修正磁盘错误时,最好使用ScanDisk程序。详细信息可以参阅(SCANDISK)命令。用CHKDSK/F命令修正磁盘错误的显示信息如下:
  10 lost allocation units found 3 chains
  convert lost chains to files?
  若按下Y,MS-DOS把每个丢失的链在根目录中以FILEnnnn .CHK形式的文件名存放文件,nnnn是从0000开始的数字。CHKDSK检查结束后,可以检查一下这些文件是否含有所需要的数据,如果有就可以对其进行编辑后使用,否则便可将其全部删除,以免占用磁盘空间。若选N,MS-DOS只修正磁盘,但不保存丢失的分配单元的内容。
  如果不用/F开关项,CHKDSK将出示信息提醒用户是否文件需要修正恢复,但不进行实际的错误修正工作。
  (3)ERRORLEVER参数
  若CHKDSK没有找到任何错误,则返回到ERRORLEVER的值为0。如果找到了一个或多个错误,返回时ERRORLEVER的值为255。
  六、使用CHKDSK命令的注意事项
  (1)系统存在打开的文件时
  当有文件打开时请不要使用CHKDSK。因为CHKDSK是假定磁盘文件处于关闭状态而设计的。当有文件打开时,相应的MS-DOS将会修改文件分配表和目录结构。这种改变并不一定立即进行,文件分配表和目录结构的改变发生在不同时刻。因此如果磁盘上文件打开时运行CHKDSK,就会把目录结构和文件分配表的不一致解释为出错,从而导致数据丢失或文件系统的破坏。因此,在运行其它程序,如Microsoft Windows时,千万不要运行CHKDSK。
  (2)CHKDSK不能用于分配的驱动器和网络。
  CHKDSK不能用于由SUBST命令形成的驱动器工作,也不能用于网络驱动器上的磁盘检查。
  (3)物理磁盘错误
  CHKDSK命令只能找到文件系统中的逻辑错误,而不能查找物理磁盘错误。要查找物理磁盘错误,请使用SCANDISK程序。
  (4)坏磁盘扇区
  CHKDSK报告中将坏扇区标记上“bad”,SCANDISK和其它物理磁盘错误修正程序也将坏扇区标记为“bad”,因此坏扇区不会造成危害。
  (5)交叉链接的文件
  如果有两个文件或目录共用同一磁盘空间的记录,CHKDSK会报告有交叉链接文件。如果CHKDSK发现有交叉链接文件存在,会显示类似如下信息:
   is cross linked on allocation unit
  CHKDSK不会修补交叉链接文件,即使指定了/F项。要修复交叉链接文件,需要运行SCANDISK程序,或者进行手工修复,然后复制到指定的文件中并删除原文件。
  七、应用实例
  (1)将CHKDSK的状态报告存入文件
  可将CHKDSK状态报告重定向输出到一文件中保存,但注意重定向CHKDSK输出到文件时,不要使用/F开关项。例如:将CHKDSK检查的信息输出到CHK.LIS文件中,其命令为:
  C:\DOS>CHKDSK A:>CHK.LIS。
  (2)若检查C盘存储多少数据,还有多少剩余空间并修正磁盘错误,可输入如下命令:
  CHKDSK C:
  当遇到错误时,CHKDSK会暂停并提示信息。
  (3)查找文件
  利用CHKDSK与FIND命令结合管道功能实现在全盘的文件查找,这一命令格式不仅可以列出所查找文件的所在目录,而且还可以列出各目录中的同名文件,连隐含文件也不例外。值得注意的是使用本命令之前,应先用CHKDSK/F参数修正磁盘错误。例如在C盘上查找README文件,其命令格式如下:
  C:>CHKDSK/VIFIND “README”

隐藏IE横向滚动条

在以前的HTML标准下,要隐藏横向滚动条,只需要在CSS里加上
Body
{
overflow-x:hidden;
}
但是在现在的标准下"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"下面,上面的代码不产生任何效果,因为现在不是以Body作为容器,而是html标签,所以
加入:
HTML
{
overflow-x:hidden;
}
但是这样做了以后,在IE7下,鼠标滚轮上下滚动不起作用了,IE6下却是正常的。多加上一行代码就解决问题了
HTML
{
overflow-x:hidden;
overflow-y:auto;
}

全面解决Generic host process for win32 services遇到问题需要关闭

解决WINXP系统开机后弹出Generic host process for win32 services 遇到问题需要关闭!
出现上面这个错误一般有三种情况。
1.就是病毒。开机后会提示Generic Host Process for Win32 Services 遇到问题需要
关闭”“Remote Rrocedure Call (RPC)服务意外终止,然后就自动重起电脑。一般该病毒会在注册表HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft \Windows\CurrentVersion\Run 下建立msblast.exe键值,还会在c:\windows\system32目录下会放置一个msblast.exe的木马程,解决方案如下:
RPC漏洞
详细描述:
最近发现部分RPC在使用TCP/IP协议处理信息交换时不正确的处理畸形的消息导致存在一个安全漏洞。该漏洞影响使用RPC的DCOM接口,这个接口用来处理由客户端机器发送给服务器的DCOM对象激活请求(如UNC路径)。如果攻击者成功利用了该漏洞将获得本地系统权限,他将可以在系统上运行任意命令,如安装程序、查看或更改、删除数据或者是建立系统管理员权限的帐户等.
已发现的一个攻击现象:
攻击者在用户注册表HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion \Run 下建立一个叫“msupdate”(估计有变化)的键,键值一般为msblast.exeC:\windows\system32目录下会放置一个 msblast.exe的木马程序.
另外受攻击者会出现“Generic Host Process for Win32 Services 遇到问题需要关闭”“Remote Rrocedure Call (RPC)服务意外终止,Windows必须立即重新启动”等错误信息而重启。
建议到http://www.microsoft.com/security/security_bulletins/ms03-026.asp下载相应补丁。如果已受攻击,建议先拔掉网线,在任务管理器中结束msblast.exe进程,清除注册表中的相应条目,删除system32下的木马程序,最后打补丁。
第二种情况是排除病毒后,还出现这样的问题,一般都是IE组件在注册表中注册信息被破坏,可以按下面的方法去解决该问题:
1。 在"开始"菜单中打开"运行"窗口,在其中输入"regsvr32 actxprxy.dll",然后"确定",接着会出现一个信息对话 框"DllRegisterServer in actxprxy.dll succeeded",再次点击"确定"。
   2 再次打开"运行"窗口,输入"regsvr32 shdocvw.dll
   3 再次打开"运行"窗口,输入"regsvr32 oleaut32.dll
   4 再次打开"运行"窗口,输入"regsvr32 actxprxy.dll
   5 再次打开"运行"窗口,输入"regsvr32 mshtml.dll
   6 再次打开"运行"窗口,输入"regsvr32 msjava.dll
   7 再次打开"运行"窗口,输入"regsvr32 browseui.dll
   8 再次打开"运行"窗口,输入"regsvr32 urlmon.dll
如果排除病毒问题后,做完上面的几个IE组件注册一般问题即可得到解决。
3.如果电脑有打印机,还可能是因为打印机驱动安装错误,也会造成这个错误。解决方法如下:
重装打印机驱动程序。
一般情况下做到上面三步后,该问题即可得到全面解决。

揭开SVCHOST.exe进程之谜

svchost.exe是nt核心系统的非常重要的进程,对于2000、xp来说,不可或缺。很多病毒、木马也会调用它。所以,深入了解这个程序,是玩电脑的必修课之一。
  大家对windows操作系统一定不陌生,但你是否注意到系统中“svchost.exe”这个文件呢?细心的朋友会发现windows中存在多个 “svchost”进程(通过“ctrl+alt+del”键打开任务管理器,这里的“进程”标签中就可看到了),为什么会这样呢?下面就来揭开它神秘的面纱。
发现
  在基于nt内核的windows操作系统家族中,不同版本的windows系统,存在不同数量的“svchost”进程,用户使用“任务管理器 ”可查看其进程数目。一般来说,win2000有两个svchost进程,winxp中则有四个或四个以上的svchost进程(以后看到系统中有多个这种进程,千万别立即判定系统有病毒了哟),而win2003 server中则更多。这些svchost进程提供很多系统服务,如:rpcss服务(remote procedure call)、dmserver服务(logical disk manager)、dhcp服务(dhcp client)等。
  如果要了解每个svchost进程到底提供了多少系统服务,可以在win2000的命令提示符窗口中输入“tlist -s”命令来查看,该命令是win2000 support tools提供的。在winxp则使用“tasklist /svc”命令。
svchost中可以包含多个服务
深入
  windows系统进程分为独立进程和共享进程两种,“svchost.exe”文件存在于“%systemroot% system32”目录下,它属于共享进程。随着windows系统服务不断增多,为了节省系统资源,微软把很多服务做成共享方式,交由 svchost.exe进程来启动。但svchost进程只作为服务宿主,并不能实现任何服务功能,即它只能提供条件让其他服务在这里被启动,而它自己却不能给用户提供任何服务。那这些服务是如何实现的呢?
  原来这些系统服务是以动态链接库(dll)形式实现的,它们把可执行程序指向 svchost,由svchost调用相应服务的动态链接库来启动服务。那svchost又怎么知道某个系统服务该调用哪个动态链接库呢?这是通过系统服务在注册表中设置的参数来实现。下面就以rpcss(remote procedure call)服务为例,进行讲解。
  从启动参数中可见服务是靠svchost来启动的。
实例
  以windows xp为例,点击“开始”/“运行”,输入“services.msc”命令,弹出服务对话框,然后打开“remote procedure call”属性对话框,可以看到rpcss服务的可执行文件的路径为“c:\windows\system32\svchost -k rpcss”,这说明rpcss服务是依靠svchost调用“rpcss”参数来实现的,而参数的内容则是存放在系统注册表中的。
  在运行对话框中输入“regedit.exe”后回车,打开注册表编辑器,找到[hkey_local_machine systemcurrentcontrolsetservicesrpcss]项,找到类型为“reg_expand_sz”的键“magepath”,其键值为“%systemroot%system32svchost -k rpcss”(这就是在服务窗口中看到的服务启动命令),另外在“parameters”子项中有个名为“servicedll”的键,其值为“% systemroot%system32rpcss.dll”,其中“rpcss.dll”就是rpcss服务要使用的动态链接库文件。这样 svchost进程通过读取“rpcss”服务注册表信息,就能启动该服务了。
解惑
  因为svchost进程启动各种服务,所以病毒、木马也想尽办法来利用它,企图利用它的特性来迷惑用户,达到感染、入侵、破坏的目的(如冲击波变种病毒“w32.welchia.worm”)。但windows系统存在多个svchost进程是很正常的,在受感染的机器中到底哪个是病毒进程呢?这里仅举一例来说明。
  假设windows xp系统被“w32.welchia.worm”感染了。正常的svchost文件存在于“c:\windows\system32”目录下,如果发现该文件出现在其他目录下就要小心了。“w32.welchia.worm”病毒存在于“c:\windows\system32wins”目录中,因此使用进程管理器查看svchost进程的执行文件路径就很容易发现系统是否感染了病毒。windows系统自带的任务管理器不能够查看进程的路径,可以使用第三方进程管理软件,如“windows优化大师”进程管理器,通过这些工具就可很容易地查看到所有的svchost进程的执行文件路径,一旦发现其执行路径为不平常的位置就应该马上进行检测和处理。
  由于篇幅的关系,不能对svchost全部功能进行详细介绍,这是一个windows中的一个特殊进程,有兴趣的可参考有关技术资料进一步去了解它。