All posts in Technique

Grid Archives 1.7.0

As indicated in the comment here (thanks to Paul for the detailed information), there is a cache issue in Grid Archives 1.6.0 and above.

Version 1.7.0 addresses this issue so now you can have multiple instances/pages of grid archives running and showing different categories at the same time.

No screenshots available in this update since it’s just a cache fix, but I may add an option to enable/disable cache in the future release of Grid Archives. We will definitely have screenshots at that time for sure So, stay tuned~

[ChangeLog]

  • fixed the cache issue
  • make the plugin compatible with wordpress 3.6

For more detailed information, please visit the plugin home page or click here to check out the live demo.

并不是只有代码才要注释

如题,多年失修的music player其实也需要啦……

今晚缘起一哥们告知豆瓣旧版api将要停摆的噩耗,竟然重拾起了平日里难得有的兴致;不过最后豆瓣的东西由于各种主观客观原因还是没搞成,但为了不浪费这满腔的激情和突然爆发的小宇宙 i,遂动手给music player加了那很久前便想加却从来有各种理由搪塞拖拉的功能。

遥想当年,老泪纵横。

这是一个改革创新的季节 ii,所以用实际行动来响应号召绝对是政治不错误的;我,是一个极其谨慎的人,你懂的…

[Footnotes]
  1. 还没有第七感,不过 []
  2. 任何名词前面套上一个“新型”便可以开始“哗众取宠”了,这样的好处是再一个release的时候把“新型”去掉便又可以开始忽悠了;这个过程可以形象的用苹果 ipad -> new ipad -> ipad 的轮回过程来类比 []

Multiple line support in SublimeTask

[废话]
鄙人新一年有个小计划,那便是需要开始protect起自己的private personal time,过去的一年因为工作牺牲了太多的个人时间,这样的策略抑或无奈是物有所值还是得不偿失需要被重新审视和评估;

==================== 废话的分割线 ====================

[Introduction]
Check out this introductory post if you don’t know what is SublimeTask.

