Skip to content

Instantly share code, notes, and snippets.

View tjwudi's full-sized avatar

Di Wu tjwudi

View GitHub Profile
@tjwudi
tjwudi / LimeAPI.js
Last active August 29, 2015 14:04
LimeJS often-used APIs
// 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
@tjwudi
tjwudi / highlight-jekyll-linenos
Created May 9, 2014 17:39
highlight-jekyll-linenos
{% highlight ruby linenos %}
def foo
puts 'foo'
end
{% endhighlight %}
@tjwudi
tjwudi / highlight-jekyll.txt
Created May 9, 2014 17:33
highlight-jekyll
{% highlight ruby %}
def foo
puts 'foo'
end
{% endhighlight %}
@tjwudi
tjwudi / c_program_opt.md
Last active February 16, 2017 15:16
计算机系统结构课程学习报告

基于计算机体系结构的C程序性能优化

摘要

本文主要介绍如何从计算机体系结构的角度,利用计算机系统的硬件特点来优化软件代码。本文采用C语言进行样例的描述,但是在大多数其他的编程语言中也能够适用。
首先,我们将阐述为何需要从计算机体系结构的角度进行程序优化。接着,我们抽象出了从计算机体系结构的角度分析性能问题的模式。然后,我们将了解几种被广泛应用在各种体系结构上的,基于体系结构的程序性能优化方式,并将改进前后的性能进行对比。最后,我们将综合所有在文中谈到的程序性能优化方式,一同探讨如何进行进一步的优化。

程序性能优化的两个大方向

尽管本文主要阐述程序性能优化,但是我们还是必须首先支出,编写程序的主要目标就是编写出可用的程序,而非高效的程序。我们所做的一切优化,都应该是在写出正确、可交付的程序的基础上。也就是说,可用性是程序性能优化的地基。
在建立好地基后,我们就可以思考让我们的程序运行得更加快速。一般而言,程序性能优化有两个大方向:

  1. 选择更合适的算法以及数据结构
  2. 让编译器或者解释器能够更好对你的代码进行优化
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) + "&";

List all databases

sp_helpdb

Check the current database name

select d.name 
from master..sysdatabases d, master..sysprocesses p 
where d.dbid=p.dbid and p.spid=@@spid

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

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
@tjwudi
tjwudi / hamming_code.js
Last active February 8, 2016 08:01
Communication subsystem (simulation) using Hamming code
// needs async library support
var
async = require('async');
(function lifeCycle(){
var
workflow = {
body : [],
end : function() {},
util : {},