被浪费

现在我国绝对不缺少食物,所以就开始浪费了?

我其实真的非常浪费,吃东西经常吃到一半就丢了。我在想为什么有些食物分量这么的足,但价钱也住住更贵。这里是不是有点什么关系?为了卖出更多的钞票,强制把食物的分量做多,最终让有些消费者“被浪费”了。也许由此可以想像到过多。

看看生产力吧

这几天心情有点沉重,在想一些今年的一些事情或者更早的时间吧。当回顾过去的时候,才发现原来还有些改变没有完成。2010年马上就要过去,而这年我又做了哪些改变,有些地方甚至很厌恶我自己。

当人无聊的时候,游戏可以帮助消耗时间。可问题是为什么你会无聊呢?在这段无聊的时间里,我花了很多的时间来玩网络对战游戏,游戏中你有所思,所以会让你忘记一些其它的事情,如不能自拔到是件是危险的事。在游戏消耗了大把的时间后,又为这些时间感到后悔,有时觉得这种事情很不靠谱。

在今年这段时间里,只有一半的时间在工作,其它的时间我都在为一个人工作,我是这么告诉他的。由于有些不靠谱的事情,导致了这段时间的生产力低下。不管是为谁工作,生产力是我在社会中所创造的价值。为什么一个有生产力的人,却不能创建出更多的价值,导致这种原来事情的所有理由都是借口、敷衍。值得庆幸的是,今年的基本任务是改进生产工具,从结果来看还是不错的,最在最重要的目标是让新的生产工具产生更有价值的生产力。

有些情况依然没有改变,这让我产生波动的机率仍然在增加。有些借口让自己无法去有效的改善这种情况。

唯有我们拥有天命。

悲郁之余

这几日甚是悲郁,被某个功能所难,此功能是必须实现之物,悲伤、郁闷。

已经浪费了几天的时间了,本来现在就像一个像样的。郁闷的时候找游戏和电视来解之,因此又有些时间莫名其妙的流走了。可悲、可郁。

最近做了一些时间管理的实践,特此分享一下。

我一般会使用简单的Todo List来记录一些工作内容,本人也没那么多的屁事。比如:Gmail中的工作表、iCal的待办事项。

在看过Lotus Notes 8.5.1 时间管理实践这篇文章后,我开始改进一些方法。所以文中的主角是Lotus Notes,但类似功能的软件还是很多的。文中对时间管理的理论实践讲的很好,建议有兴趣的同学可以仔细看看。

XMind是一款非常不错的思维脑图软件,基于Eclipse平台,相对于FreeMind画出来的图更为美观,并且Pro版也提供一些有用的服务,不过一般来说标准版就已经够用了。注意:这可是国人开发的产品,强力推荐。

iCal这个就不多说了,除了提供一般的日历软件功能后,在Mac OSX上计划任务也是通过这个定制的。使用Automator可以创建一些批处理任务,然后附加到iCal上从而实现计划任务。

以前我只关心哪一个工作任务完成没有,现在我更关心每一天我都做了些什么事。待办事项只有用来描述有哪些工作,或者完成与否。日历项则可以记录在什么时候完成某项工作,比如:在做某一待办事项的时候,直接将该待办事项拖动到日历中,就会生成一个日历项。方便。

附一个启动屏幕保护的Automator:

启动屏幕保护

双击以后启动屏保。

还是Firefox吧

本来在Mac下一直使用Safari,也用的挺好的。但是最有些Flash甚是吃CPU,所以简单的看了下Safari、Firefox、Chrome的Flash效率。测试页面为网易首页,呀的现在网易的广告多了。

结果是:Firefox 3.6 < Safari 5 < Firefox 4 Pre Beta 8 <= Chrome 8。我想这可能是与现在Mac版的Firefox 3.6处理插件的方式有关,后3者都已经分离了插件进程,但Mac版的Firefox 3.6还没有实现这点,记忆中Win是在3.6就实现了。但Firefox 4 Pre Beta 8已经采用了插件单独进程的处理方式,但据我使用情况来看,效率还行,但希望正式版能做的更好,总之,我对Firefox 4还是非常满意的。

