2008年8月29日星期五

Add Paypal checkout for Spree

The RailsEnvy guys begin their own casts business---Envycast .They used the Spree to build the site, and allow customer checkout by Paypal.
Some days ago, I use Spree in a site.I think it's better than substruct,because it's more simple and extendable. I also needed to integrate Paypal to it, but some thing make me confused.
1) There are many ways to integrate Paypal, and many articles introduced these ways.First you need to know which way would you like to use? I used Website Payments Standard , if you don't use this way, this article maybe not help you.

2) For test it, you need signup a develop account,then use this account to create a buyer account, and a seller account.

3) When you test your application, you must login the develop account.

4) install the Spree Paypal extension , this extension isn't mature, but can be used.

5) change the extension's default account and some urls to your own

5)there are some html field the paypal server can accept, you need to find what you would like to use.

2008年8月22日星期五

rails crop image use paperclip and jquery

More and more sites begin to allow user to crop their avatar.
After some time google, I haven't found a easy way to implement this in rails use jquery and paperclip.
So I think maybe this article is helpful.

First I install a jquery plugin imaareaselect , it works well.

I add it in the view,
 
<% content_for :head do %>
<%= javascript_include_tag 'jquery-areaselect' %>
<% javascript_tag do -%>
$(window).load(function () { $('#duck').imgAreaSelect({ x1: 120, y1: 90, x2: 280, y2: 210, onSelectEnd: set_crop });
});
function set_crop(img, selection){
$('#crop_left').val(selection.x1)
$('#crop_top').val(selection.y1)
$('#crop_width').val(selection.width)
$('#crop_height').val(selection.height)
}
<% end -%>
<% end %>


and these lines in a form

 

<%= hidden_field_tag "crop_left", "0" %>


<%= hidden_field_tag "crop_top", "0" %>


<%= hidden_field_tag "crop_width", "1" %>


<%= hidden_field_tag "crop_height", "1" %>



<%= image_tag current_user.photo.url(:large), :id => "duck" %>


then I write some codes in a moudle, this is the file:


I will extract this as a paperclip extention later. In fact, you can this with prototype too.

2008年8月9日星期六

Todo on MAC

Im not a 'getting things done' fan,but sometimes TODO list is necessary.You know, the fun of TODO list is writing it, not implement it.
I found two useful tools on Mac, Tasks bundle of Textmate and evernote .

Tasks bundle is pretty simple, but useful. when you install the bundle, then it is there.
The Tasks grammar and commands by default apply to files with the .todo, .todolist and .tasks extensions.

There is a littel problem, the default hotkey use ⌅, which sometimes make you confused.
so I just changed it in the bundle editor, this is the easist way to fix this.For more info,you need to read the original article.

Evernote is another amazing software,it allows you to easily capture information in any environment using whatever device or platform you find most convenient, and makes this information accessible and searchable at any time, from anywhere.

when you find some useful pictures or web pages, Evernote is a great tool to store them and write some note for them.


2008年8月7日星期四

四年前

四年前的现在,我正在享受上学以来最悠长美妙的一个假期。我试图沿着残留的记忆追溯回去,但来时的路已然模糊。我只记得我们玩得很开心,在故乡的我们,很少会有压抑的时候。
四年过去了,我没有长高,也没有变胖,没有什么可以赢得掌声的事在我身上发生。幸好我不是那种不赢得聚光灯就无法快乐的人,我希望我可以享受自己的生活。享受不算健壮但还很是健康的身体,享受编程,每一次刷新浏览器看到新页面时的成就感,享受对音乐,对阅读,对体育活动的热爱,享受有限的全家人呆在一起的假期,享受总给我带来烦恼但总让我独自傻笑的木头,享受我的小黄猫(我知道我很对不起你),享受我家的小白狗和她的我未曾谋面的小黑狗孩子。享受我选择做自己的网站的勇气,我知道,也许我不会成功,但我想,带给你们一点我创造的东西。
我不知道我能不能让你们快乐,但我真的想那么做。

2008年8月2日星期六

下一个腾讯?

我接触电脑是从初中时开始。和大多同学一样,电脑游戏成了我的新大陆。到现在仍然念念不忘当年玩游戏的激情澎湃,感叹现在有了自己的电脑,但再无当初的热情了。
我接触网络是从初三开始。和大多同学一样,qq让我惊诧于网络的魅力。那时候我们以为聊qq就是上网的全部。
时至今日,我从事了互联网行业, 也可以拍着胸脯讲自己是半个互联网人了。我几乎天天都要上网,有比牛毛多的web2.的网站我也注册了比牛毛多的帐号。国外的网站界面大都很美观舒服,功能也有特别之处,我试着把他们介绍给我的同学,但大家似乎都不怎么感冒。我想原因很简单,因为上面没几个和我们有关的人。
如果你有机会去网吧看看,你会明白为什么你觉得很酷的网站用户很少的原因了。上网对大多数中国网民来说就是聊qq,六七年前是这样,六七年后似乎还是这样。当然大家多了一个选择叫网络游戏。这个情况让我失望了很长时间,我希望我们都能多一点geek精神,但这仅仅是个希望。
最近的一俩个月情况有点改变(多少有那么一点)。我突然发现我的同学们似乎都在使用一个网站,地球人都知道,我就不给出链接了。这个网站我是去年十月份注册的,那时候我的大学同学有一部分已经开始使用这个网站了,我不知道那个时候它的用户量是多大,但到了现在,我觉得可能它的用户量增长了能有一倍。因为我的高中,初中,甚至小学同学都开始现身了。衡量一个站点的影响力,可以去网吧观察,看人们在打开ie后第一个登录的网站是什么。我确实这样做了,我以我并不是完全善意的眼光去观察,发现有不少人开机后做了俩件事,一曰上qq,一曰上校内。
我不是说校内会成为下一个qq,但校内确实成为了qq之后又一个让你不能忽视的东西。不能忽视的意思就是你周围的大多数人都向你说起过这个东西,你感觉这的却是个时髦又有些用处的东西。我也不是说校内会不成为下一个qq,现在我们确实不像原来那样重视qq了。互联网越来越普及,人们的选择越来越多。几年前有几个人想到开网店,网上购物,到现在我的很多一直呆在县城里的同学都开始托我网上买点东西。腾讯也发布了自己的sns,但我们可以肯定它不会威胁到校内的。
我还想说的是中国的sns市场竞争是不已经结束了,真得没有机会去和校内扳手腕了?事实上这不是一个问题。互联网是一片充满奇迹的土地,任何成功在它实现以前都是一件不可能的事。如果你做一个网站总是要考虑已经有了那些‘大家伙’,你的网站该如何立足的话,那么你还不具有互联网的创业精神。
话说回来,什么样的sns可以和校内叫板?我自己认为,太酷的不行,功能太花哨的不行,没新意的不行。在中国互联网混,一定要有草根精神,明白用户真正需要的是什么,不能看了国外的酷站眼光就高了。也不能想当然,觉得这么好的功能一推出肯定火,事实上喜欢尝试新东西的人不多,而且你的新功能也许并没有你想象中的那么好。至于新意嘛,在一个已经有人做大了的市场里推出新产品,总是要有点不一样的东西,有个词叫做差异化竞争。你不能指望那些去网吧上网的人也和你一样有空申请那么多帐号只是为了进去看看是个什么网站。

最后表达一下我对豆瓣和土豆的敬意。他们坚持自己的东西,用优秀的产品,优秀的服务来吸引人,而不是用那些无聊,污染视觉的东西壮大声势。事实上,只要你的产品足够好,就不怕没人用。