29 June 2021

CSS for 5 Typical Media Query Break Points (Device Screen Sizes)

CSS for 5 Typical Media Query Break Points (Device Screen Sizes)


<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>

/* Typical device breakpoints - 5 groups */

/* Extra small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) {
  [class*="col-"] {width: 100%; }
}

/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {
  .col-min600-1 {width: 8.33%;}
  .col-min600-2 {width: 16.66%;}
  .col-min600-3 {width: 25%;}
  .col-min600-4 {width: 33.33%;}
  .col-min600-5 {width: 41.66%;}
  .col-min600-6 {width: 50%;}
  .col-min600-7 {width: 58.33%;}
  .col-min600-8 {width: 66.66%;}
  .col-min600-9 {width: 75%;}
  .col-min600-10 {width: 83.33%;}
  .col-min600-11 {width: 91.66%;}
  .col-min600-12 {width: 100%;}
}

/* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {
  .col-min768-1 {width: 8.33%;}
  .col-min768-2 {width: 16.66%;}
  .col-min768-3 {width: 25%;}
  .col-min768-4 {width: 33.33%;}
  .col-min768-5 {width: 41.66%;}
  .col-min768-6 {width: 50%;}
  .col-min768-7 {width: 58.33%;}
  .col-min768-8 {width: 66.66%;}
  .col-min768-9 {width: 75%;}
  .col-min768-10 {width: 83.33%;}
  .col-min768-11 {width: 91.66%;}
  .col-min768-12 {width: 100%;}
}

/* Large devices (laptops/desktops, 992px and up) */
@media only screen and (min-width: 992px) {
  .col-min992-1 {width: 8.33%;}
  .col-min992-2 {width: 16.66%;}
  .col-min992-3 {width: 25%;}
  .col-min992-4 {width: 33.33%;}
  .col-min992-5 {width: 41.66%;}
  .col-min992-6 {width: 50%;}
  .col-min992-7 {width: 58.33%;}
  .col-min992-8 {width: 66.66%;}
  .col-min992-9 {width: 75%;}
  .col-min992-10 {width: 83.33%;}
  .col-min992-11 {width: 91.66%;}
  .col-min992-12 {width: 100%;}
}

/* Extra large devices (large laptops and desktops, 1200px and up) */
@media only screen and (min-width: 1200px) {
  .col-min1200-1 {width: 8.33%;}
  .col-min1200-2 {width: 16.66%;}
  .col-min1200-3 {width: 25%;}
  .col-min1200-4 {width: 33.33%;}
  .col-min1200-5 {width: 41.66%;}
  .col-min1200-6 {width: 50%;}
  .col-min1200-7 {width: 58.33%;}
  .col-min1200-8 {width: 66.66%;}
  .col-min1200-9 {width: 75%;}
  .col-min1200-10 {width: 83.33%;}
  .col-min1200-11 {width: 91.66%;}
  .col-min1200-12 {width: 100%;}
}

</style>
</head>

<body>

</body>

</html>

27 June 2021

How to obtain same effect as 'less' in Linux in mysql?

 How to obtain same effect as 'less' in Linux in mysql?


i.e. the output display stops at the first screen, before you can move the output in vi way.

$pager less

$select * from table;

Furthermore, use -

$pager less

$select * from table\G

so that fields are displayed from up to down, instead of from left to right.

On Ubuntu, Creating Virtual Environments

On Ubuntu, creating Virtual Environments

https://packaging.python.org/tutorials/installing-packages/#creating-and-using-virtual-environments

python3 -m venv <DIR>
source <DIR>/bin/activate

 '<DIR>' is actually your site name, e.g. 'mysite'.

26 June 2021

On Windows, How to Install, Create and Activate a Python Virtual Environment (Project) for Django? mkvirtualenv is not recognized as an internal or external command, operable program or batch file

 (For Windows)

How to Install, Create and Activate a Python Virtual Environment (Project) for Django? 

mkvirtualenv is not recognized as an internal or external command, operable program or batch file


https://stackoverflow.com/questions/56778211/error-message-mkvirtualenv-is-not-recognized-as-an-internal-or-external-command


For Python 3.3 or newer, Commands for installing, creating and activate virtual environment has been changed.

You can install virtual environment using pip:

py -m pip install --user virtualenv

For creating new environment:

py -m venv myproject

To activate your virtual environment:

.\myproject\Scripts\activate

After activating virtual environment, You’ll see “(myproject)” next to the command prompt.