[Overview]
Let’s keep it simple and short this time, since it’s very late now :(.

As issue #3 indicated, previous version of SublimeTask lacks the feature of multiple line support, this update just addressed this issue and addressed it well.

2 kinds of multiple types are now supported:

  • Multiple selections (hold ⌘ during multiple selections, one key fancy feature of Sublime Text)
  • One selection with multiple lines (this should be self explanatory)

So from now on you should be able to mark multiple tasks as completed/incomplete in just one shot, enjoy!
Continue reading →

YUI3: Creating a Module with Dependencies

前文类似,本文为译文,相关事宜同前文。

[问题]
你想要创建一个自定义的YUI模块并确保它会把另外一个YUI模块作为依赖加载。

[解决办法]
使用YUI.add()方法注册你的code作为一个YUI全局对象(YUI global object)的一个模块,注册的过程中把模块的依赖作为配置对象传给它。在模块名字和定义之后,YUI.add()还接收两个可选的参数:

  • 一个模块的字符串形式的版本数字。这是你的模块的版本号,并不是你的模块所兼容的YUI版本。
  • 一个包含模块metadata的配置对象。目前这个配置对象(configuration object)里面最常见的field是一个叫requires的array,它列出了该模块的所有依赖。对里面所列出的每个模块,YUI会自动在需要的时候加载它们,必要的时候会远程的加载。

下面的例子对前文例子做了修改。Y.Hello.sayHello()不在返回一个字符串值,而是改变一个单个Y.Node的内容。这个hello模块定义了一个node-base的依赖,来确保调用hello模块的时候node.setHTML()是存在并可用的。
Continue reading →

YUI3: Creating Your Own Modules

本文节选翻译自YUI3 Cookbook,翻译的目的是force自己focus看完,因为最近实在过于焦躁不安心神不宁;好了废话不多说,我们开始,因为可能牵涉到版权问题,所以恕不能同时附上英文原文。水平有限,如有错误皆是本人认知问题,与原文无关。

[问题]
你需要以YUI模块的形式来包装并复用你的code。

[解决办法]
使用YUI.add()方法把你的code注册成为YUI全局对象(YUI global object)的一个模块。最少需要给YUI.add()提供:

  • 一个模块的名字。习惯上,YUI模块的名字一般为小写字母,使用hyphens(-)分割;
  • 一个实际定义模块代码的回调函数(callback function)。可以通过把这个component定义到Y对象上的方法来expose这个模块的相关属性或方法。

一旦YUI.add()执行完毕,你便可以像其它任何YUI模块一样来使用你自己的代码。下面的例子里面i,模块定义之后紧接着的就是YUI().use(),它会加载模块以及其依赖,并在回调函数里面执行其模块方法。

< !DOCTYPE html>
<title>Creating and using a Hello World module</title>
<div id="demo"></div>
<script type="text/javascript" src="http://yui.yahooapis.com/3.8.0/build/yui/yui-min.js"></script><script type="text/javascript">
  YUI.add('hello', function (Y) {
    Y.namespace('Hello');
    Y.Hello.sayHello = function () {
      return 'GREETINGS PROGRAMS';
    };
  });
  YUI().use('node-base', 'hello', function (Y) {
    Y.one('#demo').setHTML(Y.Hello.sayHello());
  });
</script>

为了避免命名冲突,你可以使用Y.namespace()来创造一个“Hello”的namespace作为这个sayHello()方法的命名空间。Y.namespace()是个方便实用的工具,虽然这里例出的例子非常简单,本质上等同于:

Y.Hello = {};
注:上面这个例子只展现出最基本的创建模块的代码block。这个example对于构建真正可复用的code并不足够。真实世界里面的模块需要定义依赖和其它metadata,且它们通常会被定义在另外独立的文件中。

Continue reading →

[Footnotes]
  1. 译者改成了使用yui3最新版:3.8.0 []

mac之永远的flash cpu问题

这是一个mac上永远存在却永远不得解决的问题,全部归责于adobe似乎又有点不近人情因为毕竟人家在windows上performance据说还是可以的,于是有人会去总结windows和osx的系统design,因为据说osx因为某种安全机制的全局考虑不允许这不允许那,apple限制这限制那也不是新闻,所以总而言之这是个一个巴掌拍不响的勾当。

于是乔布斯两年前开始另辟蹊径釜底抽薪,这就是我们所知的html5。不过不知道是雷声大雨点小还是本人一向的懒惰以致孤陋寡闻,虽然对国内很多视频网站早就支持html5有所耳闻 i,但至今各大网站的各种视频页面的右击结果却还是深深的带着flash的胎记,于是接踵而至的就是cpu high了,fan开始转了,人转而就down了,你们都懂的。

抱怨不是本文要做的事情,事实上跟我以往update跑题千里无疾而终的习惯类似上面两段亦是我原计划外的废话,但是有时候写下标题后你就发现有些话你没办法憋着,这几年的浪荡让我发现要show自己的talk往往是件不难的事情,难的确反而是可以不talk;
Continue reading →

[Footnotes]
  1. 要不还就还只是支持mobile device,抑或各种lab各种beta []

Highlight URL in SublimeTask

[Redirection]
Check out this introductory post if you don’t know what is SublimeTask.

[Overview]
As this issue ticket indicated, people want the url (http, https, ftp etc) to be processed and displayed differently in SublimeTask.

Although opening url link in default browser is possible and actually turns out to be fairly simple, I still haven’t fully made my mind whether I want this functionality goes in or not, cuz it sounds like a separate project/plugin. Anyway, it’s really a nice-to-have feature, I will be glad to add this in in the future, either directly built in or as a separate plugin.

In this update/patch, what I did is just highlighting the url. One screenshot should be enough to tell the whole story.

[Screenshot]

Note all the url above are highlighted.

[Customization]
As always, check out the “Customization” section here should you need to customize the url display style.

Grid Archives 1.6.0

As requested, this major release mainly address one issue/feature that grid archives should actually support in the very beginning, the sort direction option.

Before 1.6.0, all the posts are sorted in descending order by default and there seems to be no easy way to change this… but that pain will be history now, starting from now

To be compatible with previous versions, the default sort direction will remain as ‘desc’, so if you still want the month/post to be displayed in the descending order, as you wish.. you’re required to do nothing~ yay!

[ChangeLog]

  • added an option to change the post sort direction (asec or desc)
  • make the plugin compatible with wordpress 3.4

As always, please visit the plugin home page for more details and click here to check out the live demo.

Vim-Task 1.1

Thanks to tUrG0n, vim-task won’t suffer from the pathogen issue anymore from now on, and we also have a new feature which will prepend a “-” for a non-task line when toggling the task status.

So by toggling the task status, we’re now actually toggling between 3 statuses of the task:

  • blank: normal text
  • pending: –
  • completed: ✓

all with the same 1 keyboard shortcut as before, as always. So neat!

PS: Vim native regex i is pretty awkward to work with, unless you use some additional features ii, the regex will quickly become a mess, which maybe makes the person who reads your code thinks “wow, how complicated the regex is!”, but actually the truth is always: “well, it’s not, it’s just that ugly, man…”

[Footnotes]
  1. to make the script portable, substitute() method will always use the ‘magic’ option in the regex match []
  2. but we don’t want more dependencies though… []

Hubot Deployment

Speaking of slowing down process, install one hubot robot in your chat room is definitely one good practice. As they said:

It will dramatically improve and reduce employee efficiency.

I generally believe that it will just improve the efficiency… dramatically.. lol

While I finish the hubot deployment last week i, I was planning to wrap up and compose a deployment guide, but turns out there’s already an excellent one on the web, so I won’t bother to reinvent the wheel:

https://github.com/github/hubot/wiki/Deploying-Hubot-onto-UNIX

[Footnotes]
  1. actually it was a move from my little tiny box to a stronger one []