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"

Monday, 19 September 2016

Nodejs Cheat Sheet


Install express and save it locally in nodejs module list
$ npm install express --save


Thursday, 1 September 2016

Some useful SQL queries

Get Distinct records

select distinct name from user;


Get Repeated records

SELECT
    name, email, COUNT(*)
FROM
    user
GROUP BY
    name, email
HAVING
    COUNT(*) > 1

Monday, 29 August 2016

postgres commands cheatsheet

$ sudo -i -u postgres
$ psql


Create new database
CREATE DATABASE schooldb;

Create new user
CREATE USER schooluser;

Change Password
ALTER USER schooluser with PASSWORD 'pass123';

Change database owner
ALTER database schooldb owner to schooluser;

Rename database name
ALTER DATABASE name RENAME TO newname
Grant All Permissions to database
grant all privileges on database dbname to dbuser;
GRANT ALL ON DATABASE somedb TO someuser;

Show databases
\l


Show tables
\dt


Connect to db
\c schooldb