GitHub for Windows 万物复苏

23 May 2012

经历了太多的等待,GitHub 终于诞下了 Windows 版,有平板触摸的感觉,欢喜^^

GitHub for Windows 是一个100%的本地应用,可以运行在 Windows XP, Vista, 7, pre-release Windows 8。应用中包括完整的 msysGit 安装,使其成为在 Windows 上使用 Git 的不二选择。

Discover, Create and Share

GitHub for Windows is the easiest way to manage your repositories on GitHub.com. Clone your repositories right from the app or clone directly from GitHub.com with the new Clone in Windows button.

Browse commits, create new ones. Roll back changes or revert them entirely.

Find and check out branches.

Create and publish branches. Merge and delete them.

Seamless Install and Automatic Updates.

We provide a no questions asked install experience and silent, automated updates that install in the background.

>>原文出处
>>下载地址 (安装需要 .Net Framework 4, 在线下载, ssh会重新自动安装)


Jekyll in Windows 终极奥义

15 Mar 2012

Install msysGit

Download Wget for Windows

Wget("World Wide Web"和"Get"的结合)是一个在网络上进行下载的简单而强大的自由软件,此为 Windows 版本,只需下载 wget.exe 文件后放在 C:\windows 下即可在任何位置调用 wget 命令

Install Ruby

Jekyll requires Ruby 1.9.1 or higher

Install Python

1 $ cd /f
2 # setuptools does not work with Python 3.2
3 $ wget -nc python.org/ftp/python/2.7.2/python-2.7.2.msi
4 $ msiexec -qn -i python-2.7.2.amd64.msi ADDLOCAL="DefaultFeature"

Install Pygments

1 # Install setuptools 
2 $ wget -nc peak.telecommunity.com/dist/ez_setup.py
3 $ ./ez_setup.py
4 # Pygments
5 $ easy_install Pygments

Install RedCloth

1 $ gem install RedCloth

Install Jekyll

1 $ gem install jekyll

Install GSL libraries

1 $ wget 'ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz'
2 $ tar xf gsl*
3 $ cd gsl*
4 $ ./configure
5 # Warning, make takes about 7 min.
6 $ make
7 $ make install
  • github.com/mojombo/jekyll/issues/376
  • github.com/romanbsd/rb-gsl/issues/2

Install Ruby/GSL

 1 # "gem install gsl" does not work. If you try it you are going to need to
 2 # delete from "Ruby193/lib/ruby/gems/1.9.1/gems" before you can continue.
 3 # rb-gsl.rubyforge.org version has to be patched to support GSL 1.15.
 4 $ wget --content-disposition --no-check-certificate \
 5 $ github.com/romanbsd/rb-gsl/tarball/master
 6 $ tar xf romanbsd-rb-gsl*
 7 $ cd romanbsd-rb-gsl*
 8 $ ruby setup.rb config
 9 $ ruby setup.rb setup
10 $ ruby setup.rb install
  • github.com/romanbsd/rb-gsl

Google+ 按钮添加 and CNZZ 站长统计

19 Feb 2012

Google+

想必你已经在很多网站上面见到过 Google+1 的按钮了,下面就在你的博客中也加入吧:

首先登录 Google+1 按钮页面,然后按照提示选择样式和设定高级功能,最后将代码粘贴到指定位置即可。

Problem

使用 Google+1 后网站打开速度变慢了,Google+1 按钮总要等上数秒甚至是数十秒才能读取完毕出现在页面里,下面是 Aaron Peters 给出的优化意见:

  • 一定不要把那段 Javascript 代码放在 <head> 标签里,这样会拖慢整个网页的打开速度。最好是将其放在 </body> 之前,这样页面可以完全打开,之后再等待+1按钮慢慢读取。其实 Google 如果再上心点,做成类似 AdSens e和 Google Analytics 那种非阻塞形式的JS代码就更快了。
  • Aaron 发现 Google 的 Javascript 代码只允许浏览器缓存6分钟,这其实也导致了我们再次打开网页时候速度依然快不起来。 Aaron 还发现 Google 提供的代码有个小瑕疵,其中的 http://apis.google.com/js/plusone.js 应该改成 https 链接,否则浏览器会做一次自动跳转,又耽误了一点时间。
  • Aaron 建议在 Google 改进之前,这么来写 Google +1 的代码能快一点:
    
    <!-- Place this tag just before your close body tag -->
    <script>
        (function(d, t) {
        var g = d.createElement(t),
        s = d.getElementsByTagName(t)[0];
        g.async = true;
        g.src = 'https://apis.google.com/js/plusone.js';
        s.parentNode.insertBefore(g, s);
        })(document, 'script');
    </script>
    <!-- Place this tag where you want the +1 button to render -->
        <g:plusone></g:plusone>
    

CNZZ

每天打开博客,发现都是静悄悄的,除了通过评论来引起你的注意外,一切都是浮云。因此,CNZZ站长统计的必要性就体现出来了,注册并添加网址,操作非常简单。

CNZZ 提供样式代码展示:文字样式 or 图片样式。可以选择任意一种样式代码放到你网页的尾部

如果你使用的是谷歌浏览器,并且还开启了 AdBlock 去广告插件,那么你就看不到上面的小东东了^..^


Jekyll 本地调试之若干问题

13 Feb 2012

没有看似简单的事,简单的开头后面往往都九曲十弯

