Skip to content

Instantly share code, notes, and snippets.

View asadlive84's full-sized avatar

Asaduzzaman Sohel asadlive84

View GitHub Profile
@asadlive84
asadlive84 / django_deploy.md
Created September 16, 2019 05:51 — forked from bradtraversy/django_deploy.md
Django Deployment - Digital Ocean

Django Deployment to Ubuntu 18.04

In this guide I will go through all the steps to create a VPS, secure it and deploy a Django application. This is a summarized document from this digital ocean doc

Any commands with "$" at the beginning run on your local machine and any "#" run when logged into the server

Create A Digital Ocean Droplet

Use this link and get $10 free. Just select the $5 plan unless this a production app.

CTRL + Z => stops (pauses) a job
CTRL + C => terminates a job
Ctrl + L => Clear Terminal
Ctrl + C => terminates a job
# you comment in cmd => write you comment in terminal
Ctrl + E => Go to End into Any Line
Alt + F => Moving Forward in word into text line
@asadlive84
asadlive84 / django-wkhtmltopdf.py
Created September 1, 2019 04:11
django-wkhtmltopdf tricks
#install
pip install django-wkhtmltopdf
#settins.py
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
#views.py
class PDFView(PDFTemplateView):
model = Student
@asadlive84
asadlive84 / wkhtmltopdfOdoo.txt
Last active September 21, 2019 21:11
wkhtmltopdf for odoo
# for odoo
sudo wget https://builds.wkhtmltopdf.org/0.12.1.3/wkhtmltox_0.12.1.3-1~bionic_amd64.deb
sudo dpkg -i wkhtmltox_0.12.1.3-1~bionic_amd64.deb
sudo apt-get install -f
sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin
sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin
@asadlive84
asadlive84 / Odoopostgresql.txt
Last active September 22, 2019 20:18
Odoo CMD
sudo systemctl daemon-reload
sudo systemctl start odoo12
sudo systemctl enable odoo12
systemctl status postgresql
systemctl restart postgresql

PSQL

Magic words:

sudo -u postgres psql
If I remember correctly the user postgres has no DB password set on Ubuntu by default. That means, that you can login to that account only by using the postgres OS user account.
Assuming, that you have root access on the box you can do:
sudo -u postgres psql
If that fails with a database "postgres" does not exists error, then you are most likely not on a Ubuntu or Debian server :-) In this case simply add template1 to the command:
sudo -u postgres psql template1
If any of those commands fail with an error psql: FATAL: password authentication failed for user "postgres" then check the file /etc/postgresql/8.4/main/pg_hba.conf: There must be a line like this as the first non-comment line:
class EmployeeManger:
mydict={}
def add_employee(self,employee:"employee"):
try:
new_pk=max(self.mydict.keys())+1
except ValueError:
new_pk=1
self.mydict[new_pk]=employee
import urllib.request
#six: 1-33 and 34-92
#seven: 91-165
#eight:165-248
#nine:245-297
#ten:297-385
y=input()
print("%s" % (y, len(y), y[::-1]))