Wednesday, December 28, 2016

Node.js for Mac

Source: http://icarus4.logdown.com/posts/175092-nodejs-installation-guide

1. Install NVM (Node.js Version Manager)
   1.1. Add "source $(brew --prefix nvm)/nvm.sh" to ~/.bash_profile
   1.2. Source ~/.bash_profile

2. Install Node.js
   2.1. List available versions by "nvm ls-remote"
   2.2. Install the LTS by "nvm install v6.9.2"


Node.js directory: /usr/local/opt/nvm/versions/node/vX.X.X
Installed versions: nvm ls
Current in use version: nvm -v
To switch version: nvm use vX.X.X (only valid for current shell). To fix it, set it as default version to use: nvm alias default vX.X.X



Tuesday, November 22, 2016

Samba server on Ubuntu

. Install samba server on ubuntu if not done yet.
    sudo apt-get install samba

. Create an user, howard.
    sudo useradd howard

. Create a samba user, howard, and set the password.
    sudo smbpasswd -a howard

. Configure the shared folder permission info in samba config file.
    sudo vi /etc/samba/smb.conf
    Add following info to the end of smb.conf file
    [src]
    path = /home/howard/src/
    browseable = yes
    read only = no
    writeable = yes
    create mask = 0755
    directory mask = 0755
    valid users = howard

. Restart the samba service and it's now ready!
    sudo service smbd restart


[To connect the samba server from a Mac OS X]
    Go to finder and Cmd+K, enter smb://IPOfUbuntu/src

Monday, November 7, 2016

Sync folders with rsync

Copy everything from srcFolder to dstFolder
     rsync -va srcFolderPath/ dstFolderPath/


Copy everything from srcFolder to dstFolder and delete any files that does not exist in srcFolder

     rsync -va --delete srcFolderPath/ dstFolderPath/

Note: the trailing slash (/) of the srcFolderPath is important. If you omit it, for instance, rsync -va srcFolderPath dstFolderPath/
then a folder named "srcFolderPath" will be created and saved into dstFolderPath.

Friday, October 7, 2016

The file is damaged and should be moved to the trash

The problem could be fixed by turned off the gatekeeper.

1. Disable the gatekeeper by
   . sudo spctl --master-disable
2. Right click on the application and click open. It should work now.
3. Enable the gatekeeper by
   . sudo spctl --master-enable



To check the status of the gatekeeper:
   . sudo spctl --status

Friday, September 30, 2016

Packed struct for LLVM

typedef struct __attribute__ ((packed))          
{
    int a ;
    char b ;
} TEST_T ;
Size: 5 Bytes


Putting it in the end as below won't work!! Also, aligned(1) does not work either!

typedef struct
{
    int a ;
    char b ;
} TEST_T __attribute__ ((packed)) ;   X
Size: 8 Bytes

typedef struct
{
    int a ;
    char b ;
} TEST_T __attribute__ ((aligned(1))) ;   X
Size: 8 Bytes

typedef struct __attribute__ ((aligned(1))) ;   X
{
    int a ;
    char b ;
TEST_T ;
Size: 8 Bytes

Friday, September 23, 2016

NFS server on Ubuntu

Setup NFS server on Ubuntu:
   . sudo apt-get install nfs-kernel-server
   . Create a folder for sharing
      . mkdir PATH_TO_SHARE
      . chmod -R 777 PATH_TO_SHARE
   . Edit /etc/exports
      . sudo vi /etc/exports
      . add following line and save
         PATH_TO_SHARE *(rw,sync,insecure,no_root_squash,no_all_squash)
   . Refresh updated /etc/exports
      . sudo exportfs -r
   . Restart NFS server
      . /etc/init.d/nfs-kernel-server restart
   . Check shared NFS folders
      . showmount -e localhost


Connect to NFS server on Ubuntu from Mac OS X

[Finder]
   . Cmd + K (Finder -> Go -> Connect to Server )
     . nfs://IPOfUbuntu:/PATH_TO_SHARE
[Terminal]
   . Check what folders have been shared
      . showmount -e IPOfUbuntu
   . Create a mount point
      . mkdir MOUNT_POINT
   . Mount nfs to local MOUNT_POINT folder
      . sudo mount -o resvport,rw -t nfs IPOfUbuntu:/PATH_TO_SHARE MOUNT_POINT

Wednesday, June 8, 2016

Thursday, May 12, 2016

ffplay rtsp command

ffplay -i rtsp://url

To force ffplay to use TCP, add "-rtsp_transport tcp" right after ffplay.
E.g. ffplay -rtsp_transport tcp -i rtsp://url

Check clients which connect to Mac OS X Wi-Fi Internet Sharing

arp -i bridge100 -a bridge100 may be different on your Mac OSX