为什么要用本地调试?其实应该反问自己,如果不用本地调试,将会多么麻烦,每每有改动想要调试着看看效果,都至少要 add, commit, push 三条命令上传到 github 服务器,说白了就两个字“麻烦”。

编译 Jekyll 编辑网站只需在根目录执行 jekyll 命令,下面的命令是 GitHub 更新网站所使用的默认指令。

1 $ jekyll --pygments --safe

现在执行这条命令,就会将整个网站创建在目录 _site 下。

如果没有安装 Apache 等 Web服务器,还可以使用 Jekyll 的内置 Web服务器。

1 $ jekyll --server --auto

默认在端口4000开启 Web服务器,访问 http://localhost:4000 即可。

下面是一些在 jekyll 运行时可能会出现的一些问题及解决方案:

Problem1 “When a Liquid exception is thrown by a post, the error-handling cannot call self.name”

在 lib/jekyll/post.rb 中补充上 name 即可。

Problem2 “Liquid error: incompatible character encodings: UTF-8 and IBM437”

这个问题是在 Windows 下出现的,英文博文没问题,中文博文就会报错,原因是你所使用的控制台并不能工作 UTF-8。

1. MyGit 控制台解决方案

  • 临时:在执行 jekyll 命令前,将当前控制台的代码格式转为 UTF-8:
1 $ export LC_ALL=en_US.UTF-8
2 $ export LANG=en_US.UTF-8
3 $ jekyll --server --auto
  • 永久:添加两对用户自定义的环境变量,LC_ALL=en_US.UTF-8 和 LANG=en_US.UTF-8

2. cmd 控制台解决方案

  • 临时:在执行 jekyll 命令前,将当前控制台的代码格式转为 UTF-8:
1 chcp 65001
2 jekyll --server --auto
  • 永久:将 chcp 命令和 jekyll 命令合并成一个 rake 任务,文件名就叫 rakefile,在 cmd 控制台执行 rake runwindows 即可。
    
    task :runwindows do
        puts '* Changing the codepage'
        `chcp 65001`
        puts '* Running Jekyll'
        `jekyll --server --auto`
    end
    

>>>Ruby 1.9 character encoding changes
>>>octopress在windows下出现的字符集错误
>>>Solving UTF problem with Jekyll on Windows

Problem3 “Ruby193/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/convertible.rb:29:in ‘read_yaml’: invalid byte sequence in GBK (ArgumentError)”

貌似是 jekyll 的一个 bug

将 convertible.rb 的第29行改为:
self.content = File.read(File.join(base, name), :encoding => “utf-8”)

>>>windows下git bash中执行jekyll —server出错,编码问题

Problem4 卡在"Running the classifier…this could take a while",无法即时调试

若要解释清楚此怪,还得从 Related posts 说起,这个相关博文的定位源于下面这个函数:

 1 # Calculate related posts.
 2 #
 3 # Returns [<Post>]
 4 def related_posts(posts)
 5   return [] unless posts.size > 1
 6   
 7   if Jekyll.lsi
 8     self.class.lsi ||= begin
 9       puts "Running the classifier... this could take a while."
10       lsi = Classifier::LSI.new
11       posts.each { |x| $stdout.print(".");$stdout.flush;lsi.add_item(x) }
12       puts ""
13       lsi
14     end
15 
16     related = self.class.lsi.find_related(self.content, 11)
17     related - [self]
18   else
19     (posts - [self])[0..9]
20   end
21 end

相信你已经发现了,这句"Running the classifier… this could take a while."就产自这里,分类器一直在工作,分出哪些是相关的博文,所以当你的博文数量很多的时候,这个分类的时间就会很长,可能永远处于Running状态(只限于本地调试的时间)。

注意上面紧接着出现了一个关键词 lsiJekyll Configuration 里面有对其的描述 “Produces an index for related posts(产生相关博文的索引)”,至此就知道了只要把 lsi 功能关掉即可。

在 _config.yml 可以找到对 lsi 的设置,直接删掉即可,默认是 lsi:false

>>>Latent semantic indexing

Problem5 “Liquid error: undefined method `join’for ……”

这好像是 Liquid 2.3.0 的一个 bug,通过还原2.2.2版本即可解决:

1 $ gem uninstall liquid
2 $ gem install liquid --version '2.2.2'

>>>Syntax Highlighting with Pygments is failing via Liquid Templates String Error

Problem6 “Liquid error: No such file or directory – pygmentize”


从改编说到穿越

29 Jan 2012

昨天在路边买了一本旧书《评书聊斋志异》,喜欢古典文学,喜欢旧书,喜欢评书,所以第一眼看到就觉定要买下它了。再者是为了丰富老爸的读书,就好那么几口,枉费我好几个书架的书……

回到家仔细擦拭了一下,发现这是一个系列书,是现代评书艺术家陈士和(1887-1995)根据《聊斋志异》而创作的口头文学。我以前是没有看过原版的聊斋的,看过的都是课本上、漫画上、电影、电视剧里的,熟悉的就那么几个经典的故事,例如画皮。

翻到目录 折狱 张鸿渐 红玉 ,都是好陌生的名字,最后一个是 聂小倩 ……等等,好像在哪里听到过,聂小倩,倩女幽魂,不就是那个电影嘛,最新版是刘亦菲主演的,难怪会眼熟,带着电影角色去看看原版是个怎样的故事。


<< Previous Page Next Page >>
Fork me on GitHub