12.23.2015

Carthage Tutorial (How to build CocoaAsyncSocket libraries)

OSX EI Capitan version 10.11.2 

1. Install brew as below link 
http://brew.sh

2. Install Carthage
brew install Carthage
brew update

3. Go to your xcode project create "Cartifile" file and type 
github "robbiehanson/CocoaAsyncSocket" "master" 
(base on your library)


4. In Terminal, type
cd ~/your xcode project/

Carthage update --platform iOS

5. Done
 


Reference

  • https://github.com/Carthage/Carthage/
  • https://github.com/robbiehanson/CocoaAsyncSocket



3.24.2015

Android Studio - ndk and gradle integration

Android Stdio 1.1.0 Gradle 2.2.1+

import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'com.android.application'

def getNdkDir(){
    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
    def ndkdir = properties.getProperty('ndk.dir', null)

    if (ndkdir == null)
        throw new GradleException("NDK location not found. " +
                "Define location with ndk.dir in the local.properties file or with an " +
                "ANDROID_NDK_ROOT/NDK_ROOT/NDKROOT/NDK environment variable.")

    if (!ndkdir.endsWith('/'))
        ndkdir = ndkdir + File.separator;

    return ndkdir
}

android {
    compileSdkVersion 21
    buildToolsVersion "22.0.0"

    defaultConfig {
        minSdkVersion 18
        targetSdkVersion 21
    }

    sourceSets.main {
        jniLibs.srcDir 'src/main/libs'
        jni.srcDirs = [] //disable automatic ndk-build call
    }

    task ndkBuild(type: Exec) {
        def ndkDir = getNdkDir()
        def ndkPath
        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            ndkPath = ndkDir + 'ndk-build.cmd'
        } else {
            ndkPath = ndkDir + 'ndk-build'
        }
        commandLine ndkPath, '-j4', '-C', file('src/main/jni').absolutePath
    }

    tasks.withType(JavaCompile) {
        compileTask -> compileTask.dependsOn ndkBuild
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        }
    }
}


1.16.2015

Gitweb Gitolite3 - how to add project owner and description

1. Open .conf file
sudo nano /yourpath/gitolite-admin/conf/gitolite.conf

2. Add gitweb config 
repo  testing
    config gitweb.owner = "Your Name"
    config gitweb.description = "Your description"
    RW+ = @all

3. git add, commit, then push

4. Check owner and description on gitweb

1.15.2015

Git - gitweb gitolite3 apache2 on Ubuntu

Work on ubuntu 14.04 LTS x64

1. Install Software
Install git gitweb apache2
sudo apt-get install git gitweb apache2

Install gitolite3

search "Synaptic Package Manager" in Ubuntu Software Center
search "gitolite3" in Synaptic Package Manager then install

2. Configure gitweb
Fix Apache2
sudo cp /etc/apache2/conf.d/gitweb /etc/apache2/conf-available/gitweb.conf
cd /etc/apache2/conf-enabled
sudo ln -s ../conf-available/gitweb.conf

Then modify gitweb.conf add "+" before FollowSymLinks look like
Alias /gitweb /usr/share/gitweb
<Directory /usr/share/gitweb>
  Options +FollowSymLinks +ExecCGI
  AddHandler cgi-script .cgi
</Directory>

Run following command
sudo a2enmod cgid
sudo service apache2 restart

Modefy gitweb in /etc/gitweb.conf
$projectroot = "/home/git/repositories/";
$projects_list = "/home/git/projects.list";

3. Configure gitolite3
Add git user
sudo adduser --system --shell /bin/bash --group --disabled-password --home /home/git git
Add user www-data to group git
sudo usermod -G git www-data

Create private and public key
cd ~/.ssh/
ssh-keygen -t rsa
sudo cp id_rsa.pub /home/git/tmp/admin.pub

Setup gitolite3 (Change user to git)
sudo su git
gitolite setup -pk /home/git/tmp/admin.pub

In /home/git/.gitolite.rc make sure
UMASK => 0027

chmod 640 /home/git/projects.list

exit
(Exit user from git)

4. Configure admin
Setup git 
git config --globla uer.name "yourname"
git config --global user.email "youremail@domain.com"

Clone gitolite-admin
cd /yourpath/
git clone git@your-server-ip:gitolite-admin.git

Add new user (you can read step.5 first)
(copy your newuser.pub to the sever put in /yourpah/gitolite-admin/keydir/)
cp newuser.pub /yourpath/gitolite-admin/keydir/newuser.pub
git add /yourpath/gitolite-admin/keydir/newuser.pub
git commit -a -m "create new repo and added newuser"
git push -u origin master

5. Configure NewUser
Create private and public key 
cd ~/.ssh/
ssh-keygen -t rsa
sudo mv id_rsa.pub newuser.pub
goto step.4 Add new user

6. Check gitweb
http://localhost/gitweb or http://your-server-ip/gitweb

Debug Command
Check ssh connection log
ssh -v git@your-server-ip
Check connection with server
ssh git@your-server-ip info

Reference

10.28.2010

OpenCV - how to create xml file for adaboost

Preparation

1. Install Open CV 2.1.0.0

2. Positive images
3. Negative images
4. ImageClipper (FreeSoftware)
5. KRename (file name)(FreeSoftware)

Steps


1. Create 3 folders
  • Negatives
  • Output
  • Positives
2. Copy two ".exe" files and some ".dll" files to "test folder" from OpenCV bin folder.

opencv_createsamples.exe

opencv_haartraining.exe

3. Use Image Clipper to label your feature on positive picture


4. ImageClipper


Label your feature


5. Use command under the folder for positives/imageclipper


dir /b /s > positives.txt

/b Uses bare format (no heading information or summary).
/s Displays files in specified directory and all subdirectories.
> Takes the output of dir and re-routes it to the file “xxx.txt” instead of outputting it to the screen

6. Use UltraEdit to modify input format

Filename [feature number] [x][y][w][h]


7. Create samples

opencv_createsamples.exe -info positives/positives.txt -vec output/positives.vec -num 515 -w 20 -h 20
[-info ]
[-vec ]
[-num ]
[-w ]
[-h ]

8. Haartraining

opencv_haartraining.exe -data output/dataALL -vec output/positives.vec -bg negatives/negatives.txt -mem 2048 -mode ALL -w 20 -h 20
[-data]
[-vec ]
[-bg ]
[-mem ]
[-mode ]
[-w ]
[-h ]

Reference

4.19.2010

Virtual Studio - how to collapse all code

  • CTRL + M + O  will collapse all.
  • CTRL + M + L  will expand all.
  • CTRL + M + P  will expand all and disable outlining.
  • CTRL + M + M will collapse/expand the current section.
Reference