顯示具有 Mac OS X 標籤的文章。 顯示所有文章
顯示具有 Mac OS X 標籤的文章。 顯示所有文章

2017年2月1日 星期三

How to Fix: Launch an older app crashes immediately on Mac

since: 2017/02/01
update: 2017/02/01

reference:
1. macos - "This UPX compressed binary contains an invalid Mach-O header and cannot be loaded." - Ask Different
2. Install upx on Mac OSX – Mac App Store


A. Error Message:
     “This UPX compressed binary contains an invalid Mach-O header and cannot be loaded.”
    
-----------------------------------------------------------------------------------------------

B. Install ups on Mac
    1. Install Homebrew:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null

    2. Install upx: (目前版本: 3.93)
$ brew install upx

-----------------------------------------------------------------------------------------------

C. 檢查 app 套件執行位置:
     > yourApp.app > 顯示套件內容 > Contents > MacOS > x-force
        (不同 app 會有不同檔名)


-----------------------------------------------------------------------------------------------

D. Decompressing the app's binary using the -d option

     $ upx -d yourApp.app/Contents/MacOS/x-force

     (完成)

-----------------------------------------------------------------------------------------------

D. 備註:
     1. 讓 Mac Sierra 可以安裝第三方軟體
         a. 啟用功能: (開啟允許「任何來源」選項)
             終端機程式 > sudo spctl --master-disable

         b. 停用功能: (關閉「任何來源」選項)
             終端機程式 > sudo spctl --master-enable

2016年6月6日 星期一

VJ Combination: AirServer + Syphon + Modul8

since: 2016/06/06
update: 2016/06/06
reference:
1. AirServer - AirPlay, Mirroring and Miracast receiver for Mac OS X and Windows PC
2. Syphon

3. Modul8 VJ software

A. AirServer
    1. 於 Mac 上執行 AirServer 後, 可檢查 Preferences 設定

    2. 在 Mirroring 頁籤, 可以調整 Mirroring 畫面的傳輸品質.(品質越好, 越吃頻寬)

-----------------------------------------------------------------------------------------------

B. AirPlay
    1. 在 iPad2 上, 從底部往上滑, 點選 AirPlay:
        > xxx 的 MacBook Pro > 啟用鏡像輸出

    2. 此時在 Mac 上即可看到 iPad2 的鏡像

-----------------------------------------------------------------------------------------------

C. Syphon

    開啟 Syphon Client > 選擇來源為: iPad2 - AirServer

-----------------------------------------------------------------------------------------------

D. Modul8

    1. 開啟 Modul8 (需為 2.7 以上, 且是正式版)
        > Modules > Show > Syphon Input (layer)

    2. 在 out 中可看到經由 Syphon 輸出的畫面:

-----------------------------------------------------------------------------------------------

E. 備註:

     1. 如果 Modul8 為從 2.6 以前升級到 2.7 以上的,  
         在 Modules > Show > 找不到 Syphon Input (layer) 的話:

         方式一: 線上安裝


*************************************************************
  (建議)方式二: 拷貝 Syphon Input Modules 
         > 先到 Modul8 官網, 下載最新的 demo 版
         > 解壓縮並掛載後, 把整個 Modul8Demo 資料夾拷貝出來,
         > 到 Modul8Demo 資料夾下的 Modules 資料夾裡
         > 將 Syphon Input (layer).m8m 檔案,
            拷貝到 Mac 上安裝  Modul8 的 Modules 目錄裡
            (一般為: 應用程式 > 某程式 > 顯示套件內容 > Contents > Modules)

2016年6月5日 星期日

Mac 無線網路診斷

since: 2016/06/05
update: 2016/06/05
reference:

A. 打開無線診斷

    1. 開啟 Wi-Fi 後, 按下鍵盤的 ALT 鍵不放 


    2. 點一下右上方的無線網路圖示(之後可以放開 ALT 鍵了)


    3. 點選 “打開無線診斷...”



-----------------------------------------------------------------------------------------------

