So Tired !_! 逆水行舟, 不进则退!

25Nov/16

Mac原生系统对ntfs格式写操作支持

Posted by Nick Xu

弹出移动硬盘
执行 hdiutil eject /Volumes/Toshiba\ Portable\ Hard\ Drive/,如下输出
"disk1" unmounted.
"disk1" ejected.

创建一个目录,稍后将mount到这个目录
sodu mkdir /Volumes/MYHD

将移动硬盘以NTFS格式mount到上面的目录
sudo mount_ntfs -o rw,nobrowse /dev/disk1s1 /Volumes/MYHD/
执行完上面命令后,你可以看到你的移动硬盘灯又两起来了,没有任何输出,表示成功。

此时,你的移动硬盘可写了。 不过你不能在Finder里面操作,因为上面加了nobrowse选项。但是这个选项是必须的,否则你无法写。

Tagged as: , , Comments Off
22Mar/16

Mac OS X 下部分Android手机无法连接adb问题之解决方案

Posted by Nick Xu

打开终端,在任意当前路经下都可以直接执行adb命令,通过USB线将Android手机和Mac PC连接后,adb devices,没有相应设备的列表。下面是解决办法:
1. 打开终端,输入:system_profiler SPUSBDataType,查看Mac系统所有USB设备信息,找到相应的厂商Vender ID。
查到相应连有Android手机设备的usb hub,找到相应的厂商Vender ID,比如,我的测试机K-Touch T619天语手机就无法连接adb,查到的相应信息片段如下:
  1. -----------------
  2.  Spreadtrum phone:
  3.               Product ID: 0x5d04
  4.               Vendor ID: 0x1782
  5.               ...
  6.        Serial Number: T619
  7.        ...
  8. -----------------

2. 终端进入/Users/user/.android,应该有一个adb_usb.ini文件,如果没有就创建,然后将上面的Vender ID “0x1782”单独一行加入到该文件,然后退出。

  1. # ANDROID 3RD PARTY USB VENDOR ID LIST -- DO NOT EDIT.
  2. # USE 'android update adb' TO GENERATE.
  3. 1 USB VENDOR ID PER LINE.
  4. 0x1782

3. 重启adb server进程。

终端依次执行下面命令:
  1. adb kill-server
  2. adb start-server

然后通过adb devices命令就可以查看到以相应设备Serial Number为名字的设备。如:

  1. -MacBook-Pro:.android user$ adb devices
  2. List of devices attached
  3. emulator-5554   device
  4. T619    device

PS:

1. 有时 adb devices不能显示连接设备,需要拔掉数据线,多插几次,并且退出终端,然后重新打开,再输入命令就能发现连接的设备,再无法连接请重启电脑,等待系统初始化环境设置。
需要注意的是并不是所有的android机器都能解决,比如有的手机有供应商ID,缺少产品ID,依然无法识别,这种奇葩形的就只能找其它方法了。
2. Windows(XP、7)下面也可以同样的方法解决。但是前提也是已经指定了adb环境变量并且安装了相应Android手机设备的adb usb驱动,判断有没有装通过将手机和Windows连接,设备管理器里面没有发现显示有问号的设备就说明装了,有就说明没有安装。然后在C:\Users\username\.android目录下面也有一个adb_usb.ini文件,像前面那样别起一行添加相应设备的Vender ID,重启adb server进程即可。
3. 如果发现无法启动ADB SERVER, 运行下面这行查看具体原因:
adb nodaemon server
Tagged as: , , Comments Off
17Mar/16

install Python Imaging Library on mac

Posted by Nick Xu

# download
curl -O -L http://effbot.org/media/downloads/Imaging-1.1.7.tar.gz
# extract
tar -xzf Imaging-1.1.7.tar.gz
cd Imaging-1.1.7
# build and install
ln -s /usr/local/include/freetype2 /usr/local/include/freetype
xcode-select --install
python setup.py build
sudo python setup.py install
# or install it for just you without requiring admin permissions:
# python setup.py install --user
Tagged as: , Comments Off
10Nov/15

mac 编译openresty常见问题

Posted by Nick Xu

