2009年3月28日星期六

www.liageren.com 给我们俩的礼物

好长时间没有在这里写,以后也很难保证会再上来。

如果大家有机会看到这里的话,我向大家推介我的站点 www.liageren.com(俩个人)。

希望你能喜欢 :)

2008年10月10日星期五

gitx,不得不推介了

在mac上用git的人们也许有过和我一样的不爽,本来git自带的gitk是个不错的工具,可以方便的查看所有提交的痕迹。但可惜gitk是用gtk写的,在mac下界面很不友好,功能大打折扣。
但我们这个世界上总有一些人有着崇高的情怀来面对生活,并随手就写下一个gitx造福人类。引用作者的介绍
# What is GitX?

GitX is a gitk like clone written specifically for OS X Leopard and higher.
This means that it has a native interface and tries to integrate with the
operating system as good as possible. Examples of this are drag and drop
support and QuickLook support.

项目的wiki上写着很清楚的安装及使用方法,但要注意这一点
After you have started it once, you can install the command-line tool
through the menu (GitX->Enable Terminal Usage…). This will install a
“gitx” binary in /usr/bin.
安装后,在git项目的根目录下输入gitx:







2008年10月8日星期三

十月的雨

国庆回了家,虽然是请假回去的。国庆于我意义不大,我似乎天天都在假期中,但回家就不一样了。我上大学后还没有在秋天回过家。以前到这个时候,我在校园里就会想家乡那边人们在忙什么,割麦子,起山药,拔菜籽,打苍蝇。这个时候已经有点冷了,人们穿着线衣,线裤,满脸堆笑的老农们,满脸堆笑的老农们站在晴朗的天空下拿着爬犁或者拿着铁锹或者其他什么工具,他们的手里总会拿着工具的。在早上阵阵的寒意里,在下午徐徐的暖风中。
但事实证明四年的时间让我的记忆出现了偏差,回家的前俩天天气好的很,接着俩天下起了雨。我没看到麦子,没看到老农,只看到了苍蝇,于是痛痛快快感受了一把当年一下打死七个的雄风。现在我们的小镇大不如从前景象,人走的越来越多,街道越来越破,今年很多人种了胡萝卜,但似乎收成也一般,只剩下苍蝇们还依旧生机盎然,成群结队。不对,还有漫街边巷的小狗,现在大家治安不靠狗了,那些个大饭量也大的big guy都换成了小毛犬,每天争斗于剩饭剩菜旁,make love于光天化日下,不避老幼男女。
行文至此,BTV6正在直播的“利物浦vs曼城”是高潮一波又一波,曼城上半场进了俩个,下半场由被扳回三个。这是红军的专长,所以利物浦球迷是幸福的。相比之下我们国米球迷气短了很多,荡气回肠的球很长时间与国米无关了。
这篇文章的题目是我很喜欢的俩首歌的结合,October, November Rain.



2008年9月22日星期一

JQuery: Drag Drop Sort

updated: add the html,

this is the html,


    <% @pages.each do |p| %>
  • ">
    <%= p.title %>
    <% if p.has_children? %>
      ">
      <% p.children.each do |c| %>
    • " class="sortable_submenu"><%= c.title %>

    • <% end -%>

    <% end -%>

  • <% end -%>


if you know the rails, it is easy :) .

--------------------------------------------------------------------------------------------------------------------------------

I need a "Drag Drop Sort " tree in my project. I found some jquery plugins, but all of them seems can't solve my problem, so I decided to solve it use JQuery UI.
All I need are 'jquery-ui-core', 'jquery-draggable', 'jquery-droppable','jquery-sortable',
these you can download from JQuery site.
Then some code like this:


$(".assets li").draggable({
helper: 'clone'
});
$(".drop").droppable({
accept: ".drag",
activeClass: 'droppable-active',
hoverClass: 'droppable-hover',
drop: function(ev, ui){
var drag = ui.draggable;
drag.appendTo($(this).siblings('ul.assets'))
$.ajax({
dataType: "script",
type: "PUT",
url: url,
data: "asset[category_id]=" + $(this).attr('id')
});
}
});
$("#sort").sortable({
items: '.sortable',
stop: function(e, ui){
var data = $(this).sortable("serialize")
$.ajax({
url: "/back/pages/sort",
type: "POST",
data: data,
dataType: "script"
});
}
});



The code is simple, there are some useful callbacks you can use, like start, stop, drop..., you can find them in the doc.

In the sort, this function "$(this).sortable("serialize") " will return the sort result.It works by default by looking at the id of each item in the format 'setname_number', and it spits out a hash like "setname[]=number&setname[]=number".

So do you think JQuery is amazing? Let's Rock!

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.