August 14th, 2006 by 张磊
今天智勇一上来,就和我说,帮我要google的T恤了——还说,Google那边的人说他们在招人,然后老头子就说我还没上大二呢:(。不过,前半句话足够让我坐在椅子上smile like a puppy ——这个过程大概持续了一刻钟。
后来,在tulip的要求下,我开始想办法解决论坛上支付宝购买财富的问题。phpwind上面有一个解决的思路,弄下来之后发现,居然是直接打款。这个想解决自动加财富是真的不容易。不由得怀疑,API改变了?支付宝该不会做这种傻事——我就又找来API看看,哦,原来是phpwind上那个人水平不到家。我参照了一下,半小时就搞定了。顺便自己用10块钱试了一下,呵呵
这两件事真的比较爽啊。而且对于Alipay的API,我阴差阳错几乎都看完了,呵呵,一边还在和蜗牛MM聊天,真好,真美妙。
August 13th, 2006 by 张磊
在学HASH映射,以前一直都不懂的,现在看了看,明白是明白了,但不知道能用来干啥。
写插入函数有个关键问题,两个键hash到同一个值时怎么办?书上给出了两种解决办法:1、使用链表;2、”open addressing”(I want to know how to make a translation for my in book I can only find English)。在open addressing下面还有三种方法,一个是挨个找空的value,一个是用可变的步长找空的value,还有一个是再做一次hashing(Double Hashing)。
还有一个叫rehashing的东西,是为了解决HashTable容量太小而做的。思路其实很简单,如果表的空间快用完,就把表容量扩大一下,把原来的键hash到新的表里。这个方法在上学期老师做字符串的时候,就用到过,可以看作成一种普遍的思路。
以前看Google黑板报里一篇blog,说HASH的存储效率只有50%左右(我都不知道怎么算的)。不过我似乎有了些看书的方法。刚拿到的专业书往往是看不进去的,尤其是英文,在书桌上放得久了,有了感情,看起来就很容易了,呵呵。我以前看《Foundations of AJAX》是这样,现在看《Data Structures and Algorithm Analysis in C》也是这样。
August 13th, 2006 by 张磊
这几天上网的时间很少,在看一部叫《关中女人》的电视剧。这个周末,黑龙江电视台很够意思,从上午到下午一直在放,我们一家四口围着电视机,过瘾阿。刚刚看完了大结局,心里头乱糟糟的。
土匪不都是坏蛋,土匪头子是文化人。姓何的司令杀了姓田的土匪,然后自己老婆被土匪害死了。何家凌辱了金家的爷们三个,结果自家祖坟被挖了。金老汉杀了田川拿了何家的秘方,生意好了起来,大儿子却坐不了男人了,后来女主角荷花和小叔子有了孩子。孩子,土匪抱走了何家的男孩,金家捡了何家的女孩,金老汉还养上了田川的儿子,最后被这个孩子逼死了。荷花含辛茹苦把三个孩子养大,自己的亲生儿子却认贼作父,最后不仅要杀姐姐,还杀了自己的亲生父亲。
荷花,一个女人啊,杀了沦落为烟鬼的丈夫,又在最后一集杀死了自己亲儿子。自己的血肉,18年的辛劳,就在两枪之后化为乌有。荷花是个硬气的女人,她拿枪指着金老汉来保护自己的孩子,她强迫何中余为自己的公公跪行送葬——她什么样的苦难都经历过了,最后去做了尼姑。
这部电视剧越到后面,越让人分辨不清对和错。现实总是这么无奈,也绝对不会有”the prince and princess have a happiness life ever after“的故事。金老汉说得好,得失是世间最大的学问。我想很多时候,我们要的不是判断,而是权衡。但至少,在原则问题上,没有权衡的余地。
《关中女人》 真好看,就是看了让人不舒服。
August 12th, 2006 by 张磊
这一段陆续做了两个输出JS的程序。其实做得多了,觉得也无非就是那么回事。去年这个时候,馒头让我在blog侧栏放上他的一段JS,那是不懂编程的我从HACKER的角度看了看,愣是没看明白。转眼做了半年有余的PHP,现在做一个输出JS的东西简直太容易了。
echo “document.write(\”XXXXXXX\”);”;
当年觉得那么奥妙的东西,不过如此简单。技术本身就是这么简单的东西,容易入门,容易上手,容易学成——但终究有那么多人说,“我要学编程!”,然后拼命在讨论XXX语言是不是比XXX好。C++的高手断然不是只会写C++。技术永远都是简单却繁琐,真正要学的东西,是我们驾驭这些技术的能力。
做一个广告,http://www.buyren.net/shop.php要升级了,采用dianping的数据库,礼品卡信息实时更新——相信会焕发出新的活力。只是我不知道智勇对我做的是不是满意。
August 12th, 2006 by 张磊
这里不是“博客”的“博”,而是“博士”的“博”。
上学期一次《法律基础》课上,方建中老师劝我们男生,如果可以,还是“博”一下,这样以后的生活可以好一点。Hoho,他自己在读浙大的博士,现在说不定在法国了。昨天晚上看CLY的blog,她说她的父母都是DR.,如果她不读一个博士出来,父母肯定不满意。今天和ZL聊天,不知怎么就说起了这档子事,她说,她毕业了会去考个硕士研究生,出来再去读博士——奋斗完了,就快30了。
博,还是不博?
也许这个问题现在更多的版本是,读研or not?
说心里话,我现在都不知道考上研究生上去学什么、做什么。学习么?我们在大学四年所学的东西应该让我们很快就能掌握新知识、新技术——如果你不行,最好反思一下大学四年做了些什么。科研么?这是一个冠冕堂皇理由,但出来工作一样是为我们的社会创造价值。中国的牛人最多想到了IFrame,国外的牛人用没啥新技术可是倍儿优秀的AJAX。中国的科研搞得真的让人失望,但我们看到的黑幕,也许还是冰山一角。剩下一个在民间流传甚广的理由,读研可以给自己镀镀金,以后找工作容易点——在咱们国内,学历至上也不是一年两年的事了,这是一个没有over educated理论的国家。顺便给国外找不上工作的Dr.们提个建议,到中国来吧,这里有你们想要的一切。靠读研镀金本身就是动机不纯,这样读出来,也未必比人家本科生强到哪里。
上个学期之前,我写blog说,该决定是不是将来读研了。对我来说,读研无异于一件Boring&&Pointless的事情。李开复到Google时说,I need to follow my heart——我不去读研了,除非是出国。因为在出国这件事情上,我曾经那么欢喜地憧憬过,又曾那么坚决地放弃过。如果以后还有机会,我还想试试。我没有生在一个富裕的家庭,我家的经济条件堪堪让我简单地活在杭州,如果真的出去,一切都靠自己——想来,也非常刺激。
所有人都劝我读研——孤独便是这样的,所有人都关心你,但没有人了解你。
August 11th, 2006 by 张磊
下午一上来,智勇就让我看论坛。原来是服务器更换机房——但智勇在提示页上做了我们几个blog的链接。这导致了我今天流量的零头居然比昨天还多,我这个高兴啊,但突然就想,会不会超流量?冷汗一下就冒了出来。
晚上吃了口饭,论坛还没好。我随手给自己的blog侧栏加上了一个“热评文章”(其实评论最多的也只有4条),然后在单篇文章页面里加了一个随机显示文章的功能(模仿了Livid,他的blog每篇文章下面有一个”Looking around”)。今天我的同学给我留言说打开blog时候遇到的问题,左边因为Adsense一直不能显示,弄得中间也显示不了。唉,没想到居然不可以修改,我有把Adsense撤掉的欲望了。可是到了Adsense里面,发现今天居然有钱了……
August 11th, 2006 by 张磊
Recently Zhejiang is suffering from a typhoon, And the situation is really disappionting. So I’m worry about my teachers as well as serveral friends. Sounding funny , a little brother of mine will start his trip to Hangzhou in few days .Oh, God bless him.
Man can never beat the nature. So where there is environmental damage ,there is natural disasters. Considering this , I prefer to live in a small town than in a big city like Hangzhou. As a matter of fact , my hometown is small but quiet , plus , there’s neither typhoon nor earthquake althrough the year.
Chinese people have suffered too much this summer.
August 11th, 2006 by 张磊
做了那么多难看的网页,却从来没有系统地学习过CSS。这几天在看的《Ajax in Action》把做web的各个方面都讲到了,自然也包括CSS。感觉学起来并不困难,只是这也和flash一样——你可以用一个下午学会Flash的技法,却花费一个月也很难做出漂亮的动画。
A style rule consists of two parts: the selector and the style declaration. The selector
specifies which elements are going to be styled, and the style declaration declares which style properties are going to be applied. Let’s say that we want to make all our level-1 headings in a document (that is, thetags) appear red. We can declare a CSS rule to do this:
h1 { color: red }.
CSS selectors
In addition to defining a type of HTML tag to apply a style to, we can limit the rule to those within a specific context. There are several ways of specifying the context: by HTML tag type, by a declared class type, or by an element’s unique ID. Let’s look at tag-type selectors first. For example, to apply the above rule only to tags that are contained within a tag, we would modify our rule like this:
div h1 { color: red; }
These are also referred to as element-based selectors, because they decide whether or not a DOM element is styled based on its element type. We can also define classes for styling that have nothing to do with the HTML tag type. For example, if we define a style class called callout, which is to appear in a colored box, we could write
.callout { border: solid blue 1px; background-color: cyan }
To assign a style class to an element, we simply declare a class attribute in the HTML tag, such as
I’ll appear as a normal bit of text
And I’ll appear as a callout!
Elements can be assigned more than one class. Suppose that we define an additional style class loud as
.loud { color: orange }
and apply both the styles in a document like so:
I’ll be bright orange
I’ll appear as a callout
And I’ll appear as an unappealing mixture of both!
The third element will appear with orange text in a cyan box with a blue border. It is also possible to combine CSS styles to create a pleasing and harmonious design!
We can combine classes with element-based rules, to define a class that operates
only on particular tag types. For example:
span.highlight { background-color: yellow }
will be applied only to tags with a declared class attribute of highlight. Other tags, or other types of tag with class=’highlight’, will be unaffected. We can also use these in conjunction with the parent-child selectors to create very specific rules:
div.prose span.highlight { background-color: yellow }
This rule will be applied only to tags of class highlight that are nested within tags of class prose.
We can specify rules that apply only to an element with a given unique ID, as specified by the id attribute in the HTML. No more than one element in an HTML document should have a given ID assigned to it, so these selectors are typically used to select a single element on a page. To draw attention to a close button on a page, for example, we might define a style:
#close { color: red }
CSS also allows us to define styles based on pseudo-selectors. A web browser defines a limited number of pseudo-selectors. We’ll present a few of the more useful ones here. For example:
*:first-letter {
font-size: 500%;
color: red;
float: left;
}
will draw the first letter of any element in a large bold red font. We can tighten up this rule a little, like this:
p.illuminated:first-letter {
font-size: 500%;
color: red;
float: left;
}
The red border effect will now apply only toelements with a declared class of illuminated. Other useful pseudo-selectors include first-line, and hover, which modifies the appearance of hyperlinks when the mouse pointer passes over them. For example, to make a link appear in yellow when under the mouse pointer, we could write the following rule:
a:hover{ color:yellow; }
That covers the bases for CSS selectors.
CSS style properties
Every element in an HTML page can be styled in a number of ways. The most generic elements, such as the tag, can have dozens of stylings applied to them. Let’s look briefly at a few of these.
The text of an element can be styled in terms of the color, the font size, the heaviness of the font, and the typeface to use. Multiple options can be specified for fonts, to allow graceful degradation in situations where a desired font is not installed on a client machine. To style a paragraph in gray, terminal-style text, we could define a styling:
.robotic{
font-size: 14pt;
font-family: courier new, courier, monospace;
font-weight: bold;
color: gray;
}
Or, more concisely, we could amalgamate the font elements:
.robotic{
font: bold 14pt courier new, courier, monospace;
color: gray;
}
In either case, the multiple styling properties are written in a key-value pair notation, separated by semicolons. CSS can define the layout and size (often referred to as the box-model) of an element, by specifying margins and padding elements, either for all four sides or for each side individually:
.padded{ padding: 4px; }
.eccentricPadded {
padding-bottom: 8px;
padding-top: 2px;
padding-left: 2px;
padding-right: 16px;
margin: 1px;
}
The dimensions of an element can be specified by the width and height properties. The position of an element can be specified as either absolute or relative. Absolutely positioned elements can be positioned on the page by setting the top and left properties, whereas relatively positioned elements will flow with the rest of the page.
Background colors can be set to elements using the background-color property. In addition, a background image can be set, using the background-image property:
.titlebar{ background-image: url(images/topbar.png); }
Elements can be hidden from view by setting either visibility:hidden or display:none. In the former case, the item will still occupy space on the page, if relatively positioned, whereas in the latter case, it won’t.
This covers the basic styling properties required to construct user interfaces for Ajax applications using CSS. In the following section, we’ll look at an example of putting CSS into practice.
From: 《Ajax in Action》
August 10th, 2006 by 张磊
On WebDeveloper.com , the board about PHP is the hottest one. But in college , I’ll never learn about PHP except study all by myself. However , there’s only a single course about dynamic web for us , and we can study very little ASP there.
So where is PHP now? Did it disappear? I have to admit that Windows server systems are easy to use as well as desktop systems , yet PHP , based mainly on Linux and Unix , is faster and safer. what’s worse , most of the open sourse software are disliked by our education. I want to know how can I get familiar with Linux , Apache , or Mysql. Maybe the only way is to explore by myself.
Now I can use PHP –this good script language freely , but a lot of my classmates even do not know what PHP is . Unknow is worse than fail. In a word , on the way to open sourse , there’s still a long way.
August 10th, 2006 by 张磊
暑假之前,我曾打算将店评好好完善一次。但计划总是赶不上变化,中间发生的一系列事情让我渐渐远离了店评。我就要重新开始做了,以前的版本总是有不如意的地方——因为那时候自己技术远没有现在成熟,写东西的思路现在看也比较简单。我好好地做了一番思想斗争,还是觉得应该重新做,把程序的底层结构打好,以后进行开发也容易。
现在的店评有些缺点,首先是界面不好看(我美工真的不行啊);其次后台管理虽然很方便,但是增加新功能的时候比较难;我觉得比较严重的是,那时候开发建立在phpwind基础上,网页的结构很不好,比如没有独立的css文件,这些都是亟待改进的。其实现在面向论坛会员的这个版本不是最新的版本,那时候我做的新版本根没有得到看的时间,放在服务器上,现在服务器也重装了。
其实店评后来做的东西里面,开发的风格已经大不一样了。最后做的活动那块,我算是比较满意的。现在重做,不知道要做多久。