第一次装openresty没有事情的,然而重装MAC后,再装openresty出现了问题。安装openresty可以直接

git clone https://github.com/openresty

下来,运行make,自动下载依赖包,也可以直接到 http://openresty.org/ 下载打包好的。

1.openssl缺少错误如下

1
2
3
4
5
6
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

ERROR: failed to run command: sh ./configure --prefix=/usr/local/openresty/nginx \…

缺少openssl库,那就把本机安装路径告诉它吧:

./configure —with-openssl=/usr/local/Cellar/openssl/1.0.2c

2.openssl源码安装错误

1
2
3
4
5
6
7
8
9
10
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f objs/Makefile
cd /usr/local/Cellar/openssl/1.0.2c \
	&& if [ -f Makefile ]; then /Applications/Xcode.app/Contents/Developer/usr/bin/make clean; fi \
	&& ./config --prefix=/usr/local/Cellar/openssl/1.0.2c/.openssl no-shared  no-threads \
	&& /Applications/Xcode.app/Contents/Developer/usr/bin/make \
	&& /Applications/Xcode.app/Contents/Developer/usr/bin/make install LIBDIR=lib
/bin/sh: ./config: No such file or directory
make[2]: *** [/usr/local/Cellar/openssl/1.0.2c/.openssl/include/openssl/ssl.h] Error 127
make[1]: *** [build] Error 2
make: *** [all] Error 2

上了github,https://github.com/torch/image/issues/16,查查,明白了,这里要的是source code,不是安装路径,够坑的了吧。

那么好了,到https://www.openssl.org/下载了最新的,openssl.1.0.2c版本,到bundle目录里:

export KERNEL_BITS=64
./configure --with-cc-opt='-I/usr/local/Cellar/pcre/8.36/include/' \
       --with-ld-opt='-L/usr/local/Cellar/pcre/8.36/lib' \
       --with-openssl=bundle/openssl-OpenSSL_1_0_2c -j2

报了个warning:

1
2
3
WARNING! If you wish to build 64-bit library, then you have to
         invoke './Configure darwin64-x86_64-cc' *manually*.
         You have about 5 seconds to press Ctrl-C to abort.

看着是openssl与darwin的版本不兼容问题,后来发现是新版的openssl与nginx兼容问题。

3.pcre依赖报错

1
2
3
4
5
ld: symbol(s) not found for architecture x86_64 collect2: ld 
returned 1 exit status make[2]: *** [objs/nginx] 
Error 1 make[1]: *** [build] 
Error 2 make: *** 
[all] Error 2

找一找,发现了问题解决方案,是pcre依赖包没带上,也就是正则匹配依赖包的问题了:

在github上找到了issuse相关信息: https://github.com/openresty/ngx_openresty/issues/3#issuecomment-120227290

最后在issuse上问道了agentzh的解决方案,agentzh的makefile里在处理新版nginx与openssl依赖上的一点问题,后来他更新了github仓库:

1
2
3
4
5
6
export KERNEL_BITS=64
./configure --with-cc-opt='-I/usr/local/Cellar/pcre/8.37/include/' \
       --with-ld-opt='-L/usr/local/Cellar/pcre/8.37/lib' \
       --with-openssl=$HOME/work/openssl-1.0.2d -j9
make -j9
sudo make install

在我这里(MAC OSX 10.10.4)运行起来是没问题的。

两个问题:

1.openssl依赖,要用源码,要export告诉系统环境变量

2.pcre包要手动加上去。

Tagged as: , Comments Off
11Aug/15

burn an ISO on a USB drive on Mac OS X?

Posted by Nick Xu

