简单想法

用于记录一些简短的想法

Views: 85151

440 Responses to "简单想法"

  • 在 Mac OS X 系统下编译 PortAudio:

    ./configure –disable-mac-universal

    修改 Makefile, 删除 -Werror.

    修改 include/pa_mac_core.h, 删除这两行:

    #include <AudioUnit/AudioUnit.h>
    //#include <AudioToolbox/AudioToolbox.h>

    加上这一行:

    #include <CoreAudio/CoreAudio.h> Reply
  • Real-Time Web Reply
  • 如果vim的退格键(backspace)不能删除, 可以配置:

    set backspace=indent,eol,start Reply
  • Cocoa 保存 NSImage 为图片:


    NSData *data = [img TIFFRepresentation];
    NSBitmapImageRep *rep = [NSBitmapImageRep imageRepWithData:data];
    data = [rep representationUsingType:NSPNGFileType properties:nil];
    [data writeToFile:@"/path/test.png" atomically:NO];

    Reply
  • Cocoa View 另存为图片:


    [view lockFocus];
    NSRect bounds = [view bounds];
    NSBitmapImageRep* rep;
    rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:bounds];
    [view unlockFocus];

    // 或者
    BitmapImageRep* rep = [view bitmapImageRepForCachingDisplayInRect:self.bounds];
    [view cacheDisplayInRect:self.bounds toBitmapImageRep:rep];

    NSData *data = [rep representationUsingType:NSJPEGFileType properties:nil];
    [data writeToFile:@"/path/to/file.jpg" atomically:NO];
    Reply
  • git 修改 commit log:


    git commit --amend
    Reply

  • valgrind --tool=memcheck --leak-check=yes --show-reachable=yes ./myapp

    Reply
  • Cocoa Webview 获取当前鼠标下的 DOM 节点:

    NSPoint point = [theEvent locationInWindow];
    NSDictionary *dict = [webView elementAtPoint:point];
    DOMNode *node = [dict objectForKey:@"WebElementDOMNode"];
    Reply
  • Mac OSX 下复制应用程序的 logo:

    1. 在 Finder 中找到应用程序(*.app)
    2. Cmd + C 复制
    3. 启动 Preview
    4. 选择菜单 File -> New From Clipboard Reply
  • [NSImage imageNamed:@"NSApplicationIcon"]; Reply

« [1][2][3][4][5][6][7][8][9] » 5/44