This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a director | |
director = new lime.Director(document.body, 1024, 768); | |
// Create a scene | |
scene = new lime.Scene(); | |
// Add a scene to director | |
director.replaceScene(scene); | |
// Schedule Manager Example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% highlight ruby linenos %} | |
def foo | |
puts 'foo' | |
end | |
{% endhighlight %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% highlight ruby %} | |
def foo | |
puts 'foo' | |
end | |
{% endhighlight %} |
本文主要介绍如何从计算机体系结构的角度,利用计算机系统的硬件特点来优化软件代码。本文采用C语言进行样例的描述,但是在大多数其他的编程语言中也能够适用。
首先,我们将阐述为何需要从计算机体系结构的角度进行程序优化。接着,我们抽象出了从计算机体系结构的角度分析性能问题的模式。然后,我们将了解几种被广泛应用在各种体系结构上的,基于体系结构的程序性能优化方式,并将改进前后的性能进行对比。最后,我们将综合所有在文中谈到的程序性能优化方式,一同探讨如何进行进一步的优化。
尽管本文主要阐述程序性能优化,但是我们还是必须首先支出,编写程序的主要目标就是编写出可用的程序,而非高效的程序。我们所做的一切优化,都应该是在写出正确、可交付的程序的基础上。也就是说,可用性是程序性能优化的地基。
在建立好地基后,我们就可以思考让我们的程序运行得更加快速。一般而言,程序性能优化有两个大方向:
- 选择更合适的算法以及数据结构
- 让编译器或者解释器能够更好对你的代码进行优化
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('App').config(function (RestangularProvider) { | |
// convert json request to x-www-form-urlencoded request | |
RestangularProvider.setFullRequestInterceptor(function (el, op, what, url) { | |
if (op === "put" || op === "post") { | |
var res = ""; | |
_.forOwn(el, function (v, k) { | |
if (!_.isFunction(v)) { | |
res += k + "=" + encodeURIComponent(v) + "&"; |
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateLikes < ActiveRecord::Migration | |
def change | |
create_table :likes do |t| | |
t.references :user, index: true | |
t.references :activity, index: true | |
t.timestamps | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// needs async library support | |
var | |
async = require('async'); | |
(function lifeCycle(){ | |
var | |
workflow = { | |
body : [], | |
end : function() {}, | |
util : {}, |