Directly from the Ubuntu download page (my formatting):

  1. Download the desired file
  2. Open the Terminal (in /Applications/Utilities/ or query Terminal in Spotlight)
  3. Convert the .iso file to .img using the convert option of hdiutil (e.g., hdiutil convert -format UDRW -o ~/path/to/target.img ~/path/to/ubuntu.iso)
  4. Note: OS X tends to put the .dmg ending on the output file automatically. Remove the .dmg extension as necessary, mv ~/path/to/target.img{.dmg,}
  5. Run diskutil list to get the current list of devices
  6. Insert your flash media
  7. Run diskutil list again and determine the device node assigned to your flash media (e.g. /dev/disk2)
  8. Run diskutil unmountDisk /dev/diskN (replace N with the disk number from the last command; in the previous example, N would be 2)
  9. Execute sudo dd if=/path/to/downloaded.img of=/dev/rdiskN bs=1m (replace /path/to/downloaded.img with the path where the image file is located; for example, ./ubuntu.img or ./ubuntu.dmg).
  10. Using /dev/rdisk instead of /dev/disk may be faster.
    • If you see the error dd: Invalid number '1m', you are using GNU dd. Use the same command but replace bs=1m with bs=1M.
    • If you see the error dd: /dev/diskN: Resource busy, make sure the disk is not in use. Start the 'Disk Utility.app' and unmount (don't eject) the drive.
  11. Run diskutil eject /dev/diskN and remove your flash media when the command completes
  12. Restart your Mac and hold down Alt while the Mac is restarting to choose the USB stick

Note: On newer Macs you might have to install an EFI boot manager to boot from USB.

Tagged as: , , , , Comments Off
11May/15

mac下的strace命令 

Posted by Nick Xu

strace在linux下用来跟踪某个进程的系统调用
在solaris下,对应的是dtrace
在mac下,对应的命令是:dtruss

13Feb/15

mac上opencv安装步骤

Posted by Nick Xu

1. 去 http://opencv.org 下载最新版OpenCV for Linux/Mac源文件,目前版本是2.4.3。下载后解压。

2. 去 http://www.cmake.org 下载最新版cmake,.dmg文件,建议使用2.8.12.2版本。下载后安装。
3. 接下来开始安装opencv(注: 如果需要启用多核支持, 可以先按第6点进行修改后再编译,未经测试)

开一个终端,进入opencv解压缩的目录,如cd 然后把文件夹拽进去。
mkdir release
cd ./release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..
make
sudo make install
4. 至此opencv应该已经装上了。
 注:如果cmake出现错误,请到苹果开发者网站那里下载Command Line Tools安装。(关键)

由于本人是要写python,所以还要进行下一步配置。本人mac是rmbp15,自带的python版本是2.7,终端下输入python后输入import cv,如果提示没有找到cv,请按如下步骤操作。
1. 打开一个终端,cd ~
2. vim .profile
3. 添加export PYTHONPATH=/usr/local/lib/python2.7/site-packages/,其中python2.7根据个人python版本而定。
4. source .profile
5. 至此应该全部完成了。

6.补充:

I got this working with OpenCV 2.4.10 and GCC 4.9.2. I also had to make the following additional changes to the CMakeLists.txt in the root OpenCV directory:

OCV_OPTION(WITH_OPENEXR “Include ILM support via OpenEXR” OFF)
OCV_OPTION(WITH_OPENMP “Include OpenMP support” ON)
OCV_OPTION(BUILD_OPENEXR “Build openexr from source” OFF )

I originally was running into errors with “Undefined symbols for architecture x86_64 cv::imshow, cv::imread, cv::imwrite, etc,” because Homebrew installed a clang OpenCV whereas my project was using GCC. One solution would be to rebuild everything with clang but that was not appealing in my case because I wanted OpenMP support. So I instead used your solution to build a GCC version of OpenCV.

3Jul/14

mac下设置nat

Posted by Nick Xu

$ sudo sysctl -w net.inet.ip.forwarding=1
$ sudo natd -interface en1
$ sudo ipfw add divert natd ip from any to any via en1
23Jan/14

Mac OSX maxfiles settings

Posted by Nick Xu

  1. create or edit the file “/etc/launchd.conf”
  2. write in it the following: limit maxfiles 20000 50000
  3. run the command: sudo chmod 775 /etc/launchd.conf
  4. save and reboot
4Nov/13

解决mac系统英文版本下偶尔中文文件名乱码的问题

Posted by Nick Xu

打开Terminal
输入
echo 25:52 >~/.CFUserTextEncoding (如此诡异的解决方案)
回车

然后重启一次就好啦,这样既是英文界面,也可以看中文了!

Tagged as: , Comments Off
site
site