Thursday, 5 October 2017

Heroku commands

Set Environment Variable
$ heroku config:set variable=value


Check Logs
$ heroku log


Login to remote shell
$ heroku run bash 

Saturday, 30 September 2017

Install Openproject on ubuntu

wget -qO- https://dl.packager.io/srv/opf/openproject-ce/key | sudo apt-key add -

sudo wget -O /etc/apt/sources.list.d/openproject-ce.list \
  https://dl.packager.io/srv/opf/openproject-ce/stable/7/installer/ubuntu/16.04.repo

sudo apt-get update
sudo apt-get install openproject

Monday, 3 July 2017

Ubuntu/Linux Fix Wifi On Dell Latitude

Wifi not working/detecting any network on Dell Latitude



sudo apt-get update
sudo apt-get install firmware-b43-installer

and restart the computer.

It worked for me on Dell Latitude,
I think this should work on other Laptops/Systems also.

Saturday, 29 April 2017

Create swap on USD drive for Linux

 - Unmount the USB drive
$ sudo umount /media/sdb1

- To watch the disk label as we have used here sdb1 yours might be different,
use the following and make sure which one is your pen drive with the consideration of size,
and sdb1 is just used here for exampling and explaining -

$ sudo fdisk -l

- Create swap on you pen drive by-
$ sudo mkswap /dev/sdb1

- Turn it on by:
$ sudo swapon -p 32767 /dev/sdb1

- To check its working use
$ cat /proc/swaps

Saturday, 11 February 2017

Things to do after fresh/first install of Ubuntu

These notes are written wrt Ubuntu 16.x



Click to minimize an app from taskbar

Run this command:-
gsettings set org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ launcher-minimize-window true


Install Linux Graphics Drivers

    1. Open up the ‘Software & Updates’ tool from the Unity Dash
    2. Click the ‘Additional Drivers’ tab
    3. Follow any on-screen prompts to check for, install and apply any changes

Check for best driver option for your NVidia Graphics cards.

Install System Cleaner

Install Development Tools

Saturday, 28 January 2017

AOSP - Android Source Building Comprehensive Guide

Binaries Generated By The Build

1. boot.img
boot.img contains the kernel and ramdisk, critical files necessary to load the device before the filesystem can be mounted. You have to generate the boot.img yourself using mkbootimg, a tool provided by AOSP.

2.kernel
Binary for linux kernel.

3. ramdisk.img
ramdisk.img is a small partition image that is mounted read-only by the kernel at boot time.
It only contains /init and a few config files.
It is used to start init which will mount the rest of the system images properly and run the init procedure.

A Ramdisk is a standard Linux feature.


4. ramdisk-recovery.img
Recovery image for ramdisk.

5. recovery.img
It is the Android recovery image.

A bootable program on an Android flash memory partition that is used to perform a factory reset or restore the original OS version. In order to install a different OS version (a different ROM), the stock recovery image must be replaced with a custom version such as ClockworkMod Recovery. After rooting the Android, utilities such as ROM Manager install the custom recovery, which is then used to install the custom ROM.

6. userdata.img
userdata.img is a partition image that can be mounted as /data and thus contains all application-specific and user-specific data.   

7. system.img
system.img is a partition image that will be mounted as / and thus contains all system binaries

8. full_mako-img-eng.nsk.zip
A full update is one where the entire final state of the device (system, boot, and recovery partitions) is contained in the package. As long as the device is capable of receiving the package and booting the recovery system, the package can install the desired build regardless of the current state of the device.

Friday, 27 January 2017

Linux Troubleshooting

1. How do I fix a “Problem with MergeList” or “status file could not be parsed” ?

sudo rm -vf /var/lib/apt/lists/*
sudo apt-get update


2. How to run 32 bit binaries on 64 bit Linux ?

sudo dpkg --add-architecture i386

Or if you are using Ubuntu 12.04 LTS (Precise Pangolin) or below, use this:

echo "foreign-architecture i386" > /etc/dpkg/dpkg.cfg.d/multiarch

Then:

sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

3. How to remove openjdk ?

sudo apt-get purge openjdk*

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"

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


Friday, 26 August 2016

How to create windows USB installer from windows CD/DVD ?

sudo dd if=/dev/cdrom of=/home/username/image.iso



sudo dd if=/home/username/image.iso of=/dev/sdb


here sdb is your USB drive, change it, it can be /dev/sdc etc.

Tuesday, 19 July 2016

Ubuntu get wifi password

cd etc/NetworkManager/system-connections/ 

sudo cat WIFI_SSID_Name  

“psk”=”PASSWORD”

Monday, 18 July 2016

Heroku Django Commands

Useful commands:
  • heroku run python manage.py migrate
  • heroku config:set DISABLE_COLLECTSTATIC=1

Initialize repo

clone your existing repo from git, remove .git and do following


$ cd my-project/
$ git init
$ heroku git:remote -a quickorders
 
Login to remote shell
$ heroku run bash 


References:
  • https://devcenter.heroku.com/articles/getting-started-with-python#push-local-changes
  • https://devcenter.heroku.com/articles/deploying-python
  • https://devcenter.heroku.com/articles/django-app-configuration


Tips:
  • Do "git push" migrations files