OAuth2.0
Refs
What is OAuth 2.0 ?
The industry-standard protocol for authorization.
This specification and its extensions are being developed within the IETF OAuth Working Group.
The industry-standard protocol for authorization.
This specification and its extensions are being developed within the IETF OAuth Working Group.
Smaller, more expressive, more robust.
VS Epxress
The key difference between Koa and Express is how they handle middleware. Express includes routing and templates in the application framework. Koa, on the other hand, requires modules for these features, therefore making it more modular or customizable.
Functions follow the computer-science definition in that they MUST return a value and cannot alter the data they receive as parameters (the arguments). Functions are not allowed to change anything, must have at least one parameter, and they must return a value. Stored procs do not have to have a parameter, can change database objects, and do not have to return a value.
1 | -- create a procedure: |
1 | create table customers ( |
A cursor is a pointer that points to the result of a query.
There are two types of cursors:
Cursor attributes
Attribute | Description |
---|---|
%FOUND | Returns TRUE if an INSERT, UPDATE, or DELETE statement affected one or more rows or a SELECT INTO statement returned one or more rows. Otherwise, it returns FALSE. |
%NOTFOUND | The logical opposite of %FOUND. It returns TRUE if an INSERT, UPDATE, or DELETE statement affected no rows, or a SELECT INTO statement returned no rows. Otherwise, it returns FALSE. |
%ISOPEN | Always returns FALSE for implicit cursors, because Oracle closes the SQL cursor automatically after executing its associated SQL statement. |
%ROWCOUNT | Returns the number of rows affected by an INSERT, UPDATE, or DELETE statement, or returned by a SELECT INTO statement. |
If you run the examples in PL/SQL Developer, remember to run the code of the procedure creation in a program windows instead of a sql window. Sql window does not throw errors!
1 | DECLARE |
1 | DECLARE |
1 | CREATE OR REPLACE PROCEDURE greetings |
1 | DECLARE |
1 | DECLARE |
1 | DECLARE |
1 | CREATE TABLE employee ( |
This creates the following data:
EMP_ID | FIRST_NAME | LAST_NAME | DEPT_ID | MANAGER_ID | OFFICE_ID |
---|---|---|---|---|---|
1 | Sally | Jones | 3 | 2 | 5 |
2 | Mark | Smith | 2 | 4 | 3 |
3 | John | Andrews | 1 | 4 | 3 |
4 | Michelle | Johnson | 2 | 5 | |
5 | Brian | Grand | 2 | 2 | 3 |
1 | WITH d_count AS |
1 | WITH cteEmp(emp_id, |
EMP_ID | FIRST_NAME | MANAGER_ID | EMPLEVEL |
---|---|---|---|
4 | Michelle | 1 | |
2 | Mark | 4 | 2 |
3 | John | 4 | 2 |
1 | Sally | 2 | 3 |
5 | Brian | 2 | 3 |
The above result is generated in the following process:
where manager_id IS NULL
, which returns one row;UNION
query connecting a initial qery and a recursive query.FROM employee e, cteEmp r WHERE e.manager_id = r.emp_id
associates the original table with data from the initial query, returning more data;1 | -- Normal |
Build options:
Refresh types:
Trigger types:
Prebuilt:
Schedule:
START WITH ... NEXT ...
specifies a schedule.A materialized view can be refreshed either manually or as part of a refresh group or via a schedule.
Refresh manually:
1 | EXEC DMBS_MVIEW.refresh('mvt1'); |
Create a refresh group:
1 | BEGIN |
Create a schedule(must be specified at the creation of the materialized view):
1 | create materialized view mvt1 |
The materialized view mvt1
will be refreshed every minute. An Oracle job is also created at the same time.
To find out the job id, use this query:
1 | select m.owner, m.mview_name, r.job |
mvtt
:ind | name |
---|---|
1 | a |
1 | create materialized view mvt1 |
Now mvt1
has the same data as mvtt
. Insert a new row will not trigger an update in mvtt
because its trigger type is on demand
.
analytic_function([ arguments ]) OVER (analytic_clause)
[ query_partition_clause ] [ order_by_clause [ windowing_clause ] ]
1 | CREATE TABLE emp ( |
1 | SELECT empno, deptno, sal, |
NULL
values to last in ASC
order and first in DESC
MAX
and MIN
ignores NULL
values1 | SELECT empno, |
order_by_clause
, can only be used when order_by_clause
is present.order_by_clause
, a default windowing clause is attached: RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
1 | RANGE BETWEEN start_point AND end_point |
1 | SELECT empno, deptno, sal, |
1 | SELECT empno, deptno, sal, |
LAG
: Access the row at a given offset prior of the current row without using a self-join.1 | LAG(expression [, offset ] [, default ]) |
1 | SELECT e.empno, |
SUM
also supports windowing:1 | SELECT e.empno, |
1 | create public database link |
1 | -- user和password都不需要引号,如果passwrd有特殊字符,那就用双引号""包起来 |
Find all database links:
INSERT ALL
to insert multiple rows:1 | CREATE TABLE employee ( |
1 | CREATE OR REPLACE FUNCTION MD5( |
Regexper: Visulization tool for Regexp
Regex101: Write, test and debug Regexp
Syntax | Description |
---|---|
Special Characters | |
\n | New line. |
\f | Form feed. |
\r | Return. |
\s | Space. |
\t | Tab. |
\v | Vertical tab. |
[\b] | Backspace. As \b refers to boundary (see below), [] is used to differentiate backspace and boundary. |
Repeats | |
? | Zero or one occurrence. |
* | Zero or more occurrences. |
{x} | X times. |
{min, max} | min to max times. If max not given, then it means at least min times. |
Margins | |
\b | Boundary. Matches a pseudo position between word character \w and non-word character \W . Often used to extract single word. Match /\bcat\b/ in The cat scattered his food will not match cat in scattered as cat in scattered is surrounded by word character s and t . |
\B | Non-boundary. |
^ | Start of string. |
$ | End of string. |
Modifiers | |
/m | Multiple line. |
/i | Ignore case. |
/g | Global. |
Sub-expression | |
Sub-expression | Expression within brackets ( and ) is a sub-expression. |
Backreference | Use \1 , \2 in the back to reference the first, second expression in the front. Example: Use \b(\w+)\s\1 to match two continuous same words in Hello what what is the first thing, and I am am Tom. . |
Non-capturing group | Use (?:) to avoid being captured. Example: Using (Chendongti)(?:an) to match Chendongtian will only return one group Chendongti , an is not captured. |
Lookahead | Use (?=) /(?!) to add a must-have/must-not-have suffix. Example: Using happ(?=ily) to match happ happily will only return happ in happily , and happ(?!ily) will only return happ in happy . |
Lookbehind | Use (?<=) /(?<!) to add must-have/must-not-have prefix. Example: Using (?<=ap)ple to match apple people will only return ple in apple , and (?<!ap)ple will only return ple in people . |
Logical operators | |
NOT | ^ . [^abc] . |
OR | | . (a|b) . |
An distributed in-memory key-value database.
distributed: redis can scale from a single instance to a distributed system.
in-memory: that’s why redis is fast and commonly serves as cache.
key-value: redis stores key-value pairs.
As an in-memory cache, redis is much faster than traditional RDBMS.
Helps reduce database workload.
Server: See offical install procedure here.
As no offical windows install file provided, tporadowski provides an unoffical install file.
Client: redis server ships with a cli tool redis-cli
. For GUI client, check RedisInsight out.
redis.windows-service.conf
: Configuration file for windows service.reids.windows.conf
: Configuration file for command line.
Default redis requires no auth, but cannot access from machine other than localhost.
To enable remote access (only tested on windows):
In file redis.windows-service.conf
:
bind 127.0.0.1
(line 64). This makes redis listen to all interfaces.procted-mode yes
to protected-mode no
(line 83). All clients are now able to connect in.requirepass foobared
(line 503) and replace foobared
to your own password.Type | Description |
---|---|
Hash | Key-value dictionary object. |
Sorted Set | Sorted set. |
Set | Unsorted set. |
String | Simplest type. String or number. |
List | Linked list under the hood. Can add element to the head/left or the tail/right. |
JSON | JSON object. Requires RedisJSON module be installed. |
redis-cli
: connects to localhost on port 6379.redis-cli -h [host] -p [port] -a [password]
: connect to specified host and port. If password contains special character, wrap it in quotes.
Note that redis
does not work in browser environment.
A running chrome consists of multiple process. Each tab is an isolated process.
A tab process consisits of multiple threads. Among them the important ones includes:
setTimeout
, setInterval
. Timer thread should be stand-alone as running of other function may affect timing accuracy.Javascript, well-known for its asynchronism.
Synchronous functions runs and gets result. When function is slow (e.g. has file I/O or web request operations), it waits.
Asynchronous functions runs and expects result. The function does not wait for result, instead it leaves a callback function there to handle future result, and it moves on.
Asynchronism makes Javascript run without idle time. That’s why javascript is fast.
Browsers gives us Web APIs to handle callbacks. Functions like AJAX
, setTimeout
call these APIs.
Web APIs push callbacks into callback queue. Callbacks wait to be executed in the future.
Event loop watches call stack and callback queue. If call stack is empty, event loop takes one callback from callback queue and javascript engines executes the callback.
Callback queue is not only one but two queue: macrotask queue and microtask queue.
Everytime event loop is triggered, it takes all microtasks and one macrotask. Microtasks are executed first.
Macrotasks: setTimeout
, setInterval
, setImmediate
, I/O operations, UI rendering
Microtasks: Promise
, process.nextTick
, MutationObserver
A lightweight markup language which formats content by its simple syntax.
Eveywhere, for everything.
Websites like Reddit, Github, etc. support markdown. Documents, notes, books, emails and so on support markdown. WYSIWYG files are mostly only supported by its own editor.
Human readable. Markdown files are in plain text which is human readable. WYSIWYG files are not.
Portable. As markdown files are written in plain text, it can be created on any device, any operating system. And almost all platforms supports rendering of markdown.
Online editor: Dillinger
Client editor: Marktext, a realtime rendering editor
Element | Syntax |
---|---|
Heading | # Heading 1 ## Heading 2 ### Heading 3 |
Bold | **bold text** |
Italic | *Italic* |
Blockquote | > blockquote |
List | 1. First Item 2. Second Item 3. Third Item - First Item - Second Item - Third Item |
Code | `code` |
Horizontal rule | --- |
Link | [title](https://www.example.com) |
Image | ![alt text](image.jpg) |
Element | Syntax |
---|---|
Table | | Syntax | Description | | ———– | ———– | | Header | Title | | Paragraph | Text | Note that there must be a blank line after the table. |
Fenced code block | ```{ firstname: ‘dongtian’, lastname: ‘chen’ }``` Use ``` [language] to specify code block language, for example ``` js to specify javascript. See supported language here |
Footnote | Here’s a sentence with a footnote. [^1] [^1]: This is the footnote. |
Definition List | term : definition |
Strikethrough | ~~The world is flat.~~ |
Task List | - [x] Write the press release - [ ] Update the website - [ ] Contact the media |
Emoji | That is so funny! 😂 |
Highlight | I need to highlight these ==very important words==. |
Subscript | H~2~O |
Superscript | X^2^ |
1 | > <div class="poetry">满堂花醉三千客,一剑霜寒十四州。</div> |
1 | > ⚠ **If you are using mobile browser**: Be very careful here! |
1 | > Case 1 |
will produce:
Case 1
00:23
00:54
Case 2
00:21
00:51
or an easier one(leave one space at the beginning of the second line and so on):
1 | > line 1 |
will produce:
line 1
line 2
line 3
Use diff
directive:
1 | ``` diff |
gives:
1 | - I like markup |
1 | ``` js, test.js |
gives:
1 | console.log('hello!') |
Use 2 or 4 spaces:
1 | # Unordered list |