Last major update: 25.08.2020
- Что такое авторизация/аутентификация
- Где хранить токены
- Как ставить куки ?
- Процесс логина
- Процесс рефреш токенов
- Кража токенов/Механизм контроля токенов
| var mongoose = require('mongoose'); | |
| mongoose.connect('mongodb://localhost/foobar'); | |
| // bootstrap mongoose, because syntax. | |
| mongoose.createModel = function(name, options) { | |
| var schema = new mongoose.Schema(options.schema); | |
| for (key in options.self) { | |
| if (typeof options.self[key] !== 'function') continue; | |
| schema.statics[key] = options.self[key]; | |
| } |
| ### Example #1 ### | |
| $ docker ps -a | |
| CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
| 2e23d01384ac iperf-v1:latest "/usr/bin/iperf -s" 10 minutes ago Up 10 minutes 5001/tcp, 0.0.0.0:32768->5201/tcp compassionate_goodall | |
| # Append the container ID (CID) to the end of an inspect | |
| $ docker inspect --format '{{ .NetworkSettings.IPAddress }}' 2e23d01384ac | |
| 172.17.0.1 | |
| ### Example #2 ### | |
| # Add -q to automatically parse and return the last CID created. |
| HTML: | |
| <div class="wrapper"> | |
| <div class="tabs"> | |
| <span class="tab">Вкладка 1</span> | |
| <span class="tab">Вкладка 2</span> | |
| <span class="tab">Вкладка 3</span> | |
| </div> | |
| <div class="tab_content"> | |
| <div class="tab_item">Содержимое 1</div> | |
| <div class="tab_item">Содержимое 2</div> |
Magic numbers are the first bits of a file which uniquely identify the type of file. This makes programming easier because complicated file structures need not be searched in order to identify the file type.
For example, a jpeg file starts with ffd8 ffe0 0010 4a46 4946 0001 0101 0047 ......JFIF.....G ffd8 shows that it's a JPEG file, and ffe0 identify a JFIF type structure. There is an ascii encoding of "JFIF" which comes after a length code, but that is not necessary in order to identify the file. The first 4 bytes do that uniquely.
This gives an ongoing list of file-type magic numbers.
| // from http://scratch99.com/web-development/javascript/convert-bytes-to-mb-kb/ | |
| function bytesToSize(bytes) { | |
| var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; | |
| if (bytes == 0) return 'n/a'; | |
| var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); | |
| if (i == 0) return bytes + ' ' + sizes[i]; | |
| return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i]; | |
| }; |