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

Tuesday, November 3, 2015

Sharing folders between VMware host and guest O.S.

1. Install VMware Tools. See http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1022048 and http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1022525
     . Virtual Machine -> Install VMware Tools
           sudo mkdir /mnt/vmtools
           sudo mount /dev/sr0 /mnt/vmtools
           cd /mnt/vmtools
           tar zxvf VMwareTools-x.x.x.tar.gz -C /tmp
           cd /tmp/vmware-tools-distrib
           sudo ./vmware-install.pl -d
           sudo reboot

2. Configure share folder
     . Go to settings of the guest VM -> Sharing
           Setup the sharing folder

3. The location of the shared folder will be in /mnt/hgfs or /media/psf/

bash_profile for Mac

# reloads the prompt, usefull to take new modifications into account
alias reload="source ~/.bash_profile"

alias ll='ls -al'
alias ..="cd ../"
alias ...="cd ../../"
alias .3="cd ../../../"
alias .4="cd ../../../../"

#Find CPU hogs
alias cpu_hogs='ps wwaxr -o pid,stat,%cpu,time,command | head -10'

#recommended 'top' invocation to minimize resources
alias ttop="top -R -F -s 10 -o rsize"

# qfind: Quickly search for file alias qfind="find . -name "
alias qfind="find . -name "

# your public ip
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"

# your local ip
alias localip="ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'"

#   ---------------------------
#   6.  NETWORKING
#   ---------------------------

# netCons:      Show all open TCP/IP sockets
alias netCons='lsof -i'

# flushDNS:     Flush out the DNS Cache
alias flushDNS='dscacheutil -flushcache'

# lsock:        Display open sockets
alias lsock='sudo /usr/sbin/lsof -i -P'

# lsockU:       Display only open UDP sockets
alias lsockU='sudo /usr/sbin/lsof -nP | grep UDP'

# lsockT:       Display only open TCP sockets
alias lsockT='sudo /usr/sbin/lsof -nP | grep TCP'

# ipInfo0:      Get info on connections for en0
alias ipInfo0='ipconfig getpacket en0'

# ipInfo1:      Get info on connections for en1
alias ipInfo1='ipconfig getpacket en1'

# openPorts:    All listening connections
alias openPorts='sudo lsof -i | grep LISTEN'

# showBlocked:  All ipfw rules inc/ blocked IPs
alias showBlocked='sudo ipfw list'

#   ii:  display useful host related informaton
#   -------------------------------------------------------------------
    ii() {
        echo -e "\nYou are logged on ${RED}$HOST"
        echo -e "\nAdditionnal information:$NC " ; uname -a
        echo -e "\n${RED}Users logged on:$NC " ; w -h
        echo -e "\n${RED}Current date :$NC " ; date
        echo -e "\n${RED}Machine stats :$NC " ; uptime
        echo -e "\n${RED}Current network location :$NC " ; scselect
        echo -e "\n${RED}Public facing IP Address :$NC " ;myip
        #echo -e "\n${RED}DNS Configuration:$NC " ; scutil --dns
        echo

    }

Tuesday, August 25, 2015

[Books] Five marketing/creative books that have stood the test of time

Source: http://www.adweek.com/adfreak/5-marketing-and-creativity-books-stand-test-time-157640
1. A Technique for Producing Ideas, James Webb Young (1965)
2. The Soul of a New Machine, Tracy Kidder (1981)
3. Bill Bernbach's Book, Bob Levenson (1987)
4. The Book of Gossage, Howard Gossage, edited by Bruce Bendinger (1995)
5. The Cluetrain Manifesto, Rick Levine, Christopher Locke, David "Doc" Searls, David Weinberger (2000)

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

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