Tuesday, February 11, 2020

书单

https://www.greatschools.org/gk/book-lists/

https://developer.mozilla.org/en-US/docs/Learn

Tools

Cmder:

https://github.com/cmderdev/cmder

Tab manipulation

  • Ctrl + T : New tab dialog (maybe you want to open cmd as admin?)
  • Ctrl + W : Close tab
  • Ctrl + D : Close tab (if pressed on empty command)
  • Shift + Alt + #Number : Fast new tab: 1 - CMD, 2 - PowerShell
  • Ctrl + Tab : Switch to next tab
  • Ctrl + Shift + Tab : Switch to previous tab
  • Ctrl + #Number : Switch to tab #Number
  • Alt + Enter: Fullscreen

Shell

  • Ctrl + Alt + U : Traverse up in directory structure (lovely feature!)
  • EndHomeCtrl : Traversing text with as usual on Windows
  • Ctrl + R : History search
  • Shift + Mouse : Select and copy text from buffer


Windows Screenshot:
https://www.digitalcitizen.life/4-ways-take-screenshots-windows-8-81-using-built-tools

Windows + Shift + S (Windows 10 only)

























Django

Setup:

A Complete Beginner's Guide (Catoon)
1 Python
Mac homebrew -> python3

2 Virualenv
pip3 install virtualenv (homebrew installed pip when install python)

3 Django
in a newly made project directory, activate virtual environment before install Django
virtualenv venv -p python3
source venv/bin/activate
pip install django

https://www.youtube.com/watch?v=tptRTf3IWrM

1 Python
cmd





request.POST.get('sth') vs request.POST['sth'] - difference?

request.POST['sth'] will raise a KeyError exception if 'sth' is not in request.POST.

request.POST.get('sth') will return None if 'sth' is not in request.POST.



How to check if django form data is None, ' ' (empty string), or False

The problem is that by checking for:
 if form.data['first_name'] is None:
Only checks for if the value is None, where as:
if form.data['first_name']:
Checks for None or '' an empty string or False come to that.
What you could also do is:
return bool(form.data.get('first_name', False))
In this case if form.data['first_name'] is not present it will return False, if the value is None or '' this will also return False, if the value is True or 'a string' it will return True.

create project inside git repository directory with different project name other than creating sub-directory.
https://automationpanda.com/2018/02/06/starting-a-django-project-in-an-existing-directory/



SSH tunneling:

 vagrant ssh -- -N -L 8000:127.0.0.1:8000 in host
https://stackoverflow.com/questions/18157353/connection-reset-when-port-forwarding-with-vagrant



Django form with choices but also with input option
https://stackoverflow.com/questions/24783275/django-form-with-choices-but-also-with-freetext-option
https://stackoverflow.com/questions/16055808/django-form-dropdown-list-of-stored-models



OT:
Postgres full-text search is Good Enough!
http://rachbelaid.com/postgres-full-text-search-is-good-enough/

Postgres Full-Text Search With Django 
http://blog.lotech.org/postgres-full-text-search-with-django.html

Storing Images In DB Using Django Models
https://stackoverflow.com/questions/18747730/storing-images-in-db-using-django-models

https://wsvincent.com/django-search/

$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.6
https://docs.python-guide.org/starting/install3/linux/

ManyToMany field and FliterSelectMultiple:

ORM relationship cheatsheet:
https://hackernoon.com/django-orm-relationships-cheat-sheet-14433d6cf68c

Django Models: Setting up Many-to-Many Relationships through Intermediate Models
https://medium.com/@aswinshenoy/django-admin-setting-up-many-to-many-relationships-with-intermediate-models-782895cb48b2

Django Document Form fields:
https://docs.djangoproject.com/en/dev/ref/forms/fields/#django.forms.ModelMultipleChoiceField

Django - Use the Django admin app's FilteredSelectMultiple widget in form
- January 29, 2014
https://www.dangtrinh.com/2014/01/django-use-django-admin-apps.html

https://stackoverflow.com/questions/55859820/how-to-create-the-same-form-in-group-and-permission-on-django-templates

https://stackoverflow.com/questions/43419030/django-modelmultiplechoicefield-widget-not-rendering

https://hackernoon.com/django-orm-relationships-cheat-sheet-14433d6cf68c

https://stackoverflow.com/questions/57820652/need-guidance-with-filteredselectmultiple-widget

https://github.com/jazzband/django-sortedm2m

FilteredSelectMultiple does not respect order
https://code.djangoproject.com/ticket/15881

https://stackoverflow.com/questions/10366045/django-how-to-save-data-to-manytomanyfield




https://stackoverflow.com/questions/10583652/uncaught-referenceerror-django-is-not-defined


Redefine eligible student QuerySet
http://www.columbia.edu/~njn2118/journal/2016/1/29.html




























windows ubuntu

PS C:\Users\littl> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

PS C:\Users\littl> bash -c "ls -ltr"

PS C:\Users\littl> Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile Ubuntu.appx -UseBasicParsing

PS C:\Users\littl> Add-AppPackage .\Ubuntu.appx

PS C:\Users\littl> bash -c "vi .gitignore"

PS C:\Users\littl> git config --global user.email "lz.fcla@gmail.com"

PS C:\Users\littl> git config --global user.name "Liang Zhong"

PS C:\Users\littl> git remote add origin git@github.com:liangzhong/hello-world-standalone.git