Thursday, 26 January 2017

Linux rsync comand usage examples

rsync
-a
--progress
--delete = delete files/folders from /destination that are not on /source (so /destination is an exact mirror of /source)
--exclude
--dry-run
Always start with -n (fake run) before doing a real run.
-r = recursive (copy all directories, contents and their subdirectories)
-v = be verbose


1. Sync dirs
rsync -av --delete src/  dest/

2. With SSH
rsync -av –delete -e ssh /Directory1/ geek@192.168.235.137:/
Directory2/

3. With SSH and port
rsync -av –delete -e 'ssh -p 12345' /Directory1/ geek@192.168.235.137:/Directory2/

Saturday, 10 December 2016

dos and don'ts of writing c++ code

  1. Use namespaces - when you have huge code and classes, add them into a name spaces by categorizing them. Like a namespace for database, namespace for logger, namespace for ui etc. 
  2. Follow C++ coding conventions and remain consistent in project and with team ( and with global c++ community).
  3. In header files, avoid the use of forward declaration as much as possible and included the required header files.

Wednesday, 7 December 2016

Android create apk release with date

#
# script to create a release for apk with current date time
#

PROJECT="SpeedRiderApp"
DATE=`date +%Y-%m-%d`

echo "Preparing APK For ${PROJECT}"
echo "Removing previous releases of date: ${DATE}"

rm -fr "${HOME}/Desktop/${PROJECT}-${DATE}.apk" "${HOME}/Desktop/${PROJECT}-${DATE}" "${HOME}/Desktop/${PROJECT}-${DATE}.zip"

cp "app/build/outputs/apk/app-debug.apk"  "${HOME}/Desktop/${PROJECT}-${DATE}.apk"

echo "----- DONE MAKING APK -----"


cp -a . "${HOME}/Desktop/${PROJECT}-${DATE}"
cd "${HOME}/Desktop/${PROJECT}-${DATE}"

echo "Removing build"
rm -fr build

echo "Removing app/build"
rm -fr "app/build"

cd "${HOME}/Desktop/"
zip -r "${PROJECT}-${DATE}.zip" "${PROJECT}-${DATE}"

# back to project dir
cd -

Wednesday, 30 November 2016

Shell script To Make release zip for project

PROJECT="SpiritedRepublic"
DATE=`date +%Y-%m-%d`
DIR="${HOME}/Desktop/${PROJECT}-src-${DATE}"

# remove previous DIR
echo "removing $DIR"
rm -fr "$DIR"
mkdir "$DIR"

# python files
echo "Copying python files"
cp -a /home/neo/work/qt_projs/SpiritedRepublic/src/*.py "$DIR"

# ui files
echo "Copying ui files"
cp -a /home/neo/work/qt_projs/SpiritedRepublic/src/*.ui "$DIR"

# csv files
echo "Copying csv files"
cp -a /home/neo/work/qt_projs/SpiritedRepublic/src/*.csv "$DIR"

# shell script files
echo "Copying shell script files"
cp -a /home/neo/work/qt_projs/SpiritedRepublic/src/*.sh "$DIR"


# zip
ZIP_PATH="${DIR}.zip"
echo "Creating zip file at: ${ZIP_PATH}"
cd "${HOME}/Desktop"

zip -r "${PROJECT}-src-${DATE}.zip" . -i "${PROJECT}-src-${DATE}/*

Saturday, 22 October 2016

Cygwin Package Manager

wget raw.github.com/transcode-open/apt-cyg/master/apt-cyg
chmod +x apt-cyg
mv apt-cyg /usr/local/bin
Now that apt-cyg is installed. Here are few examples of installing some packages
apt-cyg install nano
apt-cyg install git
apt-cyg install ca-certificates

Tuesday, 18 October 2016

bashrc cool tips

# git commit push all modified files
gcpa() {
    echo "Commit Message: $1"

    echo "Commiting.................."
    git commit -am "$1"

    echo "Pushing...................."
    git push

    echo "Done......................."
}


example:
$ gcpa "Added logs"

# commit single file with msg
# equivalent to add, commit, push
gcpm() {
    echo "Committing: $1"
    echo "Message: $2"

    echo "Adding.................."
    git add "$1"

    echo "Commiting.................."
    git commit -m "$2"

    echo "Pushing...................."
    git push

    echo "Done......................."
}

# example
$ gcpm abc.py "Added exception handler"

bashrc cool tips

# git commit push all modified files
gcpa() {
    echo "Commit Message: $1"

    echo "Commiting.................."
    git commit -am "$1"

    echo "Pushing...................."
    git push

    echo "Done......................."
}


example:
$ gcpa "Added logs"

# commit single file with msg
# equivalent to add, commit, push
gcpm() {
    echo "Committing: $1"
    echo "Message: $2"

    echo "Adding.................."
    git add "$1"

    echo "Commiting.................."
    git commit -m "$2"

    echo "Pushing...................."
    git push

    echo "Done......................."
}

# example
$ gcpm abc.py "Added exception handler"