2014-05-16

解决MacBook拔出耳机后没有声音的问题

重新加载声卡驱动即可解决问题,方法如下:

sudo kextunload /System/Library/Extensions/AppleHDA.kext
sudo kextload /System/Library/Extensions/AppleHDA.kext 


Mac OS下编译安装GCC

1. 主要是按这篇文章的方法编译安装GCC 4.9.0

http://solarianprogrammer.com/2013/06/11/compiling-gcc-mac-os-x/

2. 安装到编译gcc时出错,提示 /usr/include 目录不存在,google之后才发现是因为只安装了xcode而没有安装 command line tools 的原因,执行以下命令安装:

xcode-select --install

3. 然后再按步骤继续编译,结果又有错误提示 Bootstrap comparison failure!

4. 尝试运行 make distclean 命令清理掉之前编译中间文件后重试。

5. 安装成功。

2013-11-23

B+ Tree implementation in Java

The most commonly implemented form of the B-Tree is the B+ Tree. The difference between them is that the internal nodes of B+ tree do not store records; they are used for navigation only.

Definition of B+ Tree
    A B+ Tree of order m has these properties:
    - The root is either a leaf or has at least two children;
    - Each internal node, except for the root, has between ⎡m/2and m children;
    - Internal nodes do not store record, only store key values to guild the search;
    - Each leaf node, has between ⎡m/2⎤ and m keys and values;
    - Leaf node store keys and records or pointers to records;
    - All leaves are at the same level in the tree, so the tree is always height balanced.

★ Algorithms

Search
  • Do binary search on keys in current node. 
    • When current node is a leaf node:
      • If search key is found, then return record.
      • If search key is not found, then report an unsuccessful search.
    • When current node is an internal node:
      • If search key < key_0, then repeat the search process on the first branch of current node.
      • If search key >= key_last, then repeat the search process on the last branch of current node.
      • Otherwise, find the first key_i >= key, and repeat the search process on the (i+1) branch of current node.
Insertion
  • Perform a search to determine which leaf node the new key should go into.
  • If the node is not full, insert the new key, done!
  • Otherwise, split the leaf node.
    • Allocate a new leaf node and move half keys to the new node.
    • Insert the new leaf's smallest key into the parent node.
    • If the parent is full, split it too, repeat the split process above until a parent is found that need not split.
    • If the root splits, create a new root which has one key and two children.
Deletion
  • Perform a search to determine which leaf node contains the key.
  • Remove the key from the leaf node.
    • If the leaf node is at least half-full, done!
    • If the leaf node as L is less than half-full:
      • Try to borrow a key from sibling node as S (adjacent node with same parent)
        • If S is L's left sibling, then borrow S's last key, and replace their parent navigate key with this borrowed key value.
        • If S is L's right sibling, then borrow S's first key, and replace their parent navigate key with S's second key value.
      • If can not borrow a key from sibling node, then merge L and sibling S
        • After merged L and S, delete their parent navigate key and proper child pointer.
        • Repeat the borrow or merge operation on parent node, perhaps propagate to root node and decrease the height of the tree.
Implementation


★ Source Code
Source code can be found at here.


2013-11-19

Install MonoDevelop under Mac OS X


  1. Download and install.
  2. Bug fix: ASP.NET MVC 3 missing System.Web.WebPages
  3. Bug fix: Access “/Library/Frameworks/Mono.framework/Versions/3.2.4/etc/mono/registry” is denied
    • sudo mkdir /Library/Frameworks/Mono.framework/Versions/3.2.4/etc/mono/registry
    • sudo chmod g+rwx /Library/Frameworks/Mono.framework/Versions/3.2.4/etc/mono/registry
    • solutions
  4. Bug fix: Specified version is "1.0.0.0", but the version in bin is "3.0.0.0".
    • Open Web.config, change the line  to 
    • solutions
  5. Bug fix: Storage scopes cannot be created when _AppStart is executing.
    • delete Microsoft.Web.Infrastructure.dll from references
    • solutions

Helpful links:

2013-10-08

Learning Vim 7.x : [1]

Abstracts from the chapter 1 and 2 of Learning vi and vim 7.0


2
3
4

Index of Machine Learning resources


Prerequisites
  • Linear Algebra
  • Statistics
  • Probability
  • Calculus - single and multi-variable and differential equations
  • Linear and convex optimization
  • Python, Java
  • Other programming knowledge

Online Courses

Books

2012-01-06

JavaScript高级程序设计读书摘要(一)

前七章:语言基础
  • JavaScript完整的实现: ECMAScript、DOM(Document Object Model)、BOM(Browser Object Model)
  • 数据类型:null、undefined、boolean、string、number、object、function
  • 字符串是值类型,且不可变
  • 函数参数:实际上为一数组,可通过 arguments 进行访问;函数调用时传参与函数声明无关;arguments.callee 指向当前的函数对象
  • JavaScript没有块级作用域,变量作用域最低层次为函数,故在两大括号代码段内声明的变量在该函数后续代码内仍可访问。
  • 数据的length属性不是只读的,可以通过设置该属性调整数组长度
  • 数组支持 push、pop、shift 等方法,从而可轻易实现栈和队列
  • Function 实际上是对象,函数名就是指向函数对象的指针,也可以理解为一变量
  • this 引用的是函数据以执行操作的对象,如果是在全局作用域下执行,则引用的是 window
  • 函数是对象,所以有属性(length、prototype、caller)和方法(apply、call)
  • 基本类型对应的包装类型:Boolean、Number、String
  • 在调用基本类型的方法或属性时,会创建基本类型对应的引用类型,然后销毁
  • 两个全局内置对象: Global、Math
  • JavaScript没有类和接口,但是支持OOP
  • JavaScript面向对象编程实际上就是利用Function是对象的特性而展开的
  • 对象的prototype相当于类的元信息,很重要,是实现继承的关键
  • 匿名函数
  • 闭包,指有权访问另一个函数作用域中的变量的函数。