20 June 2021

How to list all html files in a directory recursively sorted by file size?

 How to list all html files in a directory recursively sorted by file size?

$du -a -h | sort -nr | grep 'html' | less

Note:

1. '-a' means all files and directories, not just directories.

2. '-h' means human readable.

3. '-n' means numeric sort.

4. '-r' means recursive.

How to clean up unnecessary files and optimise the local repository

 How to clean up unnecessary files and optimise the local repository?

$git gc

11 June 2021

The Best Website on Which You Draw Charts and Diagrams

 The Best Website on Which You Draw Charts and Diagrams

http://lucid.app


How to create an alias command in git to display a log in graph?

How to create an alias command in git to display a log in graph?


$alias graph="git log --all --oneline --graph  --decorate"

(I find that it outputs the same as without '--decorate'.)

Note:

'--oneline' is a shorthand for both '--pretty=oneline' and  '--abbrev-commit' used together.

-----------------------------------------------------------------------------------------

I find the 2 following commands are very helpful,

1.

$git log --all --oneline --graph

2.

$git show-branch --all --more=1000

(you can replace 1000 with any number, according to your requirements.)

08 June 2021

How to undo (almost) anything with Git

How to undo (almost) anything with Git


https://github.blog/2015-06-08-how-to-undo-almost-anything-with-git/



 

checkout, reset, restore, revert, and switch. What do they really do?

 checkout, reset, restore, revert, and switch. What do they really do?

Written by torek, etc.


https://stackoverflow.com/questions/58003030/what-is-the-git-restore-command-and-what-is-the-difference-between-git-restor


The whole page is useful, especially from 'To add to VonC's answer, and bring into the picture all the relevant commands, in alphabetical order, I will cover:'

I also like -

$git restore -s@ -SW -- <file> 

above the aforesaid section.



07 June 2021

How to undo and redo in git?

 How to undo and redo in git?

For both undo and redo, use git reflog and git reset --hard head@{n}

You will find n in the result of git reflog.

06 June 2021

How to find what the git merge conflicts are?

 How to find what the git merge conflicts are?

After you run
$git merge <branch name 2>

If the merge failed, and it said that there was a conflict, the error message would tell you in which file the conflict was - 'Merge conflict in <file name>'.

Run -
$git diff <current branch name> <branch name 2> <file name>

you will get what the conflict is. Content in red is the change done in <current branch name>, and that in green is the change done in <branch name 2>.



01 June 2021

My '_vimrc' File

source $VIMRUNTIME/vimrc_example.vim


set diffexpr=MyDiff()

function MyDiff()

  let opt = '-a --binary '

  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif

  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif

  let arg1 = v:fname_in

  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif

  let arg1 = substitute(arg1, '!', '\!', 'g')

  let arg2 = v:fname_new

  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif

  let arg2 = substitute(arg2, '!', '\!', 'g')

  let arg3 = v:fname_out

  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif

  let arg3 = substitute(arg3, '!', '\!', 'g')

  if $VIMRUNTIME =~ ' '

    if &sh =~ '\<cmd'

      if empty(&shellxquote)

        let l:shxq_sav = ''

        set shellxquote&

      endif

      let cmd = '"' . $VIMRUNTIME . '\diff"'

    else

      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'

    endif

  else

    let cmd = $VIMRUNTIME . '\diff'

  endif

  let cmd = substitute(cmd, '!', '\!', 'g')

  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3

  if exists('l:shxq_sav')

    let &shellxquote=l:shxq_sav

  endif

endfunction



        " 字符编码{{{

" Vim显示的编码(设置这个不会改变文件的编码){

        if has('win32') || has('win64')

        set encoding=utf-8

        set termencoding=chinese

        endif

" }

" 编辑已存在的文件时的参考文件编码.需要注意顺序,前面的字符集应该比后面的字符集大{

        set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1

" }

" }}}

"

"

filetype plugin indent on

autocmd FileType html setlocal shiftwidth=2 tabstop=2

autocmd FileType python setlocal expandtab shiftwidth=4 softtabstop=4

set number

"

" The following commands do not work

" autocmd FileType html 

" set omnifunc=htmlcomplete#CompleteTags


" The following commands do not work

" set omnifunc=csscomplete#CompleteCSS

" autocmd FileType css set omnifunc=csscomplete#CompleteCSS


" html css class id auto complete 

" https://github.com/Shougo/neocomplete.vim

let g:neocomplete#enable_at_startup = 1