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


Friday, 15 July 2016

Django with docker


Create super user for django website
docker-compose run website python manage.py createsuperuser

 here website is the name of image


Run custom command in an image
docker run --rm -i -t --entrypoint=/bin/bash albums_website:latest

This will show following promot,
root@618a92c1d9c9:/code# python manage.py <command>



Run
Run the docker-compose up command.