B. 掃描
    1. 無須理會開啟的 “無線診斷” 視窗

    2. 點選左上角的 “視窗”

    3. 點選 “掃描”



-----------------------------------------------------------------------------------------------

C. 立即掃描
     1. 按下右下方的 “立即掃描”


     2. 可以看到無線網路所使用的頻道
         (可視情況更改無線 AP 的頻道, 以確保無線傳輸品質)


2016年1月15日 星期五

openFrameworks: Reading From And Writing To Files With ofBuffer Class

since: 2016/01/15
update: 2016/01/15
reference:

A. in header file:
    ....
    /* config file */

    bool debug; // debug mode: to show more message or not
    float checkTime_second;
   
    /* record datetime to file */
    ofBuffer readBuffer;
    ofBuffer checkTimeBuffer;
    string nowDateString;


-----------------------------------------------------------------------------------------------

B. in c++ file:
     1. Read File:
   
    ....

    // read config file
    readBuffer = ofBufferFromFile("config.txt");
    //cout << readBuffer.getText(); // let's see what it says
    vector<string> lines = ofSplitString(readBuffer, "\n");
   
    for( int i = 0; i < lines.size(); i++){
        //cout << lines[i] << endl;
       
        if(i == 1) {
            debug = ofToBool(lines[i]);
            if(debug) {
                ofLog(OF_LOG_NOTICE, ">>>>> debug true");
            }
            else {
                ofLog(OF_LOG_NOTICE, ">>>>> debug false");
            }
        }
        else if(i == 4) {
            checkTime_second = ofToFloat(lines[i]);
            ofLogNotice(">>>>>>>>> checkTime_second") << checkTime_second;
        }

   

     2. Write File:
         ....

         // inner some loop
         if(ofGetElapsedTimef() >= checkTime_second) {
             ofResetElapsedTimeCounter();
               
             nowDateString = ofGetTimestampString("%Y%m%d%H%M%S");
             checkTimeBuffer.set(nowDateString.c_str(), nowDateString.size());
             if(ofBufferToFile("dateTime.txt", checkTimeBuffer)) {
                 ofLogNotice(">>>>>>>>> update checking dateTime") << nowDateString;
             }
         }


AppleScript: Repeat Checking App Status

since: 2016/01/15
update: 2016/01/15


A. 新增 AppleScript:
    1. 開啟 Automator:

   
     2. Automator > 檔案 > 新增 > 應用程式 > 選擇:
    
     3. 工具程式 > 執行 AppleScript > 拖拉到右方

    4. 預設程式碼:
on run {input, parameters}
   
    (* Your script goes here *)
   
    return input
end run


-----------------------------------------------------------------------------------------------

B. 修改 AppleScript:
on run {input, parameters}
   
    #
    # start: variables defined
    #
   
    # script repeat delay time (second)

    set repeatDelayTime to 180
   
    # dateTimeFile Path
    # /Lanli/RD/project/openFrameworks/of_v0.9.0/apps/myApps/myFirstApp/bin/data/

    set dateTimeFilePath to (("Lanli:RD:project:openFrameworks:of_v0.9.0:apps:myApps:myFirstApp:bin:data:") as text)
   
    # dateTimeFile Name
    set dateTimeFileName to "dateTime.txt"
   
    # completed dateTimeFile
    set dateTimeFile to dateTimeFilePath & dateTimeFileName
   
    # allow time difference to sysDateTime & appUpdateTime (second)

    set allowedSecondDiff to 120


    # allowed min free memory (MB)
    set allowedMinFreeMemory to 0
   
    # my app name
    set myAppName to "myFirstApp"

    # reboot system or not
    set reboot to false   

    #
    # end: variables defined
    #

   
    ##########################################################
   
    #
    # start script repeat
    #

    repeat
       
        # delay 180 second  
        # delay 180 
  
        delay repeatDelayTime
       
        # start: repeat task
       

##########################################################       
        # 
        # check 01:  app update status
        #
        # Read lines from file.

        set fileLines to paragraphs of (read file dateTimeFile as «class utf8»)
       
        # Loop over lines read and copy each to the clipboard.
        repeat with perLine in fileLines
            set the clipboard to perLine
            #display alert (the clipboard)
            set appUpdateTime to (the clipboard) as integer
            exit repeat # we just need read one line here
        end repeat
       
        # get sysDateTime
        set sysDateTime to nowTimeFormat() as integer
       
        # check time diff
        if (appUpdateTime + allowedSecondDiff) ≥ sysDateTime then
            # display dialog "you pass" with title "check app update status" buttons {"OK"} default button 1
        else
            # display dialog "reboot" with title "check app update status" buttons {"OK"} default button 1
            set reboot to true
        end if
       
       
        #
        # check 02:  system memory free
        #
       
        # query memory free (MB)

        set vmStats to (text 12 thru -2 of (do shell script "vm_stat | grep 'Pages free'")) * 4096 / 1024 / 1024
        # show free Memory
        #display dialog vmStats with title "Memory Free (MB)" buttons {"OK"} default button 1

       
        # if vmStats <= 0 MB
        if vmStats ≤ allowedMinFreeMemory then
            set reboot to true
        end if
       
        # for test
        #set reboot to false

       
        #
        # reboot system or not
        #

        if reboot is true then
            #display dialog "reboot" with title "reboot system or not" buttons {"OK"} default button 1
           
            #step 1: kill your app 
            tell application "System Events"
                set ProcessList to name of every process
               
                if myAppName is in ProcessList then
                    set ThePID to unix id of process myAppName
                    do shell script "kill -KILL " & ThePID
                end if
            end tell
           
            #step 2: reboot system
            tell application "Finder"
                restart
            end tell
           
        else
            #display dialog "pass" with title "reboot system or not" buttons {"OK"} default button 1
        end if
       
       
        # end: repeat task
       

##########################################################       
        # exit script repeat: for only once execute
        #exit repeat
       
        #   
        # end script repeat
        #  
     
    end repeat
   
    return input
end run



# nowTimeFormat
on nowTimeFormat()
   
    set theDate to current date
    set y to text -4 thru -1 of ("0000" & (year of theDate))
    set m to text -2 thru -1 of ("00" & ((month of theDate) as integer))
    set d to text -2 thru -1 of ("00" & (day of theDate))
    set hh to text -2 thru -1 of ("00" & (hours of theDate))
    set mm to text -2 thru -1 of ("00" & (minutes of theDate))
    set ss to text -2 thru -1 of ("00" & (seconds of theDate))
   
    # 2016-01-15-10-56-46
    #return y & "-" & m & "-" & d & "-" & hh & "-" & mm & "-" & ss
    # 20160115105646

    return y & m & d & hh & mm & ss
   
end nowTimeFormat

2015年10月1日 星期四

製作 OS X El Capitan USB 安裝開機碟

since: 2015/10/01
update: 2015/10/01

reference:
1. How to Create a OS X El Capitan Boot Installer USB Flash Drive

A. 準備動作:     

     1. 16 GB 的 USB 隨身碟.(至少需 8 GB)

     2. 從 Mac App Store 下載 OS X El Capitan, 下載完成後, 離開安裝步驟, 先不要安裝.

         備註: 並確認下載的檔案是在 /Applications 下
                  $ cd /Applications
                  $ ls | grep "Install"
                     Install OS X El Capitan.app

--------------------------------------------------------------------------------------------

B. 製作可開機的 USB 碟:
    1. 將 USB 隨身碟連結 Mac, 並開啟 "磁碟工具程式",
        從左邊的磁碟清單點選 USB 隨身碟.

    2. 點選 "清除" 頁籤, 格式選為: Mac OS 擴充格式(日誌式), 按下 "清除" 並確認.

    3. 點選 "分割" 頁籤, 將分割區佈局從旁邊的下拉式選單選取 "1個分割區",
        並將分割區資訊裡的名稱, 改成: Untitled .
 
  4. 點選 "選項...", 點選 "GIUD 磁碟分割區表格" > 好 >  套用 > 分割 > 確認

    5. 磁碟工具程式 > 結束磁碟工具程式

--------------------------------------------------------------------------------------------

C. 更改要安裝 OS X El Capitan 的 USB 隨身碟名稱, 以方便識別:
     ---> 將其名稱改成 "ElCapInstaller"


--------------------------------------------------------------------------------------------

D. 製作 OS X El Capitan 安裝碟:
     1. 開啟 "終端機", 鍵入以下的指令:
    $sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia --volume /Volumes/ElCapInstaller --applicationpath /Applications/Install\ OS\ X\ El\ Capitan.app --nointeraction

     2. 鍵入 admin 的 密碼, 等待完成的訊息(約 20 分鐘), 離開終端機.

     3. 完成後, 可以在 Mac Finder 看到剛出爐的 OS X El Capitan 安裝碟.

--------------------------------------------------------------------------------------------

E. 進行安裝:
     重新開機, 按下 "option" 鍵, 就可以選擇 "Install OS X El Capitan" 了.

2015年9月24日 星期四

openFrameworks: v0.8.4 with Xcode 7.0

since: 2015/09/24
update: 2015/09/26
reference:
1. Warning : before upgrading to Xcode 7 - x-code - openFrameworks

A. 說明:
     Xcode 7 並沒有包含 OS X SDK 10.10 或更早的版本,
     可能會造成程式編譯上的錯誤:

         a. opensslconf.h file not found

         b. There is no SDK with the name or path

-----------------------------------------------------------------------------------------------

B. 解決方式:
    1. 在更新至 Xcode 7 前, 先從以下目錄來備份 MacOSX10.10.sdk:
         應用程式 > Xcode > (滑鼠右鍵)顯示套件內容 >
         Contents > Developer > Platforms > MacOSX.platform >
         Developer > SDKs > MacOSX10.10.sdk

        或者直接從網路下載: MacOSX10.10.sdk.dmg

    2. 更新至 Xcode 7 後, 將剛剛備份或下載的  MacOSX10.10.sdk ,
        複製回 Xcode 7 的相對的 SDKs 目錄內.

    3. 開啟 Xcode 的專案, 選取左邊的 openFrameworksLib.xcodeproj :
        右方 > Build Settings > Architectures > Base SDK: 選取 OS X 10.10

 4. 同樣地, 也需對 Xcode 本身的專案作相同的設定.

-----------------------------------------------------------------------------------------------

C. 備註:
     如果只是 openssl 的問題, 可以由以下的方式解決:  

     1. 在 Mac 上安裝 openssl:
          $ brew install openssl

     2. 開啟 Xcode 的專案, 點選左邊的 CoreOF.xcconfig   

     3. 在右方 HEADER 定義的最下方加入:
         ....
         //@add for openssl

         HEADER_OPENSSL = "$(OF_PATH)/libs/openssl/include"
         ....

     4. 在右方 OF_CORE_HEADERS =  的最後面加入:  $(HEADER_OPENSSL)
         ....
         ....

2015年8月1日 星期六

Using the Jetson TK1 as a remote development environment for CUDA

since: 2015/08/01
update: 2015/08/01

reference:
1. How to use the Jetson TK1 as a remote development environment for CUDA
2. Remote application development using NVIDIA® Nsight™ Eclipse Edition
3. NVIDIA CUDA GETTING STARTED GUIDE FOR LINUX v6.5
4. CUDA 6.0 in Ubuntu 14.04.1 LTS - NVIDIA Developer Forums
5. CUDA Toolkit 6.5
6. CUDA Toolkit Documentation v7.0


A. 在 Local (Mac) 上安裝 CUDA toolkit
     1. 安裝 Xcode

     2. 安裝 Xcode Command Line Tools:
         $ xcode-select --install

     3. 到 CUDA Toolkit 6.5 下載 CUDA Toolkit 6.5 for Mac OSX
         版本: cuda_6.5.14_mac_64.pkg  (latest 64-bit CUDA 6.5 package)

     4. 點二下安裝, 其中 CUDA Driver 在 Local 處可以不需要安裝, 除非要執行 CUDA-Z.

-----------------------------------------------------------------------------------------------

B. 在 Remote (Jetson TK1) 上安裝 CUDA toolkit
     1. Verify You Have a CUDA-Capable GPU
         $ lspci | grep -i nvidia
         00:00.0 PCI bridge: NVIDIA Corporation Device 0e13 (rev a1)

     2. 到 CUDA Toolkit 6.5 下載 CUDA Toolkit 6.5 for Linux ARM
         版本: ONLY to be used for Jetson TK1
         cuda-repo-l4t-r21.2-6-5-prod_6.5-34_armhf.debf (L4T 21.2 DEB)
         (將檔案傳送到 remote 的 /home/ubuntu/RD/software 目錄下)

     3. 安裝:
          $ cd /home/ubuntu/RD/software
          $ sudo dpkg -i cuda-repo-l4t-r21.2-6-5-prod_6.5-34_armhf.deb
          $ sudo apt-get update
          $ sudo apt-get install cuda-toolkit-6-5

     4. Add the user to the video group
          $ sudo usermod -a -G video ubuntu

     5. Environment Setup ...
          To change the environment variables for 32-bit ARM operating systems:
          $ export PATH=/usr/local/cuda-6.5/bin:$PATH
          $ export LD_LIBRARY_PATH=/usr/local/cuda-6.5/lib:$LD_LIBRARY_PATH

     6. check the L4T version with the following command
         $ head -1 /etc/nv_tegra_release
            # R21 (release), REVISION: 4.0, GCID: 5650832, BOARD: ardbeg, EABI: hard, DATE: Thu Jun 25 22:38:59 UTC 2015

     7. install g++-4.6
         $ sudo apt-get install g++-4.6

     8. (Optional) Install Writable Samples
          $ cd /usr/local/cuda-6.5/bin
          $ cuda-install-samples-6.5.sh /home/ubuntu/RD/projects/
          $ cd NVIDIA_CUDA-6.5_Samples
          $ make

          The resulting binaries will be placed under:
          /home/ubuntu/RD/projects/NVIDIA_CUDA-6.5_Samples/bin


     9. After restart the system, Finally start one of the samples! 
         $ cd /home/ubuntu/RD/projects/NVIDIA_CUDA-6.5_Samples/bin
         $ cd armv7l/linux/release/gnueabihf
         $ ./deviceQuery


         $ ./bandwidthTest

-----------------------------------------------------------------------------------------------

C. Configure Git
       To synchronize CUDA projects between local(Mac) and target(Jetson TK1) systems,
       you need to configure git on both the local and the target systems using these
       commands:


       $ git config --global user.email "lanli0210@gmail.com"
       $ git config --global user.name "lanli"

-----------------------------------------------------------------------------------------------

D.Create nsight project on local(Mac)
     1. 開啟 nsight:
         YourMac > Developer/NVIDIA/CUDA-6.5/libnsight/nsight.app

     2. Select a workspace


     3. Create a new project
         File > New > CUDA C/C++ Project

     4. Project type: Empty Project

     5. Basic settings:

     6. Target system > Manage... > Remote Connections

     7. Configure CUDA Toolkit

     8. Target System(Project Path)

     9. remove the Local System

    結果:

     10. 完成:

-----------------------------------------------------------------------------------------------

E. Adding the source code for CUDA project
     1. File > New > Source File

     2. Source File Configure (just use a template)

     3. 完成:

     4. 按下 "編譯"
       p.s. Note that the build command is /usr/local/cuda-6.5/bin/nvcc,
              which is the compiler on the Jetson, not on the Macbook.

-----------------------------------------------------------------------------------------------

F. Debugging the code on CUDA project
     1. Debug Configurations

     2. Debugging ...
         p.s. By default the debugger will break in main() – this can be switched off
                in the debug configuration.