Error: Cowardly refusing to `sudo brew link`

$ sudo brew link node
Error: Cowardly refusing to `sudo brew link`
You can use brew with sudo, but only if the brew executable is owned by root.
However, this is both not recommended and completely unsupported so do so at
your own risk.

解决办法

$ sudo chown -R root /usr/local

[转]Moving From MacPorts to Homebrew

Using MacPorts? You should really think about moving to Homebrew. Why?
  • Homebrew installs packages into their own isolated prefixes and then symlinked into /usr/local.
  • It uses the libs that are already installed, no need to compile another perl, openssl or x11 and other stuff that can be found on your mac. Don’t waste time and disc space.
  • Way better command line user interface
  • Homebrew and it’s installation scripts are hosted at Github
  • The installation scripts (aka recepies) and Homebrew itself are written in ruby.
Moving from MacPorts to Homebrew sounds a little bit scary. MacPorts has tons of compiled stuff on your system. But you can do this. Trust me :) .
 
First, uninstall MacPorts:
 
sudo port -f uninstall installed
 
Second step: remove everything that is left from MacPorts (check for MySQL and other stuff in /opt/local first) :
 
sudo rm -rf /opt/local
sudo rm -rf /Applications/DarwinPorts
sudo rm -rf /Applications/MacPorts
sudo rm -rf /Library/LaunchDaemons/org.macports.*
sudo rm -rf /Library/Receipts/DarwinPorts*.pkg
sudo rm -rf /Library/Receipts/MacPorts*.pkg
sudo rm -rf /Library/StartupItems/DarwinPortsStartup
sudo rm -rf /Library/Tcl/darwinports1.0
sudo rm -rf /Library/Tcl/macports1.0
sudo rm -rf ~/.macports
 
Alternatively you can move those directories to another place and delete them if everything is okay (if you don’t trust your Timemachine ;) ).
 
After that you should remove the /opt/local/bin from your $PATH.
 
Now install Homebrew with the command you find here.
 

输入法加强

在Editbox中显示pingyin提示

TreeView 测试

测试了下TreeView,还不错

    control.treeView:setRootVisible(true)
    local rootNode = control.treeView:getRoot()
    
    rootNode:add(TreeNode:new("Test1"))
    rootNode:add(TreeNode:new("Test2"))
    rootNode:add(TreeNode:new("Test3"))
    rootNode:getChild(0):add(TreeNode:new("Test4"))
    rootNode:getChild(1):add(TreeNode:new("中文"))

Posix semaphore blocked by Mac Store sandbox

sem_open无法在Mac Store App中使用,会被sandbox denied,需要额外的权限,为保险起见,还是不要使用,免得被Apple拒了

以下代码无法通过

#include <semaphore.h>

sem_t * pSemaphore = sem_open(name, O_CREAT, 0777, 1);
if (pSemaphore == (sem_t *)SEM_FAILED)
{
    //... 
}

用pthread_mutex替代

#include <pthread.h>

pthread_mutex_t* pSemaphore = (pthread_mutex_t *)BL_MALLOC(sizeof(pthread_mutex_t));
int ret = pthread_mutex_init(pSemaphore, NULL);
if (ret != 0)
{
    //... 
}

UI编辑器测试

Hybrid封装,纯Lua实现,继续完善

iOS同样效果,自适应窗口

 

 

require "editor/BaseControl"
--------------------------------------------

DebugInfoControl = class("DebugInfoControl", function(parent)
    return BaseControl.create("DebugInfo.layout", parent)
end)

DebugInfoControl.__index = DebugInfoControl


function DebugInfoControl.create(parent)
    local control = DebugInfoControl.new(parent)

    control.textbox= GUICast:toTextBox(control:getWidget("_Main"))
    control.frames = 0
    control.timer = 0
    control:registerEvent("Event_Update", control.update)

    return control
end

function DebugInfoControl:update(delta)
    self.frames = self.frames+1
    self.timer = self.timer+delta
    if self.timer > 0.5 then
        self.textbox:setCaption(string.format("FPS:%d", self.frames / self.timer))
        self.frames = 0
        self.timer = 0
    end
end

Dynamic Font

动态字体实现,效果如下

整合opengl调试器

重新实现opengl监控,独立lib,暂支持mac,ios(opengles2.0 only),更加高效,不占用额外贴图内存,可跟踪任意贴图,包括任意压缩贴图

Cocos2dx + GUI

Hybrid开发记录,Mac下中文输入实现