模板语言是越傻越好

For years I’ve been absolutely certain that I really prefer stupid template languages any time I’m generating HTML. The less the template language can do the better. Since I spend most of my time coding in Python you might assume this applies just to Python, but I think it also applies to anything where you have the power to readily mix HTML generation and code.

The biggest annoyance I have with smart template languages (Mako, Genshi, Jinja2, PHP, PerlColdFusion, etc) is that you have the capability to mix core business logic with your end views, hence violating the rules of Model-View-Controller architecture. While the web can be hard to match to MVC, in general you aren’t supposed to do that sort of thing. I’ve made the mistake of putting core logic in the wrong places in the past, but I’m proud to say I’ve gotten good at avoiding that particular mistake.

I don’t work in a vacuum.

I often work on projects crafted by others, some who decided for arcane/brilliant/idiotic reasons to mix the kernel of their applications in template function/macros. This is only possible in Smart Template Languages! If they were using a Stupid Template Language they would have been forced put their kernel code in a Python file where it applies, not in a template that was supposed to just render HTML or XML or plain text.

What it comes down to is that Smart Template Languages designers assume that developers are smart enough to avoid making this mistake. Stupid Template Languages designers assume that developers generally lack the discipline to avoid creating horrific atrocities that because of unnecessary complexity have a bus factor of 1.

So what is a Smart Template Language?

In my own vernacular, template languages that let you write functions/macros are what I call a Smart Template Language. Some of them are brilliantly executed, the example of Jinja2 comes to mind, but invariably I suffer through abuse of its Macro control structure as implemented by others.

Misery Cubed a.k.a. Genius Template Languages

Next comes Genius Template Languages, which take things a step further. These template languages allow you to not only define functions/macros, but also let you embed unrestricted Python (or Java or Ruby or whatever) in the template. This ‘feature’ lets you code your entire application in the templates!  In the Python world what comes to mind is Mako and Genshi, but I’m sure there are many other tools with this ‘capability’.

I like Stupid Template Languages!

Stupid Template Languages don’t let you define functions/macros. They don’t let you embed Python code. They barely let you define variables and often have simplistic control architectures.

For Django efforts, which is about 70% of my work, I like the Django Template Language (DTL). Since it is used by a huge community, there are a ton of useful apps which have it as a dependency. Switching away from it would mean cutting myself off from a large ecosphere of tools I can use to not reinvent the wheel.

Back in my Zope/Plone days I really, really enjoyed the Template Attribute Language (TAL) because it was stupid too. If I needed an XML generation template language and could import it easily I might consider using it again, or perhaps Chameleon, which is a new, improved version . The downside is that they come paired with another tool paired with it, METAL, which gave it macros. My own experience with METAL is that it was all too easy to do what we developers do with Smart Template Languages.

But DTL and TAL are slow!

So what?

If you want to boost your performance, first try caching. There are a ton of tools you can use, with Varnish being one I keep seeing in action. Read the docs on your favorite web framework’s caching engine and apply what you learn. And Djangonauts should read up on Mike Malone as much as possible.

If after all that the site still delivers slow content and it appears to be a template language issue, then identify the bottleneck content and consider alternatives for that one portion. My favorite response is a bit of AJAX. Use your framework to render the content as JSON and have JavaScript parse it into legible content, a task which JQuery makes trivial.

From: http://pydanny.blogspot.com/2010/12/stupid-template-languages.html

修改NavigationController的后退按钮Action

有时候会需要在点击后退按钮的时候添加一些代码处理,但SDK并没有提供什么直接可用的方法。经过搜索,发现有一个比较好的方法可以解决这个问题,个人觉得自己设置一个后退按扭不怎么美观。

原理是重载UINavigationController的

– (UIViewController *)popViewControllerAnimated:(BOOL)animated

在这里添加一些处理代码,可以根据当前的Class来决定不同的处理方法。

原文:Custom action on Back Button UINavigationController