├── README.md ├── index.html ├── parse.js ├── pdf ├── Acrobat │ ├── Chapter_1.xml │ ├── bottom_line.xml │ ├── chapter_2.xml │ ├── chapter_3.xml │ ├── chapter_4.xml │ ├── chapter_5.xml │ ├── chapter_6.xml │ ├── chapter_7.xml │ ├── chapter_8.xml │ ├── even_pages.xml │ └── odd_pages.xml ├── README.md ├── create_index.py ├── descripitive_image_final-01.png ├── descripitive_image_final.png ├── index_for_pdf.html ├── index_for_pdf_print.html ├── popup.html └── remove_links.py └── web ├── OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1 ├── @font-face │ ├── 9f94dc20bb2a09c15241d3a880b7ad01.eot │ ├── 9f94dc20bb2a09c15241d3a880b7ad01.svg │ ├── 9f94dc20bb2a09c15241d3a880b7ad01.ttf │ ├── 9f94dc20bb2a09c15241d3a880b7ad01.woff │ ├── 9f94dc20bb2a09c15241d3a880b7ad01.woff2 │ └── Demo.html ├── License.txt ├── Menlo Regular │ ├── Menlo Regular.eot │ ├── Menlo Regular.svg │ ├── Menlo Regular.ttf │ ├── Menlo Regular.woff │ └── Menlo Regular.woff2 └── Online_Web_Fonts.url ├── OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88 ├── License.txt ├── Menlo Bold │ ├── @font-face │ │ ├── Demo.html │ │ ├── a6ffc5d72a96b65159e710ea6d258ba4.eot │ │ ├── a6ffc5d72a96b65159e710ea6d258ba4.svg │ │ ├── a6ffc5d72a96b65159e710ea6d258ba4.ttf │ │ ├── a6ffc5d72a96b65159e710ea6d258ba4.woff │ │ └── a6ffc5d72a96b65159e710ea6d258ba4.woff2 │ ├── Menlo Bold.eot │ ├── Menlo Bold.svg │ ├── Menlo Bold.ttf │ ├── Menlo Bold.woff │ └── Menlo Bold.woff2 └── Online_Web_Fonts.url ├── continents.csv ├── convert_table.py ├── covid_cases.js ├── covid_cases.png ├── covid_deaths.js ├── covid_deaths.png ├── default.min.css ├── default_dark.min.css ├── default_dark1.min.css ├── default_dark2.min.css ├── default_dark3.min.css ├── empty_script.py ├── faq.html ├── favicon.png ├── highlight.min.js ├── image_720.jpeg ├── image_888.jpeg ├── image_960.jpeg ├── image_orig.jpeg ├── image_orig_blue6.png ├── image_social.jpeg ├── image_social_2.png ├── image_social_3.png ├── image_social_4.png ├── image_social_bckp.png ├── image_twitter_card.jpeg ├── image_twitter_card_2.jpeg ├── jquery-3.4.0.min.js ├── jquery-3.4.0.slim.min.js ├── mario_bros.png ├── plotly.min.js ├── script_2.js ├── showdown.min.js ├── style.css ├── style_dark.css ├── style_dark1.css ├── style_dark2.css ├── style_dark3.css ├── template.html ├── twitter_card_large.jpeg ├── twitter_card_large_bckp.jpeg └── update_plots.py /pdf/Acrobat/Chapter_1.xml: -------------------------------------------------------------------------------- 1 | /
-------------------------------------------------------------------------------- /pdf/Acrobat/bottom_line.xml: -------------------------------------------------------------------------------- 1 | /
__________________________________________________________________________________________________________
-------------------------------------------------------------------------------- /pdf/Acrobat/chapter_2.xml: -------------------------------------------------------------------------------- 1 | /
| Chapter 2: Types
-------------------------------------------------------------------------------- /pdf/Acrobat/chapter_3.xml: -------------------------------------------------------------------------------- 1 | /
| Chapter 3: Syntax
-------------------------------------------------------------------------------- /pdf/Acrobat/chapter_4.xml: -------------------------------------------------------------------------------- 1 | /
| Chapter 4: System
-------------------------------------------------------------------------------- /pdf/Acrobat/chapter_5.xml: -------------------------------------------------------------------------------- 1 | /
| Chapter 5: Data
-------------------------------------------------------------------------------- /pdf/Acrobat/chapter_6.xml: -------------------------------------------------------------------------------- 1 | /
| Chapter 6: Advanced
-------------------------------------------------------------------------------- /pdf/Acrobat/chapter_7.xml: -------------------------------------------------------------------------------- 1 | /
| Chapter 7: Libraries
-------------------------------------------------------------------------------- /pdf/Acrobat/chapter_8.xml: -------------------------------------------------------------------------------- 1 | /
| Chapter 8: Multimedia
-------------------------------------------------------------------------------- /pdf/Acrobat/even_pages.xml: -------------------------------------------------------------------------------- 1 | /
-------------------------------------------------------------------------------- /pdf/Acrobat/odd_pages.xml: -------------------------------------------------------------------------------- 1 | /
-------------------------------------------------------------------------------- /pdf/README.md: -------------------------------------------------------------------------------- 1 | How To Create PDF (on macOS) 2 | ============================ 3 | 4 | 5 | Setup 6 | ----- 7 | * Install Adobe Acrobat Pro DC. 8 | * Copy headers and footers from `pdf/acrobat/` folder to `/Users//Library/Preferences/Adobe/Acrobat/DC/HeaderFooter/`. 9 | 10 | 11 | Printing to PDF 12 | --------------- 13 | ### Normal PDF 14 | * Open `index.html` in text editor and first remove element `


` before the `

Libraries

`. 15 | * Then replace the index and footer with contents of `pdf/index_for_pdf.html` file and save. 16 | * Disable internet connection and open Chromium version 108.0.5328.0 (later versions will render the site incorrectly after index is added). Right click anywhere in the window and choose 'inspect'. Go to 'Network' tab and check 'Disable Cache'. Open the `index.html` file while keeping the inspect window open. 17 | * Right click on the border of the site and select inspect. Select `` element under 'Elements' tab and change top margin and top padding from 16 to 0 in 'Styles' tab. 18 | * Change brightness of comments by right clicking on one of them and selecting inspect. Then click on the rectangle that represents color and toggle the color space to HSLA by clicking on the button with two vertical arrows. Change lightness (L) percentage to 77%. 19 | * Change the brightness of text to 13%. 20 | * Select 'Print...' with destination 'Save as PDF', paper size 'A4', 'Default' margins (top 10mm, right 9.5mm, bottom 8mm and left 10mm), 'Default' scale and no headers and footers and save (the document should be 51 pages long with last page empty). 21 | * Check if plots were rendered correctly. 22 | 23 | ### PDF optimized for laser color printing 24 | * Run `./parse.js` again. 25 | * Change all links in text to normal text and add a page number in brackets like that: '(p. )' by running './pdf/remove_links.py' (Links can be found with this regex: `.*a href.*`). 26 | * Open `index.html` in text editor and first remove element `


` before the `

Libraries

`. 27 | * Then replace the index and footer with contents of `pdf/index_for_pdf_print.html` file and save. 28 | * Disable internet connection and open Chromium version 108.0.5328.0 (later versions will render the site incorrectly after index is added). Right click anywhere in the window and choose 'inspect'. Go to 'Network' tab and check 'Disable Cache'. Open the `index.html` file while keeping the inspect window open. 29 | * Right click on the border of the site and select inspect. Select `` element under 'Elements' tab and change top margin and top padding from 16 to 0 in 'Styles' tab. 30 | * Change brightness of elements by right clicking on them and selecting inspect. Then click on the rectangle that represents color and toggle the color space to HSLA by clicking on the button with two vertical arrows. 31 | * Change lightness (L) percentage to: 32 | * 0% for the text. 33 | * 87% for the gray line on the left side of the code. 34 | * 89% for the gray hash characters by the titles 35 | * 37% for the red text and function names (they use their own red). 36 | * 60% for the blue text and the text in the contents (it uses its own blue), but leave color of decorators and the `>>>` intact. 37 | * 58% for the comments. 38 | * Individually change brightness of every comment line that starts with: `# $ pip3 install` and of comments in basic script template to 57%, by adding `color: hsla(0, 0%, 57%, 1);` to their element.style. 39 | * Select 'Print...' with destination 'Save as PDF', paper size 'A4', 'Default' margins (top 10mm, right 9.5mm, bottom 8mm and left 10mm), 'Default' scale and no headers and footers and save (the document should be 51 pages long with last page empty). 40 | * Check if plots were rendered correctly. 41 | 42 | 43 | Adding headers and footers to PDF (the same for both files) 44 | ----------------------------------------------------------- 45 | * Open the PDF file in Adobe Acrobat Pro DC. 46 | * Select 'Organize Pages'. 47 | * Right click the second page and select 'Crop Pages...'. 48 | * Select units: 'Inches'. 49 | * In 'Change page size' section select 'A4' for 'Page Sizes' and set 'XOffset' to '0.1 in'. Then click on 'YOffset' input field, so the x offset gets registered. Select page range 'All' and click OK. 50 | * Select 'Edit PDF' tab and add headers and footers by clicking 'Header & Footer' button, selecting a preset from 'Saved Settings' dropdown menu and clicking ok. Popup will say that font 'Menlo' contains invalid encoding. This is fine. 51 | * Start by adding the bottom_line preset and check afterward if bottom line on the first page is aligned properly with the text. If it is not close the file and start over. 52 | * Repeat the process for each preset. When popup asks you if you want to replace existing header or footer click 'Add New'. 53 | * Use this values for font and margins if presets get lost: Borders: left-line: 0.6, left-text: 0.8, top-line: 11.4, bottom-text: 0.27, right-text-odd: 0.57, font-name: menlo, font-size: 8. 54 | * Select 'Organize Pages' tab and remove the last page (it should be empty). 55 | * Select 'File/Properties...' and set title to 'Comprehensive Python Cheatsheet' and author to 'Jure Šorn'. 56 | * Save the progress by running 'Save as' in Format: 'Adobe PDF Files'. 57 | * Run 'Save as' again, this time in 'Adobe PDF Files, Optimized', so that Menlo font error gets fixed. 58 | 59 | 60 | Compressing 61 | ----------- 62 | * Compress the two files together with HOW_TO_PRINT.txt instruction file that contains the instructions from the next section using: `zip 'Comprehensive Python Cheatsheet.zip' 'Comprehensive Python Cheatsheet.pdf' 'Comprehensive Python Cheatsheet (optimized for printing).pdf' 'HOW_TO_PRINT.txt'`. 63 | 64 | 65 | Printing the PDF 66 | ---------------- 67 | * Open the PDF that was optimized for printing in Chrome and print on A4 on both sides with default margins, scale 98% and no headers and footers. 68 | -------------------------------------------------------------------------------- /pdf/create_index.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Usage: .py 4 | # 5 | 6 | from collections import namedtuple 7 | from dataclasses import make_dataclass 8 | from enum import Enum 9 | import re 10 | import sys 11 | from bs4 import BeautifulSoup 12 | from collections import defaultdict 13 | 14 | 15 | def main(): 16 | html = read_file('index.html') 17 | doc = BeautifulSoup(''.join(html), 'html.parser') 18 | hhh = defaultdict(lambda: defaultdict(list)) 19 | for i in range(2, 5): 20 | for h in doc.find_all(f'h{i}'): 21 | an_id = h.attrs['id'] 22 | text = h.text.lstrip('#') 23 | first_letter = text[0] 24 | hhh[first_letter][text].append(an_id) 25 | print_hhh(hhh) 26 | 27 | 28 | def print_hhh(hhh): 29 | letters = hhh.keys() 30 | for letter in sorted(letters): 31 | hh = hhh[letter] 32 | print(f'### {letter}') 33 | commands = hh.keys() 34 | for command in sorted(commands): 35 | links = hh[command] 36 | lll = ', '.join(f'[1](#{l})' for l in links) 37 | print(f'**{command} {lll}** ') 38 | print() 39 | 40 | 41 | ### 42 | ## UTIL 43 | # 44 | 45 | def read_file(filename): 46 | with open(filename, encoding='utf-8') as file: 47 | return file.readlines() 48 | 49 | 50 | if __name__ == '__main__': 51 | main() -------------------------------------------------------------------------------- /pdf/descripitive_image_final-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/pdf/descripitive_image_final-01.png -------------------------------------------------------------------------------- /pdf/descripitive_image_final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/pdf/descripitive_image_final.png -------------------------------------------------------------------------------- /pdf/index_for_pdf.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

#Index

4 | 5 |
6 |

A

7 |

abstract base classes, 4, 19
8 | animation, 40, 42-43
9 | argparse module, 22
10 | arguments, 10, 12, 22
11 | arrays, 29, 37-38
12 | asyncio module, 33
13 | audio, 40-41, 42

14 |

B

15 |

beautifulsoup library, 35
16 | binary representation, 7, 8
17 | bitwise operators, 8, 30
18 | bytes, 22-23, 25, 28-29

19 |

C

20 |

cache, 13
21 | callable, 17
22 | class, 4, 14-20
23 | closure, 12-13
24 | collection, 4, 18, 19
25 | collections module, 2, 3, 4, 19, 29
26 | combinatorics, 8
27 | command line arguments, 22
28 | comprehensions, 1, 2, 11
29 | context manager, 17, 23, 27, 32
30 | copy function, 15
31 | coroutine, 33
32 | counter, 2, 4, 12, 17
33 | csv, 26, 34, 46, 47
34 | curses module, 33, 34
35 | cython, 15, 49

36 |

D

37 |

dataclasses module, 11, 15
38 | datetime module, 8-9
39 | decorator, 13, 14, 15, 16
40 | deques, 29
41 | dictionaries, 2, 4, 10-11, 19, 21
42 | duck types, 16-19

43 |

E

44 |

enum module, 19-20
45 | enumerate function, 3
46 | excel, 46
47 | exceptions, 20-21, 23, 31
48 | exit function, 21

49 |

F

50 |

files, 22-29, 34, 46
51 | filter function, 11
52 | flask library, 36
53 | floats, 4, 6, 7
54 | format, 6-7
55 | functools module, 11, 12, 13, 16

56 |

G

57 |

games, 33, 42-43
58 | generators, 4, 11, 17
59 | global keyword, 10, 12
60 | gui app, 35

61 |

H

62 |

hashable, 15, 16
63 | hexadecimal representation, 7, 8, 28

64 |

I

65 |

image, 35, 39-40, 42-43
66 | imports, 12
67 | inline, 11, 15, 20
68 | input function, 22
69 | introspection, 21, 31
70 | ints, 4, 7-8, 28
71 | is operator, 16, 30
72 | iterable, 4, 18, 19
73 | iterator, 3-4, 11, 17
74 | itertools module, 3, 8

75 |

J

76 |

json, 25, 36, 46

77 |

L

78 |

lambda, 11
79 | lists, 1-2, 4, 10-11, 18-19, 21
80 | locale module, 16
81 | logging, 31

82 |

M

83 |

main function, 1, 49
84 | match statement, 30
85 | matplotlib library, 34, 44, 45
86 | map function, 11, 30
87 | math module, 7
88 | memoryviews, 29
89 | module, 12

90 |

N

91 |

namedtuples, 3, 6
92 | nonlocal keyword, 12
93 | numbers, 4, 6-8
94 | numpy library, 37-38, 39, 44

95 |

O

96 |

open function, 17, 22-23, 25, 26, 28
97 | operator module, 30
98 | os commands, 23-25, 34

99 |

P

100 |

pandas library, 44-48
101 | partial function, 12, 20
102 | paths, 23-24, 34
103 | pickle module, 25
104 | pillow library, 39-40
105 | plotting, 34, 44, 45, 47-48
106 | print function, 14, 22
107 | profiling, 36-37
108 | progress bar, 34
109 | property decorator, 15, 16
110 | pygame library, 42-43

111 |

Q

112 |

queues, 29, 32, 33

113 |

R

114 |

random module, 8, 33, 41
115 | ranges, 3, 4
116 | recursion, 13, 21
117 | reduce function, 11
118 | regular expressions, 5-6
119 | requests library, 35, 36

120 |

S

121 |

scope, 10, 12, 20
122 | scraping, 35, 43, 46, 47-48
123 | sequence, 4, 18-19
124 | sets, 2, 4, 10-11, 19, 21
125 | shell commands, 25
126 | sleep function, 34
127 | sortable, 1, 16
128 | splat operator, 10, 26
129 | sql, 27, 46
130 | statistics, 7, 37-38, 44-48
131 | strings, 4-7, 14
132 | struct module, 28-29
133 | subprocess module, 25
134 | super function, 14
135 | sys module, 13, 21-22

136 |

T

137 |

table, 26, 27, 34, 37-38, 45-46
138 | template, 6, 36
139 | threading module, 32, 36
140 | time module, 34, 36
141 | tuples, 3, 4, 10-11, 18-19
142 | type, 4, 16, 30
143 | type annotations, 15, 31

144 |

W

145 |

wave module, 40-41
146 | web app, 36

147 |
-------------------------------------------------------------------------------- /pdf/index_for_pdf_print.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

#Index

4 | 5 |
6 |

A

7 |

abstract base classes, 4, 19
8 | animation, 40, 42-43
9 | argparse module, 22
10 | arguments, 10, 12, 22
11 | arrays, 29, 37-38
12 | asyncio module, 33
13 | audio, 40-41, 42

14 |

B

15 |

beautifulsoup library, 35
16 | binary representation, 7, 8
17 | bitwise operators, 8, 30
18 | bytes, 22-23, 25, 28-29

19 |

C

20 |

cache, 13
21 | callable, 17
22 | class, 4, 14-20
23 | closure, 12-13
24 | collection, 4, 18, 19
25 | collections module, 2, 3, 4, 19, 29
26 | combinatorics, 8
27 | command line arguments, 22
28 | comprehensions, 1, 2, 11
29 | context manager, 17, 23, 27, 32
30 | copy function, 15
31 | coroutine, 33
32 | counter, 2, 4, 12, 17
33 | csv, 26, 34, 46, 47
34 | curses module, 33, 34
35 | cython, 15, 49

36 |

D

37 |

dataclasses module, 11, 15
38 | datetime module, 8-9
39 | decorator, 13, 14, 15, 16
40 | deques, 29
41 | dictionaries, 2, 4, 10-11, 19, 21
42 | duck types, 16-19

43 |

E

44 |

enum module, 19-20
45 | enumerate function, 3
46 | excel, 46
47 | exceptions, 20-21, 23, 31
48 | exit function, 21

49 |

F

50 |

files, 22-29, 34, 46
51 | filter function, 11
52 | flask library, 36
53 | floats, 4, 6, 7
54 | format, 6-7
55 | functools module, 11, 12, 13, 16

56 |

G

57 |

games, 33, 42-43
58 | generators, 4, 11, 17
59 | global keyword, 10, 12
60 | gui, 35

61 |

H

62 |

hashable, 15, 16
63 | hexadecimal representation, 7, 8, 28

64 |

I

65 |

image, 35, 39-40, 42-43
66 | imports, 12
67 | inline, 11, 15, 20
68 | input function, 22
69 | introspection, 21, 31
70 | ints, 4, 7-8, 28
71 | is operator, 16, 30
72 | iterable, 4, 18, 19
73 | iterator, 3-4, 11, 17
74 | itertools module, 3, 8

75 |

J

76 |

json, 25, 36, 46

77 |

L

78 |

lambda, 11
79 | lists, 1-2, 4, 10-11, 18-19, 21
80 | locale module, 16
81 | logging, 31

82 |

M

83 |

main function, 1, 49
84 | match statement, 30
85 | matplotlib library, 34, 44, 45
86 | map function, 11, 30
87 | math module, 7
88 | memoryviews, 29
89 | module, 12

90 |

N

91 |

namedtuples, 3, 6
92 | nonlocal keyword, 12
93 | numbers, 4, 6-8
94 | numpy library, 37-38, 39, 44

95 |

O

96 |

open function, 17, 22-23, 25, 26, 28
97 | operator module, 30
98 | os commands, 23-25, 34

99 |

P

100 |

pandas library, 44-48
101 | partial function, 12, 20
102 | paths, 23-24, 34
103 | pickle module, 25
104 | pillow library, 39-40
105 | plotting, 34, 44, 45, 47-48
106 | print function, 14, 22
107 | profiling, 36-37
108 | progress bar, 34
109 | property decorator, 15, 16
110 | pygame library, 42-43

111 |

Q

112 |

queues, 29, 32, 33

113 |

R

114 |

random module, 8, 33, 41
115 | ranges, 3, 4
116 | recursion, 13, 21
117 | reduce function, 11
118 | regular expressions, 5-6
119 | requests library, 35, 36

120 |

S

121 |

scope, 10, 12, 20
122 | scraping, 35, 43, 46, 47-48
123 | sequence, 4, 18-19
124 | sets, 2, 4, 10-11, 19, 21
125 | shell commands, 25
126 | sleep function, 34
127 | sortable, 1, 16
128 | splat operator, 10, 26
129 | sql, 27, 46
130 | statistics, 7, 37-38, 44-48
131 | strings, 4-7, 14
132 | struct module, 28-29
133 | subprocess module, 25
134 | super function, 14
135 | sys module, 13, 21-22

136 |

T

137 |

table, 26, 27, 34, 37-38, 45-46
138 | template, 6, 36
139 | threading module, 32, 36
140 | time module, 34, 36
141 | tuples, 3, 4, 10-11, 18-19
142 | type, 4, 16, 30
143 | type annotations, 15, 31

144 |

W

145 |

wave module, 40-41
146 | web, 36

147 |
-------------------------------------------------------------------------------- /pdf/popup.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |

4 |

5 | 6 | 7 | 8 |
“A very helpful cheat sheet, quite long.” ― Brian Kernighan
9 | 10 |
    11 |
  • Footers with page numbers and chapter titles.
  • 12 |
  • Index on the last page.
  • 13 |
  • Carefully chosen locations of page breaks.
  • 14 |
  • Includes a bonus PDF optimized for color laser printing.
  • 15 |
  • Free updates via Email (~2x per year).
  • 16 |
  • 50 pages.
  • 17 |
18 | 19 |
    20 |
21 | 22 | 23 | Buy Now 24 | 25 | 26 |
-------------------------------------------------------------------------------- /pdf/remove_links.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Usage: ./remove_links.py 4 | # Removes links from index.html and adds page numbers in brackets instead (p. XX). 5 | 6 | from pathlib import Path 7 | 8 | 9 | MATCHES = { 10 | 'For details about sort(), sorted(), min() and max() see Sortable.': 'For details about sort(), sorted(), min() and max() see Sortable (p. 16).', 11 | 'Module operator has function itemgetter() that can replace listed lambdas.': 'Module \'operator\' has function itemgetter() that can replace listed lambdas (p. 31).', 12 | 'This text uses the term collection instead of iterable. For rationale see Collection.': 'This text uses the term collection instead of iterable. For rationale see Collection (p. 18).', 13 | 'Adding \'!r\' to the expression converts object to string by calling its repr() method.': 'Adding \'!r\' to the expression converts object to string by calling its repr() method.', 14 | 'It can be any callable, but is usually implemented as a function that returns a closure.': 'It can be any callable, but is usually implemented as a function that returns a closure.', 15 | 'Hints are used by type checkers like mypy, data validation libraries such as Pydantic and lately also by Cython compiler. However, they are not enforced by CPython interpreter.': 'Hints are used by type checkers like mypy, data validation libraries such as Pydantic and lately also by Cython compiler. However, they are not enforced by CPython interpreter.', 16 | 'Objects can be made sortable with \'order=True\' and immutable with \'frozen=True\'.': 'Objects can be made sortable with \'order=True\' and immutable with \'frozen=True\'.', 17 | 'For object to be hashable, all attributes must be hashable and \'frozen\' must be True.': 'For object to be hashable, all attributes must be hashable and \'frozen\' must be True.', 18 | 'Function field() is needed because \'<attr_name>: list = []\' would make a list that is shared among all instances. Its \'default_factory\' argument can be any callable.': 'Function field() is needed because \'<attr_name>: list = []\' would make a list that is shared among all instances. Its \'default_factory\' argument can be any callable (p. 17).', 19 | 'Sequence iterators returned by the iter() function, such as list_iterator and set_iterator.': 'Sequence iterators returned by the iter() function, such as list_iterator and set_iterator.', 20 | 'Objects returned by the itertools module, such as count, repeat and cycle.': 'Objects returned by the itertools module, such as count, repeat and cycle (p. 3).', 21 | 'Generators returned by the generator functions and generator expressions.': 'Generators returned by the generator functions (p. 4) and generator expressions (p. 11).', 22 | 'File objects returned by the open() function, etc.': 'File objects returned by the open() function (p. 22), etc.', 23 | 'Use \'logging.exception(<str>)\' to log the passed message, followed by the full error message of the caught exception. For details see Logging.': 'Use \'logging.exception(<str>)\' to log the passed message, followed by the full error message of the caught exception. For details see Logging (p. 31).', 24 | 'Functions report OS related errors by raising OSError or one of its subclasses.': 'Functions report OS related errors by raising OSError or one of its subclasses (p. 23).', 25 | 'To print the spreadsheet to the console use Tabulate library.': 'To print the spreadsheet to the console use Tabulate library (p. 34).', 26 | 'For XML and binary Excel files (xlsx, xlsm and xlsb) use Pandas library.': 'For XML and binary Excel files (xlsx, xlsm and xlsb) use Pandas library (p. 46).', 27 | 'Bools will be stored and returned as ints and dates as ISO formatted strings.': 'Bools will be stored and returned as ints and dates as ISO formatted strings (p. 9).', 28 | 'ProcessPoolExecutor provides true parallelism but: everything sent to/from workers must be pickable, queues must be sent using executor\'s \'initargs\' and \'initializer\' parameters, and executor should only be reachable via \'if __name__ == "__main__": ...\'.': 'ProcessPoolExecutor provides true parallelism but: everything sent to/from workers must be pickable, queues must be sent using executor\'s \'initargs\' and \'initializer\' parameters, and executor should only be reachable via \'if __name__ == "__main__": ...\'.', 29 | 'Install a WSGI server like Waitress and a HTTP server such as Nginx for better security.': 'Install a WSGI server like Waitress and a HTTP server such as Nginx for better security.', 30 | 'Data analysis library. For examples see Plotly.': 'Data analysis library. For examples see Plotly (p. 47).', 31 | } 32 | 33 | 34 | def main(): 35 | index_path = Path('..', 'index.html') 36 | lines = read_file(index_path) 37 | out = ''.join(lines) 38 | for from_, to_ in MATCHES.items(): 39 | out = out.replace(from_, to_, 1) 40 | write_to_file(index_path, out) 41 | 42 | 43 | ### 44 | ## UTIL 45 | # 46 | 47 | def read_file(filename): 48 | p = Path(__file__).resolve().parent / filename 49 | with open(p, encoding='utf-8') as file: 50 | return file.readlines() 51 | 52 | 53 | def write_to_file(filename, text): 54 | p = Path(__file__).resolve().parent / filename 55 | with open(p, 'w', encoding='utf-8') as file: 56 | file.write(text) 57 | 58 | 59 | if __name__ == '__main__': 60 | main() 61 | -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/9f94dc20bb2a09c15241d3a880b7ad01.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/9f94dc20bb2a09c15241d3a880b7ad01.eot -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/9f94dc20bb2a09c15241d3a880b7ad01.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/9f94dc20bb2a09c15241d3a880b7ad01.ttf -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/9f94dc20bb2a09c15241d3a880b7ad01.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/9f94dc20bb2a09c15241d3a880b7ad01.woff -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/9f94dc20bb2a09c15241d3a880b7ad01.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/9f94dc20bb2a09c15241d3a880b7ad01.woff2 -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/Demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Menlo Regular Font - OnlineWebFonts.COM 6 | 17 | 18 | 19 |

OnlineWebFonts Font Demo

20 |

21 | Menlo Regular Font More Format Downloads

22 |
23 |
Instructions:
24 |
    25 |
  • 26 |

    1Use font-face declaration Fonts.
    27 | 28 |

    29 | @font-face {font-family: "Menlo Regular";
    30 |   src: url("9f94dc20bb2a09c15241d3a880b7ad01.eot"); /* IE9*/
    31 |   src: url("9f94dc20bb2a09c15241d3a880b7ad01.eot?#iefix") format("embedded-opentype"), /* IE6-IE8 */
    32 |   url("9f94dc20bb2a09c15241d3a880b7ad01.woff2") format("woff2"), /* chrome、firefox */
    33 |   url("9f94dc20bb2a09c15241d3a880b7ad01.woff") format("woff"), /* chrome、firefox */
    34 |   url("9f94dc20bb2a09c15241d3a880b7ad01.ttf") format("truetype"), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/
    35 |   url("9f94dc20bb2a09c15241d3a880b7ad01.svg#Menlo Regular") format("svg"); /* iOS 4.1- */
    36 | }
    37 | 
    38 | 39 |
  • 40 |
  • 41 |

    2Settings font css style
    42 | 43 |

    44 | .demo{
    45 |     font-family:"Menlo Regular" !important;
    46 |     font-size:16px;font-style:normal;
    47 |     -webkit-font-smoothing: antialiased;
    48 |     -webkit-text-stroke-width: 0.2px;
    49 |     -moz-osx-font-smoothing: grayscale;}
    50 | 
    51 | 52 |
  • 53 |
  • 54 |

    3View DEMO
    55 |

    56 | <div class="demo"> www.OnlineWebFonts.Com </div>
    57 | 
    58 |
  • 59 |
  • 60 |

    OROr add to the head section of page.
    61 |

    62 | <link href="//db.onlinewebfonts.com/c/9f94dc20bb2a09c15241d3a880b7ad01?family=Menlo+Regular" rel="stylesheet" type="text/css"/>
    63 | 
    64 |
  • 65 |
66 |
67 |
68 |
69 | 
70 | OnlineWebFonts.Com features an amazing collection of free fonts,
71 | premium fonts and free dingbats. With over 8,000,000 freeware fonts, 
72 | you've come to the best place to download fonts! 
73 | 
74 | OnlineWebFonts.Com Some fonts provided are trial versions of full versions and may not allow embedding 
75 | unless a commercial license is purchased or may contain a limited character set. 
76 | Please review any files included with your download, 
77 | which will usually include information on the usage and licenses of the fonts. 
78 | If no information is provided, 
79 | please use at your own discretion or contact the author directly. 
80 | 
81 | 0123456789  /*-+~!@#$%^&*()-=_+{}[]:;"'|\<>.?
82 | 
83 | 
84 |
85 | 86 |
87 |
License and attribution:
88 |
You must credit the author Copy this link ( oNlineWebFonts.Com ) on your web
Copy the Attribution License:
89 | 90 |
91 | 94 | 95 | -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/License.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/License.txt -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/Menlo Regular/Menlo Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/Menlo Regular/Menlo Regular.eot -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/Menlo Regular/Menlo Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/Menlo Regular/Menlo Regular.ttf -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/Menlo Regular/Menlo Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/Menlo Regular/Menlo Regular.woff -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/Menlo Regular/Menlo Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/Menlo Regular/Menlo Regular.woff2 -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/Online_Web_Fonts.url: -------------------------------------------------------------------------------- 1 | [{000214A0-0000-0000-C000-000000000046}] 2 | Prop3=19,2 3 | [InternetShortcut] 4 | URL=http://www.onlinewebfonts.com/ 5 | IDList= 6 | IconFile=http://www.fontfree.org/favicon.ico 7 | IconIndex=1 8 | HotKey=0 9 | -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/License.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/License.txt -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Menlo Bold/@font-face/Demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Menlo Bold Font - OnlineWebFonts.COM 6 | 17 | 18 | 19 |

OnlineWebFonts Fonts Demo

20 |

21 | Menlo Bold Fonts More Formats Downloads

22 |
23 |
Instructions:
24 |
    25 |
  • 26 |

    1Use font-face declaration Fonts.
    27 | 28 |

    29 | @font-face {font-family: "Menlo Bold";
    30 |   src: url("a6ffc5d72a96b65159e710ea6d258ba4.eot"); /* IE9*/
    31 |   src: url("a6ffc5d72a96b65159e710ea6d258ba4.eot?#iefix") format("embedded-opentype"), /* IE6-IE8 */
    32 |   url("a6ffc5d72a96b65159e710ea6d258ba4.woff2") format("woff2"), /* chrome、firefox */
    33 |   url("a6ffc5d72a96b65159e710ea6d258ba4.woff") format("woff"), /* chrome、firefox */
    34 |   url("a6ffc5d72a96b65159e710ea6d258ba4.ttf") format("truetype"), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/
    35 |   url("a6ffc5d72a96b65159e710ea6d258ba4.svg#Menlo Bold") format("svg"); /* iOS 4.1- */
    36 | }
    37 | 
    38 | 39 |
  • 40 |
  • 41 |

    2Settings font css style
    42 | 43 |

    44 | .demo{
    45 |     font-family:"Menlo Bold" !important;
    46 |     font-size:16px;font-style:normal;
    47 |     -webkit-font-smoothing: antialiased;
    48 |     -webkit-text-stroke-width: 0.2px;
    49 |     -moz-osx-font-smoothing: grayscale;}
    50 | 
    51 | 52 |
  • 53 |
  • 54 |

    3View DEMO
    55 |

    56 | <div class="demo"> www.OnlineWebFonts.Com </div>
    57 | 
    58 |
  • 59 |
  • 60 |

    OROr add to the head section of page.
    61 |

    62 | <link href="//db.onlinewebfonts.com/c/a6ffc5d72a96b65159e710ea6d258ba4?family=Menlo+Bold" rel="stylesheet" type="text/css"/>
    63 | 
    64 |
  • 65 |
66 |
67 |
68 |
69 | 
70 | OnlineWebFonts.Com features an amazing collection of free fonts,
71 | premium fonts and free dingbats. With over 8,000,000 freeware fonts, 
72 | you\'ve come to the best place to download fonts! 
73 | 
74 | OnlineWebFonts.Com Some fonts provided are trial versions of full versions and may not allow embedding 
75 | unless a commercial license is purchased or may contain a limited character set. 
76 | Please review any files included with your download, 
77 | which will usually include information on the usage and licenses of the fonts. 
78 | If no information is provided, 
79 | please use at your own discretion or contact the author directly. 
80 | 
81 | 0123456789  /*-+~!@#$%^&*()-=_+{}[]:;"\'|\<>.?
82 | 
83 | 
84 |
85 | 86 |
87 |
License and attribution:
88 |
You must credit the author Copy this link ( oNlineWebFonts.Com ) on your web
Copy the Attribution License:
89 | 90 |
91 | 94 | 95 | -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Menlo Bold/@font-face/a6ffc5d72a96b65159e710ea6d258ba4.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Menlo Bold/@font-face/a6ffc5d72a96b65159e710ea6d258ba4.eot -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Menlo Bold/@font-face/a6ffc5d72a96b65159e710ea6d258ba4.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Menlo Bold/@font-face/a6ffc5d72a96b65159e710ea6d258ba4.ttf -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Menlo Bold/@font-face/a6ffc5d72a96b65159e710ea6d258ba4.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Menlo Bold/@font-face/a6ffc5d72a96b65159e710ea6d258ba4.woff -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Menlo Bold/@font-face/a6ffc5d72a96b65159e710ea6d258ba4.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Menlo Bold/@font-face/a6ffc5d72a96b65159e710ea6d258ba4.woff2 -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Menlo Bold/Menlo Bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Menlo Bold/Menlo Bold.eot -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Menlo Bold/Menlo Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Menlo Bold/Menlo Bold.ttf -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Menlo Bold/Menlo Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Menlo Bold/Menlo Bold.woff -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Menlo Bold/Menlo Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Menlo Bold/Menlo Bold.woff2 -------------------------------------------------------------------------------- /web/OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88/Online_Web_Fonts.url: -------------------------------------------------------------------------------- 1 | [{000214A0-0000-0000-C000-000000000046}] 2 | Prop3=19,2 3 | [InternetShortcut] 4 | URL=http://www.onlinewebfonts.com/ 5 | IDList= 6 | IconFile=http://www.fontfree.org/favicon.ico 7 | IconIndex=1 8 | HotKey=0 9 | -------------------------------------------------------------------------------- /web/continents.csv: -------------------------------------------------------------------------------- 1 | Continent_Name,Continent_Code,Country_Name,Two_Letter_Country_Code,Three_Letter_Country_Code,Country_Number 2 | Asia,AS,"Afghanistan, Islamic Republic of",AF,AFG,4 3 | Europe,EU,"Albania, Republic of",AL,ALB,8 4 | Antarctica,AN,Antarctica (the territory South of 60 deg S),AQ,ATA,10 5 | Africa,AF,"Algeria, People's Democratic Republic of",DZ,DZA,12 6 | Oceania,OC,American Samoa,AS,ASM,16 7 | Europe,EU,"Andorra, Principality of",AD,AND,20 8 | Africa,AF,"Angola, Republic of",AO,AGO,24 9 | North America,NA,Antigua and Barbuda,AG,ATG,28 10 | Europe,EU,"Azerbaijan, Republic of",AZ,AZE,31 11 | Asia,AS,"Azerbaijan, Republic of",AZ,AZE,31 12 | South America,SA,"Argentina, Argentine Republic",AR,ARG,32 13 | Oceania,OC,"Australia, Commonwealth of",AU,AUS,36 14 | Europe,EU,"Austria, Republic of",AT,AUT,40 15 | North America,NA,"Bahamas, Commonwealth of the",BS,BHS,44 16 | Asia,AS,"Bahrain, Kingdom of",BH,BHR,48 17 | Asia,AS,"Bangladesh, People's Republic of",BD,BGD,50 18 | Europe,EU,"Armenia, Republic of",AM,ARM,51 19 | Asia,AS,"Armenia, Republic of",AM,ARM,51 20 | North America,NA,Barbados,BB,BRB,52 21 | Europe,EU,"Belgium, Kingdom of",BE,BEL,56 22 | North America,NA,Bermuda,BM,BMU,60 23 | Asia,AS,"Bhutan, Kingdom of",BT,BTN,64 24 | South America,SA,"Bolivia, Republic of",BO,BOL,68 25 | Europe,EU,Bosnia and Herzegovina,BA,BIH,70 26 | Africa,AF,"Botswana, Republic of",BW,BWA,72 27 | Antarctica,AN,Bouvet Island (Bouvetoya),BV,BVT,74 28 | South America,SA,"Brazil, Federative Republic of",BR,BRA,76 29 | North America,NA,Belize,BZ,BLZ,84 30 | Asia,AS,British Indian Ocean Territory (Chagos Archipelago),IO,IOT,86 31 | Oceania,OC,Solomon Islands,SB,SLB,90 32 | North America,NA,British Virgin Islands,VG,VGB,92 33 | Asia,AS,Brunei Darussalam,BN,BRN,96 34 | Europe,EU,"Bulgaria, Republic of",BG,BGR,100 35 | Asia,AS,"Myanmar, Union of",MM,MMR,104 36 | Africa,AF,"Burundi, Republic of",BI,BDI,108 37 | Europe,EU,"Belarus, Republic of",BY,BLR,112 38 | Asia,AS,"Cambodia, Kingdom of",KH,KHM,116 39 | Africa,AF,"Cameroon, Republic of",CM,CMR,120 40 | North America,NA,Canada,CA,CAN,124 41 | Africa,AF,"Cape Verde, Republic of",CV,CPV,132 42 | North America,NA,Cayman Islands,KY,CYM,136 43 | Africa,AF,Central African Republic,CF,CAF,140 44 | Asia,AS,"Sri Lanka, Democratic Socialist Republic of",LK,LKA,144 45 | Africa,AF,"Chad, Republic of",TD,TCD,148 46 | South America,SA,"Chile, Republic of",CL,CHL,152 47 | Asia,AS,"China, People's Republic of",CN,CHN,156 48 | Asia,AS,Taiwan,TW,TWN,158 49 | Asia,AS,Christmas Island,CX,CXR,162 50 | Asia,AS,Cocos (Keeling) Islands,CC,CCK,166 51 | South America,SA,"Colombia, Republic of",CO,COL,170 52 | Africa,AF,"Comoros, Union of the",KM,COM,174 53 | Africa,AF,Mayotte,YT,MYT,175 54 | Africa,AF,"Congo, Republic of the",CG,COG,178 55 | Africa,AF,"Congo, Democratic Republic of the",CD,COD,180 56 | Oceania,OC,Cook Islands,CK,COK,184 57 | North America,NA,"Costa Rica, Republic of",CR,CRI,188 58 | Europe,EU,"Croatia, Republic of",HR,HRV,191 59 | North America,NA,"Cuba, Republic of",CU,CUB,192 60 | Europe,EU,"Cyprus, Republic of",CY,CYP,196 61 | Asia,AS,"Cyprus, Republic of",CY,CYP,196 62 | Europe,EU,Czech Republic,CZ,CZE,203 63 | Africa,AF,"Benin, Republic of",BJ,BEN,204 64 | Europe,EU,"Denmark, Kingdom of",DK,DNK,208 65 | North America,NA,"Dominica, Commonwealth of",DM,DMA,212 66 | North America,NA,Dominican Republic,DO,DOM,214 67 | South America,SA,"Ecuador, Republic of",EC,ECU,218 68 | North America,NA,"El Salvador, Republic of",SV,SLV,222 69 | Africa,AF,"Equatorial Guinea, Republic of",GQ,GNQ,226 70 | Africa,AF,"Ethiopia, Federal Democratic Republic of",ET,ETH,231 71 | Africa,AF,"Eritrea, State of",ER,ERI,232 72 | Europe,EU,"Estonia, Republic of",EE,EST,233 73 | Europe,EU,Faroe Islands,FO,FRO,234 74 | South America,SA,Falkland Islands (Malvinas),FK,FLK,238 75 | Antarctica,AN,South Georgia and the South Sandwich Islands,GS,SGS,239 76 | Oceania,OC,"Fiji, Republic of the Fiji Islands",FJ,FJI,242 77 | Europe,EU,"Finland, Republic of",FI,FIN,246 78 | Europe,EU,Åland Islands,AX,ALA,248 79 | Europe,EU,"France, French Republic",FR,FRA,250 80 | South America,SA,French Guiana,GF,GUF,254 81 | Oceania,OC,French Polynesia,PF,PYF,258 82 | Antarctica,AN,French Southern Territories,TF,ATF,260 83 | Africa,AF,"Djibouti, Republic of",DJ,DJI,262 84 | Africa,AF,"Gabon, Gabonese Republic",GA,GAB,266 85 | Europe,EU,Georgia,GE,GEO,268 86 | Asia,AS,Georgia,GE,GEO,268 87 | Africa,AF,"Gambia, Republic of the",GM,GMB,270 88 | Asia,AS,"Palestinian Territory, Occupied",PS,PSE,275 89 | Europe,EU,"Germany, Federal Republic of",DE,DEU,276 90 | Africa,AF,"Ghana, Republic of",GH,GHA,288 91 | Europe,EU,Gibraltar,GI,GIB,292 92 | Oceania,OC,"Kiribati, Republic of",KI,KIR,296 93 | Europe,EU,"Greece, Hellenic Republic",GR,GRC,300 94 | North America,NA,Greenland,GL,GRL,304 95 | North America,NA,Grenada,GD,GRD,308 96 | North America,NA,Guadeloupe,GP,GLP,312 97 | Oceania,OC,Guam,GU,GUM,316 98 | North America,NA,"Guatemala, Republic of",GT,GTM,320 99 | Africa,AF,"Guinea, Republic of",GN,GIN,324 100 | South America,SA,"Guyana, Co-operative Republic of",GY,GUY,328 101 | North America,NA,"Haiti, Republic of",HT,HTI,332 102 | Antarctica,AN,Heard Island and McDonald Islands,HM,HMD,334 103 | Europe,EU,Holy See (Vatican City State),VA,VAT,336 104 | North America,NA,"Honduras, Republic of",HN,HND,340 105 | Asia,AS,"Hong Kong, Special Administrative Region of China",HK,HKG,344 106 | Europe,EU,"Hungary, Republic of",HU,HUN,348 107 | Europe,EU,"Iceland, Republic of",IS,ISL,352 108 | Asia,AS,"India, Republic of",IN,IND,356 109 | Asia,AS,"Indonesia, Republic of",ID,IDN,360 110 | Asia,AS,"Iran, Islamic Republic of",IR,IRN,364 111 | Asia,AS,"Iraq, Republic of",IQ,IRQ,368 112 | Europe,EU,Ireland,IE,IRL,372 113 | Asia,AS,"Israel, State of",IL,ISR,376 114 | Europe,EU,"Italy, Italian Republic",IT,ITA,380 115 | Africa,AF,"Cote d'Ivoire, Republic of",CI,CIV,384 116 | North America,NA,Jamaica,JM,JAM,388 117 | Asia,AS,Japan,JP,JPN,392 118 | Europe,EU,"Kazakhstan, Republic of",KZ,KAZ,398 119 | Asia,AS,"Kazakhstan, Republic of",KZ,KAZ,398 120 | Asia,AS,"Jordan, Hashemite Kingdom of",JO,JOR,400 121 | Africa,AF,"Kenya, Republic of",KE,KEN,404 122 | Asia,AS,"Korea, Democratic People's Republic of",KP,PRK,408 123 | Asia,AS,"Korea, Republic of",KR,KOR,410 124 | Asia,AS,"Kuwait, State of",KW,KWT,414 125 | Asia,AS,Kyrgyz Republic,KG,KGZ,417 126 | Asia,AS,Lao People's Democratic Republic,LA,LAO,418 127 | Asia,AS,"Lebanon, Lebanese Republic",LB,LBN,422 128 | Africa,AF,"Lesotho, Kingdom of",LS,LSO,426 129 | Europe,EU,"Latvia, Republic of",LV,LVA,428 130 | Africa,AF,"Liberia, Republic of",LR,LBR,430 131 | Africa,AF,Libyan Arab Jamahiriya,LY,LBY,434 132 | Europe,EU,"Liechtenstein, Principality of",LI,LIE,438 133 | Europe,EU,"Lithuania, Republic of",LT,LTU,440 134 | Europe,EU,"Luxembourg, Grand Duchy of",LU,LUX,442 135 | Asia,AS,"Macao, Special Administrative Region of China",MO,MAC,446 136 | Africa,AF,"Madagascar, Republic of",MG,MDG,450 137 | Africa,AF,"Malawi, Republic of",MW,MWI,454 138 | Asia,AS,Malaysia,MY,MYS,458 139 | Asia,AS,"Maldives, Republic of",MV,MDV,462 140 | Africa,AF,"Mali, Republic of",ML,MLI,466 141 | Europe,EU,"Malta, Republic of",MT,MLT,470 142 | North America,NA,Martinique,MQ,MTQ,474 143 | Africa,AF,"Mauritania, Islamic Republic of",MR,MRT,478 144 | Africa,AF,"Mauritius, Republic of",MU,MUS,480 145 | North America,NA,"Mexico, United Mexican States",MX,MEX,484 146 | Europe,EU,"Monaco, Principality of",MC,MCO,492 147 | Asia,AS,Mongolia,MN,MNG,496 148 | Europe,EU,"Moldova, Republic of",MD,MDA,498 149 | Europe,EU,"Montenegro, Republic of",ME,MNE,499 150 | North America,NA,Montserrat,MS,MSR,500 151 | Africa,AF,"Morocco, Kingdom of",MA,MAR,504 152 | Africa,AF,"Mozambique, Republic of",MZ,MOZ,508 153 | Asia,AS,"Oman, Sultanate of",OM,OMN,512 154 | Africa,AF,"Namibia, Republic of",NA,NAM,516 155 | Oceania,OC,"Nauru, Republic of",NR,NRU,520 156 | Asia,AS,"Nepal, State of",NP,NPL,524 157 | Europe,EU,"Netherlands, Kingdom of the",NL,NLD,528 158 | North America,NA,Netherlands Antilles,AN,ANT,530 159 | North America,NA,Curaçao,CW,CUW,531 160 | North America,NA,Aruba,AW,ABW,533 161 | North America,NA,Sint Maarten (Netherlands),SX,SXM,534 162 | North America,NA,"Bonaire, Sint Eustatius and Saba",BQ,BES,535 163 | Oceania,OC,New Caledonia,NC,NCL,540 164 | Oceania,OC,"Vanuatu, Republic of",VU,VUT,548 165 | Oceania,OC,New Zealand,NZ,NZL,554 166 | North America,NA,"Nicaragua, Republic of",NI,NIC,558 167 | Africa,AF,"Niger, Republic of",NE,NER,562 168 | Africa,AF,"Nigeria, Federal Republic of",NG,NGA,566 169 | Oceania,OC,Niue,NU,NIU,570 170 | Oceania,OC,Norfolk Island,NF,NFK,574 171 | Europe,EU,"Norway, Kingdom of",NO,NOR,578 172 | Oceania,OC,"Northern Mariana Islands, Commonwealth of the",MP,MNP,580 173 | Oceania,OC,United States Minor Outlying Islands,UM,UMI,581 174 | North America,NA,United States Minor Outlying Islands,UM,UMI,581 175 | Oceania,OC,"Micronesia, Federated States of",FM,FSM,583 176 | Oceania,OC,"Marshall Islands, Republic of the",MH,MHL,584 177 | Oceania,OC,"Palau, Republic of",PW,PLW,585 178 | Asia,AS,"Pakistan, Islamic Republic of",PK,PAK,586 179 | North America,NA,"Panama, Republic of",PA,PAN,591 180 | Oceania,OC,"Papua New Guinea, Independent State of",PG,PNG,598 181 | South America,SA,"Paraguay, Republic of",PY,PRY,600 182 | South America,SA,"Peru, Republic of",PE,PER,604 183 | Asia,AS,"Philippines, Republic of the",PH,PHL,608 184 | Oceania,OC,Pitcairn Islands,PN,PCN,612 185 | Europe,EU,"Poland, Republic of",PL,POL,616 186 | Europe,EU,"Portugal, Portuguese Republic",PT,PRT,620 187 | Africa,AF,"Guinea-Bissau, Republic of",GW,GNB,624 188 | Asia,AS,"Timor-Leste, Democratic Republic of",TL,TLS,626 189 | North America,NA,"Puerto Rico, Commonwealth of",PR,PRI,630 190 | Asia,AS,"Qatar, State of",QA,QAT,634 191 | Africa,AF,Reunion,RE,REU,638 192 | Europe,EU,Romania,RO,ROU,642 193 | Europe,EU,Russian Federation,RU,RUS,643 194 | Asia,AS,Russian Federation,RU,RUS,643 195 | Africa,AF,"Rwanda, Republic of",RW,RWA,646 196 | North America,NA,Saint Barthelemy,BL,BLM,652 197 | Africa,AF,Saint Helena,SH,SHN,654 198 | North America,NA,"Saint Kitts and Nevis, Federation of",KN,KNA,659 199 | North America,NA,Anguilla,AI,AIA,660 200 | North America,NA,Saint Lucia,LC,LCA,662 201 | North America,NA,Saint Martin,MF,MAF,663 202 | North America,NA,Saint Pierre and Miquelon,PM,SPM,666 203 | North America,NA,Saint Vincent and the Grenadines,VC,VCT,670 204 | Europe,EU,"San Marino, Republic of",SM,SMR,674 205 | Africa,AF,"Sao Tome and Principe, Democratic Republic of",ST,STP,678 206 | Asia,AS,"Saudi Arabia, Kingdom of",SA,SAU,682 207 | Africa,AF,"Senegal, Republic of",SN,SEN,686 208 | Europe,EU,"Serbia, Republic of",RS,SRB,688 209 | Africa,AF,"Seychelles, Republic of",SC,SYC,690 210 | Africa,AF,"Sierra Leone, Republic of",SL,SLE,694 211 | Asia,AS,"Singapore, Republic of",SG,SGP,702 212 | Europe,EU,Slovakia (Slovak Republic),SK,SVK,703 213 | Asia,AS,"Vietnam, Socialist Republic of",VN,VNM,704 214 | Europe,EU,"Slovenia, Republic of",SI,SVN,705 215 | Africa,AF,"Somalia, Somali Republic",SO,SOM,706 216 | Africa,AF,"South Africa, Republic of",ZA,ZAF,710 217 | Africa,AF,"Zimbabwe, Republic of",ZW,ZWE,716 218 | Europe,EU,"Spain, Kingdom of",ES,ESP,724 219 | Africa,AF,South Sudan,SS,SSD,728 220 | Africa,AF,Western Sahara,EH,ESH,732 221 | Africa,AF,"Sudan, Republic of",SD,SDN,736 222 | South America,SA,"Suriname, Republic of",SR,SUR,740 223 | Europe,EU,Svalbard & Jan Mayen Islands,SJ,SJM,744 224 | Africa,AF,"Swaziland, Kingdom of",SZ,SWZ,748 225 | Europe,EU,"Sweden, Kingdom of",SE,SWE,752 226 | Europe,EU,"Switzerland, Swiss Confederation",CH,CHE,756 227 | Asia,AS,Syrian Arab Republic,SY,SYR,760 228 | Asia,AS,"Tajikistan, Republic of",TJ,TJK,762 229 | Asia,AS,"Thailand, Kingdom of",TH,THA,764 230 | Africa,AF,"Togo, Togolese Republic",TG,TGO,768 231 | Oceania,OC,Tokelau,TK,TKL,772 232 | Oceania,OC,"Tonga, Kingdom of",TO,TON,776 233 | North America,NA,"Trinidad and Tobago, Republic of",TT,TTO,780 234 | Asia,AS,United Arab Emirates,AE,ARE,784 235 | Africa,AF,"Tunisia, Tunisian Republic",TN,TUN,788 236 | Europe,EU,"Turkey, Republic of",TR,TUR,792 237 | Asia,AS,"Turkey, Republic of",TR,TUR,792 238 | Asia,AS,Turkmenistan,TM,TKM,795 239 | North America,NA,Turks and Caicos Islands,TC,TCA,796 240 | Oceania,OC,Tuvalu,TV,TUV,798 241 | Africa,AF,"Uganda, Republic of",UG,UGA,800 242 | Europe,EU,Ukraine,UA,UKR,804 243 | Europe,EU,"Macedonia, The Former Yugoslav Republic of",MK,MKD,807 244 | Africa,AF,"Egypt, Arab Republic of",EG,EGY,818 245 | Europe,EU,United Kingdom of Great Britain & Northern Ireland,GB,GBR,826 246 | Europe,EU,"Guernsey, Bailiwick of",GG,GGY,831 247 | Europe,EU,"Jersey, Bailiwick of",JE,JEY,832 248 | Europe,EU,Isle of Man,IM,IMN,833 249 | Africa,AF,"Tanzania, United Republic of",TZ,TZA,834 250 | North America,NA,United States of America,US,USA,840 251 | North America,NA,United States Virgin Islands,VI,VIR,850 252 | Africa,AF,Burkina Faso,BF,BFA,854 253 | South America,SA,"Uruguay, Eastern Republic of",UY,URY,858 254 | Asia,AS,"Uzbekistan, Republic of",UZ,UZB,860 255 | South America,SA,"Venezuela, Bolivarian Republic of",VE,VEN,862 256 | Oceania,OC,Wallis and Futuna,WF,WLF,876 257 | Oceania,OC,"Samoa, Independent State of",WS,WSM,882 258 | Asia,AS,Yemen,YE,YEM,887 259 | Africa,AF,"Zambia, Republic of",ZM,ZMB,894 260 | Oceania,OC,Disputed Territory,XX,, 261 | Asia,AS,Iraq-Saudi Arabia Neutral Zone,XE,, 262 | Asia,AS,United Nations Neutral Zone,XD,, 263 | Asia,AS,Spratly Islands,XS,, 264 | -------------------------------------------------------------------------------- /web/convert_table.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | def convert_table(lines): 4 | def from_ascii(): 5 | out = [] 6 | first, header, third, *body, last = lines 7 | first = first.translate(str.maketrans({'-': '━', '+': '┯'})) 8 | out.append(f'┏{first[1:-1]}┓') 9 | header = header.translate(str.maketrans({'|': '│'})) 10 | out.append(f'┃{header[1:-1]}┃') 11 | third = third.translate(str.maketrans({'-': '─', '+': '┼'})) 12 | out.append(f'┠{third[1:-1]}┨') 13 | for line in body: 14 | line = line.translate(str.maketrans({'|': '│'})) 15 | line = line.replace('yes', ' ✓ ') 16 | out.append(f'┃{line[1:-1]}┃') 17 | last = last.translate(str.maketrans({'-': '━', '+': '┷'})) 18 | out.append(f'┗{last[1:-1]}┛') 19 | return '\n'.join(out) 20 | def from_unicode(): 21 | out = [] 22 | for line in lines: 23 | line = line.translate(str.maketrans('┏┓┗┛┠┼┨┯┷━─┃│', '+++++++++--||')) 24 | line = line.replace(' ✓ ', 'yes') 25 | out.append(line) 26 | return '\n'.join(out) 27 | if lines[0][0] == '+': 28 | return from_ascii() 29 | return from_unicode() 30 | 31 | if __name__ == '__main__': 32 | input_lines = [] 33 | try: 34 | while True: 35 | input_lines.append(input()) 36 | except EOFError: 37 | pass 38 | print(convert_table(input_lines)) 39 | 40 | -------------------------------------------------------------------------------- /web/covid_cases.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/covid_cases.png -------------------------------------------------------------------------------- /web/covid_deaths.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/covid_deaths.png -------------------------------------------------------------------------------- /web/default.min.css: -------------------------------------------------------------------------------- 1 | .hljs{overflow-x:auto}.hljs,.hljs-subst{}.hljs-comment{color:#888888}.hljs-keyword,.hljs-attribute,.hljs-selector-tag,.hljs-meta-keyword,.hljs-doctag,.hljs-name{font-weight:bold;color:#3182bd}.hljs-type,.hljs-string,.hljs-number,.hljs-selector-id,.hljs-selector-class,.hljs-quote,.hljs-template-tag,.hljs-deletion{color:#880000}.hljs-title,.hljs-section{color:#880000;font-weight:bold}.hljs-regexp,.hljs-symbol,.hljs-variable,.hljs-template-variable,.hljs-link,.hljs-selector-attr,.hljs-selector-pseudo{color:#BC6060}.hljs-literal{color:#78A960}.hljs-meta{color:#1f7199}.hljs-meta-string{color:#4d99bf}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:bold} -------------------------------------------------------------------------------- /web/default_dark.min.css: -------------------------------------------------------------------------------- 1 | .hljs{overflow-x:auto}.hljs,.hljs-subst{}.hljs-comment{color:#797979}.hljs-keyword,.hljs-attribute,.hljs-selector-tag,.hljs-meta-keyword,.hljs-doctag,.hljs-name{font-weight:bold;color:#40b0dbb8}.hljs-type,.hljs-string,.hljs-number,.hljs-selector-id,.hljs-selector-class,.hljs-quote,.hljs-template-tag,.hljs-deletion{color:hsl(340deg 82% 43%)}.hljs-title,.hljs-section{color:hsl(340deg 82% 37%);font-weight:bold}.hljs-regexp,.hljs-symbol,.hljs-variable,.hljs-template-variable,.hljs-link,.hljs-selector-attr,.hljs-selector-pseudo{color:#BC6060}.hljs-literal{color:#78A960}.hljs-meta{color:#1f7199}.hljs-meta-string{color:#4d99bf}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:bold} -------------------------------------------------------------------------------- /web/default_dark1.min.css: -------------------------------------------------------------------------------- 1 | .hljs{overflow-x:auto}.hljs,.hljs-subst{}.hljs-comment{color:hsl(0deg 0% 49% / 77%)}.hljs-keyword,.hljs-attribute,.hljs-selector-tag,.hljs-meta-keyword,.hljs-doctag,.hljs-name{font-weight:bold;color:hsl(197deg 68% 64% / 72%)}.hljs-type,.hljs-string,.hljs-number,.hljs-selector-id,.hljs-selector-class,.hljs-quote,.hljs-template-tag,.hljs-deletion{color:hsl(0deg 67% 57% / 88%)}.hljs-title,.hljs-section{color:hsl(188deg 100% 54% / 59%);font-weight:bold}.hljs-regexp,.hljs-symbol,.hljs-variable,.hljs-template-variable,.hljs-link,.hljs-selector-attr,.hljs-selector-pseudo{color:#BC6060}.hljs-literal{color:#78A960}.hljs-meta{color:hsl(200deg 66% 47%)}.hljs-meta-string{color:#4d99bf}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:bold} -------------------------------------------------------------------------------- /web/default_dark2.min.css: -------------------------------------------------------------------------------- 1 | .hljs{overflow-x:auto}.hljs,.hljs-subst{}.hljs-comment{color:#797979}.hljs-keyword,.hljs-attribute,.hljs-selector-tag,.hljs-meta-keyword,.hljs-doctag,.hljs-name{font-weight:bold;color:hsl(187deg 85% 28%)}.hljs-type,.hljs-string,.hljs-number,.hljs-selector-id,.hljs-selector-class,.hljs-quote,.hljs-template-tag,.hljs-deletion{color:hsl(340deg 82% 43%)}.hljs-title,.hljs-section{color:hsl(340deg 82% 37%);font-weight:bold}.hljs-regexp,.hljs-symbol,.hljs-variable,.hljs-template-variable,.hljs-link,.hljs-selector-attr,.hljs-selector-pseudo{color:#BC6060}.hljs-literal{color:#78A960}.hljs-meta{color:hsl(189deg 83% 22%)}.hljs-meta-string{color:#4d99bf}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:bold} -------------------------------------------------------------------------------- /web/default_dark3.min.css: -------------------------------------------------------------------------------- 1 | .hljs{overflow-x:auto}.hljs,.hljs-subst{}.hljs-comment{color:#797979}.hljs-keyword,.hljs-attribute,.hljs-selector-tag,.hljs-meta-keyword,.hljs-doctag,.hljs-name{font-weight:bold;color:hsl(187deg 85% 35%)}.hljs-type,.hljs-string,.hljs-number,.hljs-selector-id,.hljs-selector-class,.hljs-quote,.hljs-template-tag,.hljs-deletion{color:hsl(340deg 82% 51%)}.hljs-title,.hljs-section{color:hsl(340deg 82% 45%);font-weight:bold}.hljs-regexp,.hljs-symbol,.hljs-variable,.hljs-template-variable,.hljs-link,.hljs-selector-attr,.hljs-selector-pseudo{color:#BC6060}.hljs-literal{color:#78A960}.hljs-meta{color:hsl(189deg 83% 28%)}.hljs-meta-string{color:#4d99bf}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:bold} -------------------------------------------------------------------------------- /web/faq.html: -------------------------------------------------------------------------------- 1 |
Which Python version is this for?
2 |     Everything should work in the latest Python version, which is 3.12. Every feature that requires version higher than 3.9 has that mentioned in comments or brackets. There are only two such features, both requiring 3.10.

3 |     As of 12th March 2024, the only libraries whose latest version requires Python version higher than 3.8 are: numpy, pandas and matplotlib. They all require Python 3.9. This cheatsheet covers numpy version 2.0 (or higher) that was released on 16th June, 2024 and pandas version 2.0 (or higher) that was released on 3rd April 2023. 4 |

5 | 6 |
How to use it?
7 |     This cheatsheet consists of minimal text and short examples so things are easy to find with Ctrl+F / ⌘F. If you're on the webpage, searching for '#<name>' will only search for the titles. To get a link to a specific section click the grey hashtag next to the section's title before copying the address. To search for titles in the text editor use ^<name> with enabled regular expressions option.

8 |     I also keep the Python console open at all times to test little snippets of code, to check out the available functions of a module using code completion and above all, to use help(<module/object/function/type/str>) command. If something is still unclear, then I search the Python docs by googling 'python docs <module/function>'.

9 |     Recently I started using the ptpython REPL (Python console). It supports multiline editing, syntax validation, IDE-like autocompletion and syntax highlighting. It can be installed with pip3 install ptpython. Even more recently I switched to ipython REPL, which is very similar to ptpython only more responsive. It can be installed with pip3 install ipython. 10 |

11 | 12 |
What does the '<type>' signify?
13 |     It is a placeholder for an object. It needs to be replaced by an expression, literal or a variable that returns/is of that type. However, if it is located on the left side of an assignment (=) then it signifies what type of object is produced/returned by the expression on the right side of the assignment. 14 |

15 | 16 |
Why the '<type>' semantics?
17 |     It makes examples much less ambiguous. 18 |

19 | 20 |
What exactly is <el>?
21 |     El is short for element and can be any object, but it usually denotes an object that is an item of a collection. 22 |

23 | 24 |
What exactly is <collection>?
25 |     Collection is my name for an iterable object. An iterable object in Python is any object that has at least one of iter() and getitem() special methods defined. By convention, <object>.__iter__() should return an iterator of object's items and <object>.__getitem__(<index>) an item at that index. I chose not to use the name iterable because it sounds scarier and more vague than collection, even though it has a precise definition.

26 |     To make matters a bit more confusing, an abstract base class called Iterable doesn't fully follow this definition. An expression instanceof(<object>, collections.abc.Iterable) only checks whether an object has iter() special method, disregarding the getitem().

27 |     Although collection has no definition in Python's glossary, there exists a Collection abstract base class. Expression instanceof(<object>, collections.abc.Collection) returns 'True' for any object that has len(), iter() and contains() special methods defined. <object>.__len__() should return the number of elements and <object>.__contains__(<el>) should check if object contains the passed element. 28 |

29 | 30 |
What about PEP 8?
31 |     Check out Google Style Guide and use Ctrl+Alt+L / ⌥⌘L shortcut in PyCharm to automatically reformat code. 32 |

33 | 34 |
Why are there no blank lines between method definitions?
35 |     This way classes can be copy-pasted into the Python console, which would otherwise raise IndentationError. 36 |

37 | 38 |
Why are tests not covered?
39 |     Check out The Hitchhiker’s Guide to Python for a nice overview. 40 |

41 | 42 |
Django?
43 |     Here is a nice Django cheatsheet. 44 |

45 | 46 |
Why are there no concrete Regex examples?
47 |     Regular expressions are a separate technology that is independent from Python. There are many resources available online. 48 |

49 | 50 |
Why are descriptors not covered?
51 |     Because property decorator is sufficient for everyday use. 52 |

-------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/favicon.png -------------------------------------------------------------------------------- /web/highlight.min.js: -------------------------------------------------------------------------------- 1 | /*! highlight.js v9.12.0 | BSD3 License | git.io/hljslicense */ 2 | !function(e){var t="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):t&&(t.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return t.hljs}))}(function(e){function t(e){return e.replace(/&/g,"&").replace(//g,">")}function r(e){return e.nodeName.toLowerCase()}function a(e,t){var r=e&&e.exec(t);return r&&0===r.index}function n(e){return E.test(e)}function i(e){var t,r,a,i,s=e.className+" ";if(s+=e.parentNode?e.parentNode.className:"",r=M.exec(s))return w(r[1])?r[1]:"no-highlight";for(s=s.split(/\s+/),t=0,a=s.length;a>t;t++)if(i=s[t],n(i)||w(i))return i}function s(e){var t,r={},a=Array.prototype.slice.call(arguments,1);for(t in e)r[t]=e[t];return a.forEach(function(e){for(t in e)r[t]=e[t]}),r}function c(e){var t=[];return function a(e,n){for(var i=e.firstChild;i;i=i.nextSibling)3===i.nodeType?n+=i.nodeValue.length:1===i.nodeType&&(t.push({event:"start",offset:n,node:i}),n=a(i,n),r(i).match(/br|hr|img|input/)||t.push({event:"stop",offset:n,node:i}));return n}(e,0),t}function o(e,a,n){function i(){return e.length&&a.length?e[0].offset!==a[0].offset?e[0].offset"}function c(e){u+=""}function o(e){("start"===e.event?s:c)(e.node)}for(var l=0,u="",d=[];e.length||a.length;){var b=i();if(u+=t(n.substring(l,b[0].offset)),l=b[0].offset,b===e){d.reverse().forEach(c);do o(b.splice(0,1)[0]),b=i();while(b===e&&b.length&&b[0].offset===l);d.reverse().forEach(s)}else"start"===b[0].event?d.push(b[0].node):d.pop(),o(b.splice(0,1)[0])}return u+t(n.substr(l))}function l(e){return e.v&&!e.cached_variants&&(e.cached_variants=e.v.map(function(t){return s(e,{v:null},t)})),e.cached_variants||e.eW&&[s(e)]||[e]}function u(e){function t(e){return e&&e.source||e}function r(r,a){return new RegExp(t(r),"m"+(e.cI?"i":"")+(a?"g":""))}function a(n,i){if(!n.compiled){if(n.compiled=!0,n.k=n.k||n.bK,n.k){var s={},c=function(t,r){e.cI&&(r=r.toLowerCase()),r.split(" ").forEach(function(e){var r=e.split("|");s[r[0]]=[t,r[1]?Number(r[1]):1]})};"string"==typeof n.k?c("keyword",n.k):k(n.k).forEach(function(e){c(e,n.k[e])}),n.k=s}n.lR=r(n.l||/\w+/,!0),i&&(n.bK&&(n.b="\\b("+n.bK.split(" ").join("|")+")\\b"),n.b||(n.b=/\B|\b/),n.bR=r(n.b),n.e||n.eW||(n.e=/\B|\b/),n.e&&(n.eR=r(n.e)),n.tE=t(n.e)||"",n.eW&&i.tE&&(n.tE+=(n.e?"|":"")+i.tE)),n.i&&(n.iR=r(n.i)),null==n.r&&(n.r=1),n.c||(n.c=[]),n.c=Array.prototype.concat.apply([],n.c.map(function(e){return l("self"===e?n:e)})),n.c.forEach(function(e){a(e,n)}),n.starts&&a(n.starts,i);var o=n.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([n.tE,n.i]).map(t).filter(Boolean);n.t=o.length?r(o.join("|"),!0):{exec:function(){return null}}}}a(e)}function d(e,r,n,i){function s(e,t){var r,n;for(r=0,n=t.c.length;n>r;r++)if(a(t.c[r].bR,e))return t.c[r]}function c(e,t){if(a(e.eR,t)){for(;e.endsParent&&e.parent;)e=e.parent;return e}return e.eW?c(e.parent,t):void 0}function o(e,t){return!n&&a(t.iR,e)}function l(e,t){var r=v.cI?t[0].toLowerCase():t[0];return e.k.hasOwnProperty(r)&&e.k[r]}function p(e,t,r,a){var n=a?"":L.classPrefix,i='',i+t+s}function m(){var e,r,a,n;if(!N.k)return t(E);for(n="",r=0,N.lR.lastIndex=0,a=N.lR.exec(E);a;)n+=t(E.substring(r,a.index)),e=l(N,a),e?(M+=e[1],n+=p(e[0],t(a[0]))):n+=t(a[0]),r=N.lR.lastIndex,a=N.lR.exec(E);return n+t(E.substr(r))}function f(){var e="string"==typeof N.sL;if(e&&!x[N.sL])return t(E);var r=e?d(N.sL,E,!0,k[N.sL]):b(E,N.sL.length?N.sL:void 0);return N.r>0&&(M+=r.r),e&&(k[N.sL]=r.top),p(r.language,r.value,!1,!0)}function g(){C+=null!=N.sL?f():m(),E=""}function _(e){C+=e.cN?p(e.cN,"",!0):"",N=Object.create(e,{parent:{value:N}})}function h(e,t){if(E+=e,null==t)return g(),0;var r=s(t,N);if(r)return r.skip?E+=t:(r.eB&&(E+=t),g(),r.rB||r.eB||(E=t)),_(r,t),r.rB?0:t.length;var a=c(N,t);if(a){var n=N;n.skip?E+=t:(n.rE||n.eE||(E+=t),g(),n.eE&&(E=t));do N.cN&&(C+=R),N.skip||(M+=N.r),N=N.parent;while(N!==a.parent);return a.starts&&_(a.starts,""),n.rE?0:t.length}if(o(t,N))throw new Error('Illegal lexeme "'+t+'" for mode "'+(N.cN||"")+'"');return E+=t,t.length||1}var v=w(e);if(!v)throw new Error('Unknown language: "'+e+'"');u(v);var y,N=i||v,k={},C="";for(y=N;y!==v;y=y.parent)y.cN&&(C=p(y.cN,"",!0)+C);var E="",M=0;try{for(var B,S,$=0;;){if(N.t.lastIndex=$,B=N.t.exec(r),!B)break;S=h(r.substring($,B.index),B[0]),$=B.index+S}for(h(r.substr($)),y=N;y.parent;y=y.parent)y.cN&&(C+=R);return{r:M,value:C,language:e,top:N}}catch(A){if(A.message&&-1!==A.message.indexOf("Illegal"))return{r:0,value:t(r)};throw A}}function b(e,r){r=r||L.languages||k(x);var a={r:0,value:t(e)},n=a;return r.filter(w).forEach(function(t){var r=d(t,e,!1);r.language=t,r.r>n.r&&(n=r),r.r>a.r&&(n=a,a=r)}),n.language&&(a.second_best=n),a}function p(e){return L.tabReplace||L.useBR?e.replace(B,function(e,t){return L.useBR&&"\n"===e?"
":L.tabReplace?t.replace(/\t/g,L.tabReplace):""}):e}function m(e,t,r){var a=t?C[t]:r,n=[e.trim()];return e.match(/\bhljs\b/)||n.push("hljs"),-1===e.indexOf(a)&&n.push(a),n.join(" ").trim()}function f(e){var t,r,a,s,l,u=i(e);n(u)||(L.useBR?(t=document.createElementNS("http://www.w3.org/1999/xhtml","div"),t.innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n")):t=e,l=t.textContent,a=u?d(u,l,!0):b(l),r=c(t),r.length&&(s=document.createElementNS("http://www.w3.org/1999/xhtml","div"),s.innerHTML=a.value,a.value=o(r,c(s),l)),a.value=p(a.value),e.innerHTML=a.value,e.className=m(e.className,u,a.language),e.result={language:a.language,re:a.r},a.second_best&&(e.second_best={language:a.second_best.language,re:a.second_best.r}))}function g(e){L=s(L,e)}function _(){if(!_.called){_.called=!0;var e=document.querySelectorAll("pre code");N.forEach.call(e,f)}}function h(){addEventListener("DOMContentLoaded",_,!1),addEventListener("load",_,!1)}function v(t,r){var a=x[t]=r(e);a.aliases&&a.aliases.forEach(function(e){C[e]=t})}function y(){return k(x)}function w(e){return e=(e||"").toLowerCase(),x[e]||x[C[e]]}var N=[],k=Object.keys,x={},C={},E=/^(no-?highlight|plain|text)$/i,M=/\blang(?:uage)?-([\w-]+)\b/i,B=/((^(<[^>]+>|\t|)+|(?:\n)))/gm,R="
",L={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0};return e.highlight=d,e.highlightAuto=b,e.fixMarkup=p,e.highlightBlock=f,e.configure=g,e.initHighlighting=_,e.initHighlightingOnLoad=h,e.registerLanguage=v,e.listLanguages=y,e.getLanguage=w,e.inherit=s,e.IR="[a-zA-Z]\\w*",e.UIR="[a-zA-Z_]\\w*",e.NR="\\b\\d+(\\.\\d+)?",e.CNR="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",e.BNR="\\b(0b[01]+)",e.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e.BE={b:"\\\\[\\s\\S]",r:0},e.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[e.BE]},e.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[e.BE]},e.PWM={b:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},e.C=function(t,r,a){var n=e.inherit({cN:"comment",b:t,e:r,c:[]},a||{});return n.c.push(e.PWM),n.c.push({cN:"doctag",b:"(?:TODO|FIXME|NOTE|BUG|XXX):",r:0}),n},e.CLCM=e.C("//","$"),e.CBCM=e.C("/\\*","\\*/"),e.HCM=e.C("#","$"),e.NM={cN:"number",b:e.NR,r:0},e.CNM={cN:"number",b:e.CNR,r:0},e.BNM={cN:"number",b:e.BNR,r:0},e.CSSNM={cN:"number",b:e.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},e.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[e.BE,{b:/\[/,e:/\]/,r:0,c:[e.BE]}]},e.TM={cN:"title",b:e.IR,r:0},e.UTM={cN:"title",b:e.UIR,r:0},e.METHOD_GUARD={b:"\\.\\s*"+e.UIR,r:0},e.registerLanguage("apache",function(e){var t={cN:"number",b:"[\\$%]\\d+"};return{aliases:["apacheconf"],cI:!0,c:[e.HCM,{cN:"section",b:""},{cN:"attribute",b:/\w+/,r:0,k:{nomarkup:"order deny allow setenv rewriterule rewriteengine rewritecond documentroot sethandler errordocument loadmodule options header listen serverroot servername"},starts:{e:/$/,r:0,k:{literal:"on off all"},c:[{cN:"meta",b:"\\s\\[",e:"\\]$"},{cN:"variable",b:"[\\$%]\\{",e:"\\}",c:["self",t]},t,e.QSM]}}],i:/\S/}}),e.registerLanguage("bash",function(e){var t={cN:"variable",v:[{b:/\$[\w\d#@][\w\d_]*/},{b:/\$\{(.*?)}/}]},r={cN:"string",b:/"/,e:/"/,c:[e.BE,t,{cN:"variable",b:/\$\(/,e:/\)/,c:[e.BE]}]},a={cN:"string",b:/'/,e:/'/};return{aliases:["sh","zsh"],l:/\b-?[a-z\._]+\b/,k:{keyword:"if then else elif fi for while in do done case esac function",literal:"true false",built_in:"break cd continue eval exec exit export getopts hash pwd readonly return shift test times trap umask unset alias bind builtin caller command declare echo enable help let local logout mapfile printf read readarray source type typeset ulimit unalias set shopt autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate fc fg float functions getcap getln history integer jobs kill limit log noglob popd print pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof zpty zregexparse zsocket zstyle ztcp",_:"-ne -eq -lt -gt -f -d -e -s -l -a"},c:[{cN:"meta",b:/^#![^\n]+sh\s*$/,r:10},{cN:"function",b:/\w[\w\d_]*\s*\(\s*\)\s*\{/,rB:!0,c:[e.inherit(e.TM,{b:/\w[\w\d_]*/})],r:0},e.HCM,r,a,t]}}),e.registerLanguage("coffeescript",function(e){var t={keyword:"in if for while finally new do return else break catch instanceof throw try this switch continue typeof delete debugger super yield import export from as default await then unless until loop of by when and or is isnt not",literal:"true false null undefined yes no on off",built_in:"npm require console print module global window document"},r="[A-Za-z$_][0-9A-Za-z$_]*",a={cN:"subst",b:/#\{/,e:/}/,k:t},n=[e.BNM,e.inherit(e.CNM,{starts:{e:"(\\s*/)?",r:0}}),{cN:"string",v:[{b:/'''/,e:/'''/,c:[e.BE]},{b:/'/,e:/'/,c:[e.BE]},{b:/"""/,e:/"""/,c:[e.BE,a]},{b:/"/,e:/"/,c:[e.BE,a]}]},{cN:"regexp",v:[{b:"///",e:"///",c:[a,e.HCM]},{b:"//[gim]*",r:0},{b:/\/(?![ *])(\\\/|.)*?\/[gim]*(?=\W|$)/}]},{b:"@"+r},{sL:"javascript",eB:!0,eE:!0,v:[{b:"```",e:"```"},{b:"`",e:"`"}]}];a.c=n;var i=e.inherit(e.TM,{b:r}),s="(\\(.*\\))?\\s*\\B[-=]>",c={cN:"params",b:"\\([^\\(]",rB:!0,c:[{b:/\(/,e:/\)/,k:t,c:["self"].concat(n)}]};return{aliases:["coffee","cson","iced"],k:t,i:/\/\*/,c:n.concat([e.C("###","###"),e.HCM,{cN:"function",b:"^\\s*"+r+"\\s*=\\s*"+s,e:"[-=]>",rB:!0,c:[i,c]},{b:/[:\(,=]\s*/,r:0,c:[{cN:"function",b:s,e:"[-=]>",rB:!0,c:[c]}]},{cN:"class",bK:"class",e:"$",i:/[:="\[\]]/,c:[{bK:"extends",eW:!0,i:/[:="\[\]]/,c:[i]},i]},{b:r+":",e:":",rB:!0,rE:!0,r:0}])}}),e.registerLanguage("cpp",function(e){var t={cN:"keyword",b:"\\b[a-z\\d_]*_t\\b"},r={cN:"string",v:[{b:'(u8?|U)?L?"',e:'"',i:"\\n",c:[e.BE]},{b:'(u8?|U)?R"',e:'"',c:[e.BE]},{b:"'\\\\?.",e:"'",i:"."}]},a={cN:"number",v:[{b:"\\b(0b[01']+)"},{b:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{b:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],r:0},n={cN:"meta",b:/#\s*[a-z]+\b/,e:/$/,k:{"meta-keyword":"if else elif endif define undef warning error line pragma ifdef ifndef include"},c:[{b:/\\\n/,r:0},e.inherit(r,{cN:"meta-string"}),{cN:"meta-string",b:/<[^\n>]*>/,e:/$/,i:"\\n"},e.CLCM,e.CBCM]},i=e.IR+"\\s*\\(",s={keyword:"int float while private char catch import module export virtual operator sizeof dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace unsigned long volatile static protected bool template mutable if public friend do goto auto void enum else break extern using asm case typeid short reinterpret_cast|10 default double register explicit signed typename try this switch continue inline delete alignof constexpr decltype noexcept static_assert thread_local restrict _Bool complex _Complex _Imaginary atomic_bool atomic_char atomic_schar atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong atomic_ullong new throw return and or not",built_in:"std string cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap array shared_ptr abort abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr",literal:"true false nullptr NULL"},c=[t,e.CLCM,e.CBCM,a,r];return{aliases:["c","cc","h","c++","h++","hpp"],k:s,i:"",k:s,c:["self",t]},{b:e.IR+"::",k:s},{v:[{b:/=/,e:/;/},{b:/\(/,e:/\)/},{bK:"new throw return else",e:/;/}],k:s,c:c.concat([{b:/\(/,e:/\)/,k:s,c:c.concat(["self"]),r:0}]),r:0},{cN:"function",b:"("+e.IR+"[\\*&\\s]+)+"+i,rB:!0,e:/[{;=]/,eE:!0,k:s,i:/[^\w\s\*&]/,c:[{b:i,rB:!0,c:[e.TM],r:0},{cN:"params",b:/\(/,e:/\)/,k:s,r:0,c:[e.CLCM,e.CBCM,r,a,t]},e.CLCM,e.CBCM,n]},{cN:"class",bK:"class struct",e:/[{;:]/,c:[{b://,c:["self"]},e.TM]}]),exports:{preprocessor:n,strings:r,k:s}}}),e.registerLanguage("cs",function(e){var t={keyword:"abstract as base bool break byte case catch char checked const continue decimal default delegate do double enum event explicit extern finally fixed float for foreach goto if implicit in int interface internal is lock long nameof object operator out override params private protected public readonly ref sbyte sealed short sizeof stackalloc static string struct switch this try typeof uint ulong unchecked unsafe ushort using virtual void volatile while add alias ascending async await by descending dynamic equals from get global group into join let on orderby partial remove select set value var where yield",literal:"null false true"},r={cN:"string",b:'@"',e:'"',c:[{b:'""'}]},a=e.inherit(r,{i:/\n/}),n={cN:"subst",b:"{",e:"}",k:t},i=e.inherit(n,{i:/\n/}),s={cN:"string",b:/\$"/,e:'"',i:/\n/,c:[{b:"{{"},{b:"}}"},e.BE,i]},c={cN:"string",b:/\$@"/,e:'"',c:[{b:"{{"},{b:"}}"},{b:'""'},n]},o=e.inherit(c,{i:/\n/,c:[{b:"{{"},{b:"}}"},{b:'""'},i]});n.c=[c,s,r,e.ASM,e.QSM,e.CNM,e.CBCM],i.c=[o,s,a,e.ASM,e.QSM,e.CNM,e.inherit(e.CBCM,{i:/\n/})];var l={v:[c,s,r,e.ASM,e.QSM]},u=e.IR+"(<"+e.IR+"(\\s*,\\s*"+e.IR+")*>)?(\\[\\])?";return{aliases:["csharp"],k:t,i:/::/,c:[e.C("///","$",{rB:!0,c:[{cN:"doctag",v:[{b:"///",r:0},{b:""},{b:""}]}]}),e.CLCM,e.CBCM,{cN:"meta",b:"#",e:"$",k:{"meta-keyword":"if else elif endif define undef warning error line region endregion pragma checksum"}},l,e.CNM,{bK:"class interface",e:/[{;=]/,i:/[^\s:]/,c:[e.TM,e.CLCM,e.CBCM]},{bK:"namespace",e:/[{;=]/,i:/[^\s:]/,c:[e.inherit(e.TM,{b:"[a-zA-Z](\\.?\\w)*"}),e.CLCM,e.CBCM]},{cN:"meta",b:"^\\s*\\[",eB:!0,e:"\\]",eE:!0,c:[{cN:"meta-string",b:/"/,e:/"/}]},{bK:"new return throw await else",r:0},{cN:"function",b:"("+u+"\\s+)+"+e.IR+"\\s*\\(",rB:!0,e:/[{;=]/,eE:!0,k:t,c:[{b:e.IR+"\\s*\\(",rB:!0,c:[e.TM],r:0},{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,k:t,r:0,c:[l,e.CNM,e.CBCM]},e.CLCM,e.CBCM]}]}}),e.registerLanguage("css",function(e){var t="[a-zA-Z-][a-zA-Z0-9_-]*",r={b:/[A-Z\_\.\-]+\s*:/,rB:!0,e:";",eW:!0,c:[{cN:"attribute",b:/\S/,e:":",eE:!0,starts:{eW:!0,eE:!0,c:[{b:/[\w-]+\(/,rB:!0,c:[{cN:"built_in",b:/[\w-]+/},{b:/\(/,e:/\)/,c:[e.ASM,e.QSM]}]},e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"number",b:"#[0-9A-Fa-f]+"},{cN:"meta",b:"!important"}]}}]};return{cI:!0,i:/[=\/|'\$]/,c:[e.CBCM,{cN:"selector-id",b:/#[A-Za-z0-9_-]+/},{cN:"selector-class",b:/\.[A-Za-z0-9_-]+/},{cN:"selector-attr",b:/\[/,e:/\]/,i:"$"},{cN:"selector-pseudo",b:/:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/},{b:"@(font-face|page)",l:"[a-z-]+",k:"font-face page"},{b:"@",e:"[{;]",i:/:/,c:[{cN:"keyword",b:/\w+/},{b:/\s/,eW:!0,eE:!0,r:0,c:[e.ASM,e.QSM,e.CSSNM]}]},{cN:"selector-tag",b:t,r:0},{b:"{",e:"}",i:/\S/,c:[e.CBCM,r]}]}}),e.registerLanguage("diff",function(e){return{aliases:["patch"],c:[{cN:"meta",r:10,v:[{b:/^@@ +\-\d+,\d+ +\+\d+,\d+ +@@$/},{b:/^\*\*\* +\d+,\d+ +\*\*\*\*$/},{b:/^\-\-\- +\d+,\d+ +\-\-\-\-$/}]},{cN:"comment",v:[{b:/Index: /,e:/$/},{b:/={3,}/,e:/$/},{b:/^\-{3}/,e:/$/},{b:/^\*{3} /,e:/$/},{b:/^\+{3}/,e:/$/},{b:/\*{5}/,e:/\*{5}$/}]},{cN:"addition",b:"^\\+",e:"$"},{cN:"deletion",b:"^\\-",e:"$"},{cN:"addition",b:"^\\!",e:"$"}]}}),e.registerLanguage("http",function(e){var t="HTTP/[0-9\\.]+";return{aliases:["https"],i:"\\S",c:[{b:"^"+t,e:"$",c:[{cN:"number",b:"\\b\\d{3}\\b"}]},{b:"^[A-Z]+ (.*?) "+t+"$",rB:!0,e:"$",c:[{cN:"string",b:" ",e:" ",eB:!0,eE:!0},{b:t},{cN:"keyword",b:"[A-Z]+"}]},{cN:"attribute",b:"^\\w",e:": ",eE:!0,i:"\\n|\\s|=",starts:{e:"$",r:0}},{b:"\\n\\n",starts:{sL:[],eW:!0}}]}}),e.registerLanguage("ini",function(e){var t={cN:"string",c:[e.BE],v:[{b:"'''",e:"'''",r:10},{b:'"""',e:'"""',r:10},{b:'"',e:'"'},{b:"'",e:"'"}]};return{aliases:["toml"],cI:!0,i:/\S/,c:[e.C(";","$"),e.HCM,{cN:"section",b:/^\s*\[+/,e:/\]+/},{b:/^[a-z0-9\[\]_-]+\s*=\s*/,e:"$",rB:!0,c:[{cN:"attr",b:/[a-z0-9\[\]_-]+/},{b:/=/,eW:!0,r:0,c:[{cN:"literal",b:/\bon|off|true|false|yes|no\b/},{cN:"variable",v:[{b:/\$[\w\d"][\w\d_]*/},{b:/\$\{(.*?)}/}]},t,{cN:"number",b:/([\+\-]+)?[\d]+_[\d_]+/},e.NM]}]}]}}),e.registerLanguage("java",function(e){var t="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=t+"(<"+t+"(\\s*,\\s*"+t+")*>)?",a="false synchronized int abstract float private char boolean static null if const for true while long strictfp finally protected import native final void enum else break transient catch instanceof byte super volatile case assert short package default double public try this switch continue throws protected public private module requires exports do",n="\\b(0[bB]([01]+[01_]+[01]+|[01]+)|0[xX]([a-fA-F0-9]+[a-fA-F0-9_]+[a-fA-F0-9]+|[a-fA-F0-9]+)|(([\\d]+[\\d_]+[\\d]+|[\\d]+)(\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))?|\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))([eE][-+]?\\d+)?)[lLfF]?",i={cN:"number",b:n,r:0};return{aliases:["jsp"],k:a,i:/<\/|#/,c:[e.C("/\\*\\*","\\*/",{r:0,c:[{b:/\w+@/,r:0},{cN:"doctag",b:"@[A-Za-z]+"}]}),e.CLCM,e.CBCM,e.ASM,e.QSM,{cN:"class",bK:"class interface",e:/[{;=]/,eE:!0,k:"class interface",i:/[:"\[\]]/,c:[{bK:"extends implements"},e.UTM]},{bK:"new throw return else",r:0},{cN:"function",b:"("+r+"\\s+)+"+e.UIR+"\\s*\\(",rB:!0,e:/[{;=]/,eE:!0,k:a,c:[{b:e.UIR+"\\s*\\(",rB:!0,r:0,c:[e.UTM]},{cN:"params",b:/\(/,e:/\)/,k:a,r:0,c:[e.ASM,e.QSM,e.CNM,e.CBCM]},e.CLCM,e.CBCM]},i,{cN:"meta",b:"@[A-Za-z]+"}]}}),e.registerLanguage("javascript",function(e){var t="[A-Za-z$_][0-9A-Za-z$_]*",r={keyword:"in of if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const export super debugger as async await static import from as",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect Promise"},a={cN:"number",v:[{b:"\\b(0[bB][01]+)"},{b:"\\b(0[oO][0-7]+)"},{b:e.CNR}],r:0},n={cN:"subst",b:"\\$\\{",e:"\\}",k:r,c:[]},i={cN:"string",b:"`",e:"`",c:[e.BE,n]};n.c=[e.ASM,e.QSM,i,a,e.RM];var s=n.c.concat([e.CBCM,e.CLCM]);return{aliases:["js","jsx"],k:r,c:[{cN:"meta",r:10,b:/^\s*['"]use (strict|asm)['"]/},{cN:"meta",b:/^#!/,e:/$/},e.ASM,e.QSM,i,e.CLCM,e.CBCM,a,{b:/[{,]\s*/,r:0,c:[{b:t+"\\s*:",rB:!0,r:0,c:[{cN:"attr",b:t,r:0}]}]},{b:"("+e.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[e.CLCM,e.CBCM,e.RM,{cN:"function",b:"(\\(.*?\\)|"+t+")\\s*=>",rB:!0,e:"\\s*=>",c:[{cN:"params",v:[{b:t},{b:/\(\s*\)/},{b:/\(/,e:/\)/,eB:!0,eE:!0,k:r,c:s}]}]},{b://,sL:"xml",c:[{b:/<\w+\s*\/>/,skip:!0},{b:/<\w+/,e:/(\/\w+|\w+\/)>/,skip:!0,c:[{b:/<\w+\s*\/>/,skip:!0},"self"]}]}],r:0},{cN:"function",bK:"function",e:/\{/,eE:!0,c:[e.inherit(e.TM,{b:t}),{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,c:s}],i:/\[|%/},{b:/\$[(.]/},e.METHOD_GUARD,{cN:"class",bK:"class",e:/[{;=]/,eE:!0,i:/[:"\[\]]/,c:[{bK:"extends"},e.UTM]},{bK:"constructor",e:/\{/,eE:!0}],i:/#(?!!)/}}),e.registerLanguage("json",function(e){var t={literal:"true false null"},r=[e.QSM,e.CNM],a={e:",",eW:!0,eE:!0,c:r,k:t},n={b:"{",e:"}",c:[{cN:"attr",b:/"/,e:/"/,c:[e.BE],i:"\\n"},e.inherit(a,{b:/:/})],i:"\\S"},i={b:"\\[",e:"\\]",c:[e.inherit(a)],i:"\\S"};return r.splice(r.length,0,n,i),{c:r,k:t,i:"\\S"}}),e.registerLanguage("makefile",function(e){var t={cN:"variable",v:[{b:"\\$\\("+e.UIR+"\\)",c:[e.BE]},{b:/\$[@%`]+/}]}]}]};return{aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist"],cI:!0,c:[{cN:"meta",b:"",r:10,c:[{b:"\\[",e:"\\]"}]},e.C("",{r:10}),{b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{b:/<\?(php)?/,e:/\?>/,sL:"php",c:[{b:"/\\*",e:"\\*/",skip:!0}]},{cN:"tag",b:"|$)",e:">",k:{name:"style"},c:[r],starts:{e:"",rE:!0,sL:["css","xml"]}},{cN:"tag",b:"|$)",e:">",k:{name:"script"},c:[r],starts:{e:"",rE:!0,sL:["actionscript","javascript","handlebars","xml"]}},{cN:"meta",v:[{b:/<\?xml/,e:/\?>/,r:10},{b:/<\?\w+/,e:/\?>/}]},{cN:"tag",b:"",c:[{cN:"name",b:/[^\/><\s]+/,r:0},r]}]}}),e.registerLanguage("markdown",function(e){return{aliases:["md","mkdown","mkd"],c:[{cN:"section",v:[{b:"^#{1,6}",e:"$"},{b:"^.+?\\n[=-]{2,}$"}]},{b:"<",e:">",sL:"xml",r:0},{cN:"bullet",b:"^([*+-]|(\\d+\\.))\\s+"},{cN:"strong",b:"[*_]{2}.+?[*_]{2}"},{cN:"emphasis",v:[{b:"\\*.+?\\*"},{b:"_.+?_",r:0}]},{cN:"quote",b:"^>\\s+",e:"$"},{cN:"code",v:[{b:"^```w*s*$",e:"^```s*$"},{b:"`.+?`"},{b:"^( {4}| )",e:"$",r:0}]},{b:"^[-\\*]{3,}",e:"$"},{b:"\\[.+?\\][\\(\\[].*?[\\)\\]]",rB:!0,c:[{cN:"string",b:"\\[",e:"\\]",eB:!0,rE:!0,r:0},{cN:"link",b:"\\]\\(",e:"\\)",eB:!0,eE:!0},{cN:"symbol",b:"\\]\\[",e:"\\]",eB:!0,eE:!0}],r:10},{b:/^\[[^\n]+\]:/,rB:!0,c:[{cN:"symbol",b:/\[/,e:/\]/,eB:!0,eE:!0},{cN:"link",b:/:\s*/,e:/$/,eB:!0}]}]}}),e.registerLanguage("nginx",function(e){var t={cN:"variable",v:[{b:/\$\d+/},{b:/\$\{/,e:/}/},{b:"[\\$\\@]"+e.UIR}]},r={eW:!0,l:"[a-z/_]+",k:{literal:"on off yes no true false none blocked debug info notice warn error crit select break last permanent redirect kqueue rtsig epoll poll /dev/poll"},r:0,i:"=>",c:[e.HCM,{cN:"string",c:[e.BE,t],v:[{b:/"/,e:/"/},{b:/'/,e:/'/}]},{b:"([a-z]+):/",e:"\\s",eW:!0,eE:!0,c:[t]},{cN:"regexp",c:[e.BE,t],v:[{b:"\\s\\^",e:"\\s|{|;",rE:!0},{b:"~\\*?\\s+",e:"\\s|{|;",rE:!0},{b:"\\*(\\.[a-z\\-]+)+"},{b:"([a-z\\-]+\\.)+\\*"}]},{cN:"number",b:"\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b"},{cN:"number",b:"\\b\\d+[kKmMgGdshdwy]*\\b",r:0},t]};return{aliases:["nginxconf"],c:[e.HCM,{b:e.UIR+"\\s+{",rB:!0,e:"{",c:[{cN:"section",b:e.UIR}],r:0},{b:e.UIR+"\\s",e:";|{",rB:!0,c:[{cN:"attribute",b:e.UIR,starts:r}],r:0}],i:"[^\\s\\}]"}}),e.registerLanguage("objectivec",function(e){var t={cN:"built_in",b:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},r={keyword:"int float while char export sizeof typedef const struct for union unsigned long volatile static bool mutable if do return goto void enum else break extern asm case short default double register explicit signed typename this switch continue wchar_t inline readonly assign readwrite self @synchronized id typeof nonatomic super unichar IBOutlet IBAction strong weak copy in out inout bycopy byref oneway __strong __weak __block __autoreleasing @private @protected @public @try @property @end @throw @catch @finally @autoreleasepool @synthesize @dynamic @selector @optional @required @encode @package @import @defs @compatibility_alias __bridge __bridge_transfer __bridge_retained __bridge_retain __covariant __contravariant __kindof _Nonnull _Nullable _Null_unspecified __FUNCTION__ __PRETTY_FUNCTION__ __attribute__ getter setter retain unsafe_unretained nonnull nullable null_unspecified null_resettable class instancetype NS_DESIGNATED_INITIALIZER NS_UNAVAILABLE NS_REQUIRES_SUPER NS_RETURNS_INNER_POINTER NS_INLINE NS_AVAILABLE NS_DEPRECATED NS_ENUM NS_OPTIONS NS_SWIFT_UNAVAILABLE NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END NS_REFINED_FOR_SWIFT NS_SWIFT_NAME NS_SWIFT_NOTHROW NS_DURING NS_HANDLER NS_ENDHANDLER NS_VALUERETURN NS_VOIDRETURN",literal:"false true FALSE TRUE nil YES NO NULL",built_in:"BOOL dispatch_once_t dispatch_queue_t dispatch_sync dispatch_async dispatch_once"},a=/[a-zA-Z@][a-zA-Z0-9_]*/,n="@interface @class @protocol @implementation";return{aliases:["mm","objc","obj-c"],k:r,l:a,i:""}]}]},{cN:"class",b:"("+n.split(" ").join("|")+")\\b",e:"({|$)",eE:!0,k:n,l:a,c:[e.UTM]},{b:"\\."+e.UIR,r:0}]}}),e.registerLanguage("perl",function(e){var t="getpwent getservent quotemeta msgrcv scalar kill dbmclose undef lc ma syswrite tr send umask sysopen shmwrite vec qx utime local oct semctl localtime readpipe do return format read sprintf dbmopen pop getpgrp not getpwnam rewinddir qqfileno qw endprotoent wait sethostent bless s|0 opendir continue each sleep endgrent shutdown dump chomp connect getsockname die socketpair close flock exists index shmgetsub for endpwent redo lstat msgctl setpgrp abs exit select print ref gethostbyaddr unshift fcntl syscall goto getnetbyaddr join gmtime symlink semget splice x|0 getpeername recv log setsockopt cos last reverse gethostbyname getgrnam study formline endhostent times chop length gethostent getnetent pack getprotoent getservbyname rand mkdir pos chmod y|0 substr endnetent printf next open msgsnd readdir use unlink getsockopt getpriority rindex wantarray hex system getservbyport endservent int chr untie rmdir prototype tell listen fork shmread ucfirst setprotoent else sysseek link getgrgid shmctl waitpid unpack getnetbyname reset chdir grep split require caller lcfirst until warn while values shift telldir getpwuid my getprotobynumber delete and sort uc defined srand accept package seekdir getprotobyname semop our rename seek if q|0 chroot sysread setpwent no crypt getc chown sqrt write setnetent setpriority foreach tie sin msgget map stat getlogin unless elsif truncate exec keys glob tied closedirioctl socket readlink eval xor readline binmode setservent eof ord bind alarm pipe atan2 getgrent exp time push setgrent gt lt or ne m|0 break given say state when",r={cN:"subst",b:"[$@]\\{",e:"\\}",k:t},a={b:"->{",e:"}"},n={v:[{b:/\$\d/},{b:/[\$%@](\^\w\b|#\w+(::\w+)*|{\w+}|\w+(::\w*)*)/},{b:/[\$%@][^\s\w{]/,r:0}]},i=[e.BE,r,n],s=[n,e.HCM,e.C("^\\=\\w","\\=cut",{eW:!0}),a,{cN:"string",c:i,v:[{b:"q[qwxr]?\\s*\\(",e:"\\)",r:5},{b:"q[qwxr]?\\s*\\[",e:"\\]",r:5},{b:"q[qwxr]?\\s*\\{",e:"\\}",r:5},{b:"q[qwxr]?\\s*\\|",e:"\\|",r:5},{b:"q[qwxr]?\\s*\\<",e:"\\>",r:5},{b:"qw\\s+q",e:"q",r:5},{b:"'",e:"'",c:[e.BE]},{b:'"',e:'"'},{b:"`",e:"`",c:[e.BE]},{b:"{\\w+}",c:[],r:0},{b:"-?\\w+\\s*\\=\\>",c:[],r:0}]},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{b:"(\\/\\/|"+e.RSR+"|\\b(split|return|print|reverse|grep)\\b)\\s*",k:"split return print reverse grep",r:0,c:[e.HCM,{cN:"regexp",b:"(s|tr|y)/(\\\\.|[^/])*/(\\\\.|[^/])*/[a-z]*",r:10},{cN:"regexp",b:"(m|qr)?/",e:"/[a-z]*",c:[e.BE],r:0}]},{cN:"function",bK:"sub",e:"(\\s*\\(.*?\\))?[;{]",eE:!0,r:5,c:[e.TM]},{b:"-\\w\\b",r:0},{b:"^__DATA__$",e:"^__END__$",sL:"mojolicious",c:[{b:"^@@.*",e:"$",cN:"comment"}]}];return r.c=s,a.c=s,{aliases:["pl","pm"],l:/[\w\.]+/,k:t,c:s}}),e.registerLanguage("php",function(e){var t={b:"\\$+[a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*"},r={cN:"meta",b:/<\?(php)?|\?>/},a={cN:"string",c:[e.BE,r],v:[{b:'b"',e:'"'},{b:"b'",e:"'"},e.inherit(e.ASM,{i:null}),e.inherit(e.QSM,{i:null})]},n={v:[e.BNM,e.CNM]};return{aliases:["php3","php4","php5","php6"],cI:!0,k:"and include_once list abstract global private echo interface as static endswitch array null if endwhile or const for endforeach self var while isset public protected exit foreach throw elseif include __FILE__ empty require_once do xor return parent clone use __CLASS__ __LINE__ else break print eval new catch __METHOD__ case exception default die require __FUNCTION__ enddeclare final try switch continue endfor endif declare unset true false trait goto instanceof insteadof __DIR__ __NAMESPACE__ yield finally",c:[e.HCM,e.C("//","$",{c:[r]}),e.C("/\\*","\\*/",{c:[{cN:"doctag",b:"@[A-Za-z]+"}]}),e.C("__halt_compiler.+?;",!1,{eW:!0,k:"__halt_compiler",l:e.UIR}),{cN:"string",b:/<<<['"]?\w+['"]?$/,e:/^\w+;?$/,c:[e.BE,{cN:"subst",v:[{b:/\$\w+/},{b:/\{\$/,e:/\}/}]}]},r,{cN:"keyword",b:/\$this\b/},t,{b:/(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/},{cN:"function",bK:"function",e:/[;{]/,eE:!0,i:"\\$|\\[|%",c:[e.UTM,{cN:"params",b:"\\(",e:"\\)",c:["self",t,e.CBCM,a,n]}]},{cN:"class",bK:"class interface",e:"{",eE:!0,i:/[:\(\$"]/,c:[{bK:"extends implements"},e.UTM]},{bK:"namespace",e:";",i:/[\.']/,c:[e.UTM]},{bK:"use",e:";",c:[e.UTM]},{b:"=>"},a,n]}}),e.registerLanguage("python",function(e){var t={keyword:"and elif is global as in if from raise for except finally print import pass return exec else break not with class assert yield try while continue del or def lambda async await nonlocal|10 None True False",built_in:"Ellipsis NotImplemented"},r={cN:"meta",b:/^(>>>|\.\.\.) /},a={cN:"subst",b:/\{/,e:/\}/,k:t,i:/#/},n={cN:"string",c:[e.BE],v:[{b:/(u|b)?r?'''/,e:/'''/,c:[r],r:10},{b:/(u|b)?r?"""/,e:/"""/,c:[r],r:10},{b:/(fr|rf|f)'''/,e:/'''/,c:[r,a]},{b:/(fr|rf|f)"""/,e:/"""/,c:[r,a]},{b:/(u|r|ur)'/,e:/'/,r:10},{b:/(u|r|ur)"/,e:/"/,r:10},{b:/(b|br)'/,e:/'/},{b:/(b|br)"/,e:/"/},{b:/(fr|rf|f)'/,e:/'/,c:[a]},{b:/(fr|rf|f)"/,e:/"/,c:[a]},e.ASM,e.QSM]},i={cN:"number",r:0,v:[{b:e.BNR+"[lLjJ]?"},{b:"\\b(0o[0-7]+)[lLjJ]?"},{b:e.CNR+"[lLjJ]?"}]},s={cN:"params",b:/\(/,e:/\)/,c:["self",r,i,n]};return a.c=[n,i,r],{aliases:["py","gyp"],k:t,i:/(<\/|->|\?)|=>/,c:[r,i,n,e.HCM,{v:[{cN:"function",bK:"def"},{cN:"class",bK:"class"}],e:/:/,i:/[${=;\n,]/,c:[e.UTM,s,{b:/->/,eW:!0,k:"None"}]},{cN:"meta",b:/^[\t ]*@/,e:/$/},{b:/\b(print|exec)\(/}]}}),e.registerLanguage("ruby",function(e){ 3 | var t="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?",r={keyword:"and then defined module in return redo if BEGIN retry end for self when next until do begin unless END rescue else break undef not super class case require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor",literal:"true false nil"},a={cN:"doctag",b:"@[A-Za-z]+"},n={b:"#<",e:">"},i=[e.C("#","$",{c:[a]}),e.C("^\\=begin","^\\=end",{c:[a],r:10}),e.C("^__END__","\\n$")],s={cN:"subst",b:"#\\{",e:"}",k:r},c={cN:"string",c:[e.BE,s],v:[{b:/'/,e:/'/},{b:/"/,e:/"/},{b:/`/,e:/`/},{b:"%[qQwWx]?\\(",e:"\\)"},{b:"%[qQwWx]?\\[",e:"\\]"},{b:"%[qQwWx]?{",e:"}"},{b:"%[qQwWx]?<",e:">"},{b:"%[qQwWx]?/",e:"/"},{b:"%[qQwWx]?%",e:"%"},{b:"%[qQwWx]?-",e:"-"},{b:"%[qQwWx]?\\|",e:"\\|"},{b:/\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/},{b:/<<(-?)\w+$/,e:/^\s*\w+$/}]},o={cN:"params",b:"\\(",e:"\\)",endsParent:!0,k:r},l=[c,n,{cN:"class",bK:"class module",e:"$|;",i:/=/,c:[e.inherit(e.TM,{b:"[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?"}),{b:"<\\s*",c:[{b:"("+e.IR+"::)?"+e.IR}]}].concat(i)},{cN:"function",bK:"def",e:"$|;",c:[e.inherit(e.TM,{b:t}),o].concat(i)},{b:e.IR+"::"},{cN:"symbol",b:e.UIR+"(\\!|\\?)?:",r:0},{cN:"symbol",b:":(?!\\s)",c:[c,{b:t}],r:0},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{b:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},{cN:"params",b:/\|/,e:/\|/,k:r},{b:"("+e.RSR+"|unless)\\s*",k:"unless",c:[n,{cN:"regexp",c:[e.BE,s],i:/\n/,v:[{b:"/",e:"/[a-z]*"},{b:"%r{",e:"}[a-z]*"},{b:"%r\\(",e:"\\)[a-z]*"},{b:"%r!",e:"![a-z]*"},{b:"%r\\[",e:"\\][a-z]*"}]}].concat(i),r:0}].concat(i);s.c=l,o.c=l;var u="[>?]>",d="[\\w#]+\\(\\w+\\):\\d+:\\d+>",b="(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>",p=[{b:/^\s*=>/,starts:{e:"$",c:l}},{cN:"meta",b:"^("+u+"|"+d+"|"+b+")",starts:{e:"$",c:l}}];return{aliases:["rb","gemspec","podspec","thor","irb"],k:r,i:/\/\*/,c:i.concat(p).concat(l)}}),e.registerLanguage("shell",function(e){return{aliases:["console"],c:[{cN:"meta",b:"^\\s{0,3}[\\w\\d\\[\\]()@-]*[>%$#]",starts:{e:"$",sL:"bash"}}]}}),e.registerLanguage("sql",function(e){var t=e.C("--","$");return{cI:!0,i:/[<>{}*#]/,c:[{bK:"begin end start commit rollback savepoint lock alter create drop rename call delete do handler insert load replace select truncate update set show pragma grant merge describe use explain help declare prepare execute deallocate release unlock purge reset change stop analyze cache flush optimize repair kill install uninstall checksum restore check backup revoke comment",e:/;/,eW:!0,l:/[\w\.]+/,k:{keyword:"abort abs absolute acc acce accep accept access accessed accessible account acos action activate add addtime admin administer advanced advise aes_decrypt aes_encrypt after agent aggregate ali alia alias allocate allow alter always analyze ancillary and any anydata anydataset anyschema anytype apply archive archived archivelog are as asc ascii asin assembly assertion associate asynchronous at atan atn2 attr attri attrib attribu attribut attribute attributes audit authenticated authentication authid authors auto autoallocate autodblink autoextend automatic availability avg backup badfile basicfile before begin beginning benchmark between bfile bfile_base big bigfile bin binary_double binary_float binlog bit_and bit_count bit_length bit_or bit_xor bitmap blob_base block blocksize body both bound buffer_cache buffer_pool build bulk by byte byteordermark bytes cache caching call calling cancel capacity cascade cascaded case cast catalog category ceil ceiling chain change changed char_base char_length character_length characters characterset charindex charset charsetform charsetid check checksum checksum_agg child choose chr chunk class cleanup clear client clob clob_base clone close cluster_id cluster_probability cluster_set clustering coalesce coercibility col collate collation collect colu colum column column_value columns columns_updated comment commit compact compatibility compiled complete composite_limit compound compress compute concat concat_ws concurrent confirm conn connec connect connect_by_iscycle connect_by_isleaf connect_by_root connect_time connection consider consistent constant constraint constraints constructor container content contents context contributors controlfile conv convert convert_tz corr corr_k corr_s corresponding corruption cos cost count count_big counted covar_pop covar_samp cpu_per_call cpu_per_session crc32 create creation critical cross cube cume_dist curdate current current_date current_time current_timestamp current_user cursor curtime customdatum cycle data database databases datafile datafiles datalength date_add date_cache date_format date_sub dateadd datediff datefromparts datename datepart datetime2fromparts day day_to_second dayname dayofmonth dayofweek dayofyear days db_role_change dbtimezone ddl deallocate declare decode decompose decrement decrypt deduplicate def defa defau defaul default defaults deferred defi defin define degrees delayed delegate delete delete_all delimited demand dense_rank depth dequeue des_decrypt des_encrypt des_key_file desc descr descri describ describe descriptor deterministic diagnostics difference dimension direct_load directory disable disable_all disallow disassociate discardfile disconnect diskgroup distinct distinctrow distribute distributed div do document domain dotnet double downgrade drop dumpfile duplicate duration each edition editionable editions element ellipsis else elsif elt empty enable enable_all enclosed encode encoding encrypt end end-exec endian enforced engine engines enqueue enterprise entityescaping eomonth error errors escaped evalname evaluate event eventdata events except exception exceptions exchange exclude excluding execu execut execute exempt exists exit exp expire explain export export_set extended extent external external_1 external_2 externally extract failed failed_login_attempts failover failure far fast feature_set feature_value fetch field fields file file_name_convert filesystem_like_logging final finish first first_value fixed flash_cache flashback floor flush following follows for forall force form forma format found found_rows freelist freelists freepools fresh from from_base64 from_days ftp full function general generated get get_format get_lock getdate getutcdate global global_name globally go goto grant grants greatest group group_concat group_id grouping grouping_id groups gtid_subtract guarantee guard handler hash hashkeys having hea head headi headin heading heap help hex hierarchy high high_priority hosts hour http id ident_current ident_incr ident_seed identified identity idle_time if ifnull ignore iif ilike ilm immediate import in include including increment index indexes indexing indextype indicator indices inet6_aton inet6_ntoa inet_aton inet_ntoa infile initial initialized initially initrans inmemory inner innodb input insert install instance instantiable instr interface interleaved intersect into invalidate invisible is is_free_lock is_ipv4 is_ipv4_compat is_not is_not_null is_used_lock isdate isnull isolation iterate java join json json_exists keep keep_duplicates key keys kill language large last last_day last_insert_id last_value lax lcase lead leading least leaves left len lenght length less level levels library like like2 like4 likec limit lines link list listagg little ln load load_file lob lobs local localtime localtimestamp locate locator lock locked log log10 log2 logfile logfiles logging logical logical_reads_per_call logoff logon logs long loop low low_priority lower lpad lrtrim ltrim main make_set makedate maketime managed management manual map mapping mask master master_pos_wait match matched materialized max maxextents maximize maxinstances maxlen maxlogfiles maxloghistory maxlogmembers maxsize maxtrans md5 measures median medium member memcompress memory merge microsecond mid migration min minextents minimum mining minus minute minvalue missing mod mode model modification modify module monitoring month months mount move movement multiset mutex name name_const names nan national native natural nav nchar nclob nested never new newline next nextval no no_write_to_binlog noarchivelog noaudit nobadfile nocheck nocompress nocopy nocycle nodelay nodiscardfile noentityescaping noguarantee nokeep nologfile nomapping nomaxvalue nominimize nominvalue nomonitoring none noneditionable nonschema noorder nopr nopro noprom nopromp noprompt norely noresetlogs noreverse normal norowdependencies noschemacheck noswitch not nothing notice notrim novalidate now nowait nth_value nullif nulls num numb numbe nvarchar nvarchar2 object ocicoll ocidate ocidatetime ociduration ociinterval ociloblocator ocinumber ociref ocirefcursor ocirowid ocistring ocitype oct octet_length of off offline offset oid oidindex old on online only opaque open operations operator optimal optimize option optionally or oracle oracle_date oradata ord ordaudio orddicom orddoc order ordimage ordinality ordvideo organization orlany orlvary out outer outfile outline output over overflow overriding package pad parallel parallel_enable parameters parent parse partial partition partitions pascal passing password password_grace_time password_lock_time password_reuse_max password_reuse_time password_verify_function patch path patindex pctincrease pctthreshold pctused pctversion percent percent_rank percentile_cont percentile_disc performance period period_add period_diff permanent physical pi pipe pipelined pivot pluggable plugin policy position post_transaction pow power pragma prebuilt precedes preceding precision prediction prediction_cost prediction_details prediction_probability prediction_set prepare present preserve prior priority private private_sga privileges procedural procedure procedure_analyze processlist profiles project prompt protection public publishingservername purge quarter query quick quiesce quota quotename radians raise rand range rank raw read reads readsize rebuild record records recover recovery recursive recycle redo reduced ref reference referenced references referencing refresh regexp_like register regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy reject rekey relational relative relaylog release release_lock relies_on relocate rely rem remainder rename repair repeat replace replicate replication required reset resetlogs resize resource respect restore restricted result result_cache resumable resume retention return returning returns reuse reverse revoke right rlike role roles rollback rolling rollup round row row_count rowdependencies rowid rownum rows rtrim rules safe salt sample save savepoint sb1 sb2 sb4 scan schema schemacheck scn scope scroll sdo_georaster sdo_topo_geometry search sec_to_time second section securefile security seed segment select self sequence sequential serializable server servererror session session_user sessions_per_user set sets settings sha sha1 sha2 share shared shared_pool short show shrink shutdown si_averagecolor si_colorhistogram si_featurelist si_positionalcolor si_stillimage si_texture siblings sid sign sin size size_t sizes skip slave sleep smalldatetimefromparts smallfile snapshot some soname sort soundex source space sparse spfile split sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_small_result sql_variant_property sqlcode sqldata sqlerror sqlname sqlstate sqrt square standalone standby start starting startup statement static statistics stats_binomial_test stats_crosstab stats_ks_test stats_mode stats_mw_test stats_one_way_anova stats_t_test_ stats_t_test_indep stats_t_test_one stats_t_test_paired stats_wsr_test status std stddev stddev_pop stddev_samp stdev stop storage store stored str str_to_date straight_join strcmp strict string struct stuff style subdate subpartition subpartitions substitutable substr substring subtime subtring_index subtype success sum suspend switch switchoffset switchover sync synchronous synonym sys sys_xmlagg sysasm sysaux sysdate sysdatetimeoffset sysdba sysoper system system_user sysutcdatetime table tables tablespace tan tdo template temporary terminated tertiary_weights test than then thread through tier ties time time_format time_zone timediff timefromparts timeout timestamp timestampadd timestampdiff timezone_abbr timezone_minute timezone_region to to_base64 to_date to_days to_seconds todatetimeoffset trace tracking transaction transactional translate translation treat trigger trigger_nestlevel triggers trim truncate try_cast try_convert try_parse type ub1 ub2 ub4 ucase unarchived unbounded uncompress under undo unhex unicode uniform uninstall union unique unix_timestamp unknown unlimited unlock unpivot unrecoverable unsafe unsigned until untrusted unusable unused update updated upgrade upped upper upsert url urowid usable usage use use_stored_outlines user user_data user_resources users using utc_date utc_timestamp uuid uuid_short validate validate_password_strength validation valist value values var var_samp varcharc vari varia variab variabl variable variables variance varp varraw varrawc varray verify version versions view virtual visible void wait wallet warning warnings week weekday weekofyear wellformed when whene whenev wheneve whenever where while whitespace with within without work wrapped xdb xml xmlagg xmlattributes xmlcast xmlcolattval xmlelement xmlexists xmlforest xmlindex xmlnamespaces xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltype xor year year_to_month years yearweek",literal:"true false null",built_in:"array bigint binary bit blob boolean char character date dec decimal float int int8 integer interval number numeric real record serial serial8 smallint text varchar varying void"},c:[{cN:"string",b:"'",e:"'",c:[e.BE,{b:"''"}]},{cN:"string",b:'"',e:'"',c:[e.BE,{b:'""'}]},{cN:"string",b:"`",e:"`",c:[e.BE]},e.CNM,e.CBCM,t]},e.CBCM,t]}}),e}); -------------------------------------------------------------------------------- /web/image_720.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/image_720.jpeg -------------------------------------------------------------------------------- /web/image_888.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/image_888.jpeg -------------------------------------------------------------------------------- /web/image_960.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/image_960.jpeg -------------------------------------------------------------------------------- /web/image_orig.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/image_orig.jpeg -------------------------------------------------------------------------------- /web/image_orig_blue6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/image_orig_blue6.png -------------------------------------------------------------------------------- /web/image_social.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/image_social.jpeg -------------------------------------------------------------------------------- /web/image_social_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/image_social_2.png -------------------------------------------------------------------------------- /web/image_social_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/image_social_3.png -------------------------------------------------------------------------------- /web/image_social_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/image_social_4.png -------------------------------------------------------------------------------- /web/image_social_bckp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/image_social_bckp.png -------------------------------------------------------------------------------- /web/image_twitter_card.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/image_twitter_card.jpeg -------------------------------------------------------------------------------- /web/image_twitter_card_2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/image_twitter_card_2.jpeg -------------------------------------------------------------------------------- /web/mario_bros.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/mario_bros.png -------------------------------------------------------------------------------- /web/script_2.js: -------------------------------------------------------------------------------- 1 | const TOC = 2 | 'ToC = {\n' + 3 | ' \'1. Collections\': [List, Dictionary, Set, Tuple, Range, Enumerate, Iterator, Generator],\n' + 4 | ' \'2. Types\': [Type, String, Regular_Exp, Format, Numbers, Combinatorics, Datetime],\n' + 5 | ' \'3. Syntax\': [Function, Inline, Import, Decorator, Class, Duck_Type, Enum, Except],\n' + 6 | ' \'4. System\': [Exit, Print, Input, Command_Line_Arguments, Open, Path, OS_Commands],\n' + 7 | ' \'5. Data\': [JSON, Pickle, CSV, SQLite, Bytes, Struct, Array, Memory_View, Deque],\n' + 8 | ' \'6. Advanced\': [Operator, Match_Stmt, Logging, Introspection, Threading, Coroutines],\n' + 9 | ' \'7. Libraries\': [Progress_Bar, Plot, Table, Console_App, GUI, Scraping, Web, Profile],\n' + 10 | ' \'8. Multimedia\': [NumPy, Image, Animation, Audio, Synthesizer, Pygame, Pandas, Plotly]\n' + 11 | '}\n'; 12 | 13 | const TOC_MOBILE = 14 | 'ToC = {\n' + 15 | ' \'1. Collections\': [List, Dictionary, Set,\n' + 16 | ' Tuple, Range, Enumerate,\n' + 17 | ' Iterator, Generator],\n' + 18 | ' \'2. Types\': [Type, String, Regular_Exp,\n' + 19 | ' Format, Numbers,\n' + 20 | ' Combinatorics, Datetime],\n' + 21 | ' \'3. Syntax\': [Function, Inline, Import,\n' + 22 | ' Decorator, Class,\n' + 23 | ' Duck_Types, Enum, Except],\n' + 24 | ' \'4. System\': [Exit, Print, Input,\n' + 25 | ' Command_Line_Arguments,\n' + 26 | ' Open, Paths, OS_Commands],\n' + 27 | ' \'5. Data\': [JSON, Pickle, CSV, SQLite,\n' + 28 | ' Bytes, Struct, Array,\n' + 29 | ' Memory_View, Deque],\n' + 30 | ' \'6. Advanced\': [Operator, Match_Statement,\n' + 31 | ' Logging, Introspection,\n' + 32 | ' Threading, Coroutines],\n' + 33 | ' \'7. Libraries\': [Progress_Bar, Plot, Table,\n' + 34 | ' Console_App, GUI_App,\n' + 35 | ' Scraping, Web, Profiling],\n' + 36 | ' \'8. Multimedia\': [NumPy, Image, Animation,\n' + 37 | ' Audio, Synthesizer,\n' + 38 | ' Pygame, Pandas, Plotly]\n' + 39 | '}\n'; 40 | 41 | 42 | var iOS = /iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; 43 | 44 | if (iOS) { 45 | var viewport_meta = document.getElementById('viewport-meta'); 46 | viewport_meta.setAttribute('content', "initial-scale=0.55"); 47 | } 48 | 49 | var isMobile = false; 50 | // Device detection: 51 | if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) 52 | || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))) { 53 | isMobile = true; 54 | } 55 | 56 | var TOC_SCREEN_WIDTH_CUTOFF = 667 57 | var TOC_EM = '2em' 58 | var TOC_EM_DESKTOP = '1.327em' 59 | var PLOTLY_WIDTH_DESKTOP = 914 60 | 61 | 62 | function switch_to_mobile_view() { 63 | $(`code:contains(ToC)`).html(TOC_MOBILE).css("line-height", TOC_EM); 64 | const body = document.querySelector("body"); 65 | body.style["width"] = `${TOC_SCREEN_WIDTH_CUTOFF+9}px`; 66 | const plotlyDivs = document.querySelectorAll(".plotly-graph-div"); 67 | plotlyDivs.forEach((div) => { 68 | div.style["width"] = `${TOC_SCREEN_WIDTH_CUTOFF}px`; 69 | }); 70 | } 71 | 72 | 73 | function switch_to_desktop_view() { 74 | $(`code:contains(ToC)`).html(TOC).css("line-height", TOC_EM_DESKTOP); 75 | const body = document.querySelector("body"); 76 | body.style["width"] = ""; 77 | const plotlyDivs = document.querySelectorAll(".plotly-graph-div"); 78 | plotlyDivs.forEach((div) => { 79 | div.style["width"] = `${PLOTLY_WIDTH_DESKTOP}px`; 80 | }); 81 | } 82 | 83 | if (isMobile && window.screen.width < TOC_SCREEN_WIDTH_CUTOFF) { 84 | switch_to_mobile_view() 85 | } 86 | 87 | function updateToc() { 88 | if (isMobile && window.screen.width < TOC_SCREEN_WIDTH_CUTOFF) { 89 | switch_to_mobile_view(); 90 | } else { 91 | switch_to_desktop_view(); 92 | } 93 | } 94 | window.addEventListener("orientationchange", updateToc, false); 95 | 96 | // ===== Scroll to Top ==== 97 | $(window).scroll(function() { 98 | if (isMobile && $(this).scrollTop() >= 480) { // If mobile device and page is scrolled more than 520px. 99 | $('#return-to-top').fadeIn(200); // Fade in the arrow 100 | } else { 101 | $('#return-to-top').fadeOut(200); // Else fade out the arrow 102 | } 103 | }); 104 | 105 | $('#return-to-top').click(function() { // When arrow is clicked 106 | $('body,html').animate({ 107 | scrollTop : 0 // Scroll to top of body 108 | }, 500); 109 | }); 110 | -------------------------------------------------------------------------------- /web/style.css: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Michael Bostock. All rights reserved. Do not copy. */ 2 | 3 | @import url(https://fonts.googleapis.com/css?family=PT+Serif|PT+Serif:b|PT+Serif:i|PT+Sans|PT+Sans:b); 4 | 5 | .ocks-org body { 6 | background: #fcfcfa; 7 | color: #333; 8 | font-family: "PT Serif", serif; 9 | margin: 1em auto 4em auto; 10 | position: relative; 11 | width: 960px; 12 | padding: 1rem; 13 | } 14 | 15 | .ocks-org header, 16 | .ocks-org footer, 17 | .ocks-org aside, 18 | .ocks-org h1, 19 | .ocks-org h2, 20 | .ocks-org h3, 21 | .ocks-org h4 { 22 | font-family: "PT Sans", sans-serif; 23 | } 24 | 25 | .ocks-org h1, 26 | .ocks-org h2, 27 | .ocks-org h3, 28 | .ocks-org h4 { 29 | color: #000; 30 | } 31 | 32 | .ocks-org header, 33 | .ocks-org footer { 34 | color: #636363; 35 | } 36 | 37 | h1 { 38 | font-size: 64px; 39 | font-weight: 300; 40 | letter-spacing: -2px; 41 | margin: 0.3em 0 0.1em 0; 42 | } 43 | 44 | h2 { 45 | margin-top: 2em; 46 | } 47 | 48 | h1, 49 | h2 { 50 | text-rendering: optimizeLegibility; 51 | } 52 | 53 | h2 a[name], 54 | h2 a[id] { 55 | color: #ccc; 56 | padding-right: 0.3em; 57 | } 58 | 59 | header, 60 | footer { 61 | font-size: small; 62 | } 63 | 64 | .ocks-org header aside, 65 | .ocks-org footer aside { 66 | float: left; 67 | margin-right: 0.5em; 68 | } 69 | 70 | .ocks-org header aside:after, 71 | .ocks-org footer aside:after { 72 | padding-left: 0.5em; 73 | content: "/"; 74 | } 75 | 76 | footer { 77 | margin-top: 6em; 78 | } 79 | 80 | h1 ~ aside { 81 | font-size: small; 82 | right: 0; 83 | position: absolute; 84 | width: 180px; 85 | } 86 | 87 | .attribution { 88 | font-size: small; 89 | margin-bottom: 2em; 90 | } 91 | 92 | body > p, 93 | li > p, 94 | div > p { 95 | line-height: 1.5em; 96 | } 97 | 98 | body > p, 99 | div > p { 100 | width: 720px; 101 | } 102 | 103 | body > blockquote { 104 | width: 640px; 105 | } 106 | 107 | blockquote q { 108 | display: block; 109 | font-style: oblique; 110 | } 111 | 112 | ul { 113 | padding: 0; 114 | } 115 | 116 | li { 117 | width: 690px; 118 | margin-left: 30px; 119 | } 120 | 121 | a { 122 | color: steelblue; 123 | } 124 | 125 | a:not(:hover) { 126 | text-decoration: none; 127 | } 128 | 129 | pre, 130 | code, 131 | textarea { 132 | font-family: "Menlo", "Menlo Web", monospace; 133 | } 134 | 135 | code { 136 | line-height: 1em; 137 | } 138 | 139 | textarea { 140 | font-size: 100%; 141 | } 142 | 143 | pre { 144 | border-left: solid 2px #ccc; 145 | padding-left: 18px; 146 | margin: 2em 0 2em 0; 147 | } 148 | 149 | .html .value, 150 | .javascript .string, 151 | .javascript .regexp { 152 | color: #756bb1; 153 | } 154 | 155 | .html .tag, 156 | .css .tag, 157 | .javascript .keyword { 158 | color: #3182bd; 159 | } 160 | 161 | .comment { 162 | color: #636363; 163 | } 164 | 165 | .html .doctype, 166 | .javascript .number { 167 | color: #31a354; 168 | } 169 | 170 | .html .attribute, 171 | .css .attribute, 172 | .javascript .class, 173 | .javascript .special { 174 | color: #e6550d; 175 | } 176 | 177 | svg { 178 | font: 10px sans-serif; 179 | } 180 | 181 | .axis path, 182 | .axis line { 183 | fill: none; 184 | stroke: #000; 185 | shape-rendering: crispEdges; 186 | } 187 | 188 | sup, 189 | sub { 190 | line-height: 0; 191 | } 192 | 193 | q:before { 194 | content: "“"; 195 | } 196 | 197 | q:after { 198 | content: "”"; 199 | } 200 | 201 | blockquote q { 202 | line-height: 1.5em; 203 | display: inline; 204 | } 205 | 206 | blockquote q:before, 207 | blockquote q:after { 208 | content: ""; 209 | } 210 | 211 | h3, 212 | h4, 213 | p, 214 | ul { 215 | padding-left: 1.2rem; 216 | } 217 | 218 | .banner { 219 | padding: 0; 220 | } 221 | 222 | #toc { 223 | margin-top: 0; 224 | } 225 | 226 | @media only screen and (max-device-width: 1023px) { 227 | .ocks-org body { 228 | font-size: 72%; 229 | padding: 0.5rem; 230 | } 231 | 232 | body > p, 233 | div > p { 234 | width: 90vw !important; 235 | } 236 | 237 | li { 238 | width: 82vw; 239 | } 240 | 241 | h3, 242 | h4, 243 | p, 244 | ul { 245 | padding-left: .7rem; 246 | width: 90vw; 247 | } 248 | 249 | h1 { 250 | font-size: 2rem; 251 | } 252 | 253 | pre { 254 | padding-left: 0.5rem; 255 | } 256 | 257 | .banner, 258 | h1, 259 | img { 260 | max-width: calc(100vw - 2em); 261 | min-width: calc(100vw - 2em); 262 | } 263 | } 264 | 265 | 266 | /*@import url(web/style.css);*/ 267 | 268 | @font-face {font-family: "Menlo web"; 269 | src: url("OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1\\@font-face\\9f94dc20bb2a09c15241d3a880b7ad01.woff2") format("woff2"), /* chrome、firefox */ 270 | url("OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1\\@font-face\\9f94dc20bb2a09c15241d3a880b7ad01.woff") format("woff"); 271 | font-weight: normal; 272 | } 273 | 274 | @font-face {font-family: "Menlo web"; 275 | src: url("OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88\\Menlo Bold\\@font-face\\a6ffc5d72a96b65159e710ea6d258ba4.woff2") format("woff2"), /* chrome、firefox */ 276 | url("OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88\\Menlo Bold\\@font-face\\a6ffc5d72a96b65159e710ea6d258ba4.woff") format("woff"); 277 | font-weight: bold; 278 | } 279 | 280 | .join, 281 | .link, 282 | .node rect { 283 | fill: none; 284 | stroke: #636363; 285 | stroke-width: 1.5px; 286 | } 287 | 288 | .link { 289 | stroke: #969696; 290 | } 291 | 292 | .node rect { 293 | fill: white; 294 | } 295 | 296 | .link path, 297 | .node rect, 298 | .node text, 299 | .join { 300 | -webkit-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 301 | -moz-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 302 | -ms-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 303 | -o-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 304 | transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 305 | } 306 | 307 | .node .element rect { 308 | fill: #bdbdbd; 309 | stroke: none; 310 | } 311 | 312 | .node .null rect { 313 | fill: none; 314 | stroke: none; 315 | } 316 | 317 | .node .null text { 318 | fill: #636363; 319 | } 320 | 321 | .node .selection rect { 322 | stroke: #e6550d; 323 | } 324 | 325 | .node .data rect { 326 | stroke: #3182bd; 327 | } 328 | 329 | .node .datum rect { 330 | fill: #d9d9d9; 331 | stroke: none; 332 | } 333 | 334 | .node .code text { 335 | font-family: monospace; 336 | } 337 | 338 | .node .key rect { 339 | fill: #a1d99b; 340 | stroke: none; 341 | } 342 | 343 | .link .to-key, 344 | .join { 345 | stroke: #a1d99b; 346 | } 347 | 348 | .join { 349 | stroke-dasharray: 2,2; 350 | } 351 | 352 | .link .to-null { 353 | stroke-dasharray: .5,3.5; 354 | stroke-linecap: round; 355 | } 356 | 357 | .link .from-data { 358 | stroke: #3182bd; 359 | } 360 | 361 | .play circle { 362 | fill: #fff; 363 | stroke: #000; 364 | stroke-width: 3px; 365 | } 366 | 367 | .play:hover path { 368 | fill: #f00; 369 | } 370 | 371 | .play.mousedown circle { 372 | fill: #f00; 373 | } 374 | 375 | .play.mousedown path { 376 | fill: #fff; 377 | } 378 | 379 | .play rect { 380 | fill: none; 381 | pointer-events: all; 382 | cursor: pointer; 383 | } 384 | 385 | code span { 386 | -webkit-transition: background 250ms linear; 387 | -moz-transition: background 250ms linear; 388 | -ms-transition: background 250ms linear; 389 | -o-transition: background 250ms linear; 390 | transition: background 250ms linear; 391 | } 392 | 393 | pre.prettyprint, code.prettyprint { 394 | background-color: #222; 395 | border-radius: 8px; 396 | font-size: 15px; 397 | } 398 | 399 | pre.prettyprint { 400 | width: 90%; 401 | margin: 0.5em; 402 | padding: 1em; 403 | white-space: pre-wrap; 404 | } 405 | 406 | #return-to-top { 407 | position: fixed; 408 | bottom: 20px; 409 | right: 20px; 410 | background: rgb(0, 0, 0); 411 | background: rgba(0, 0, 0, 0.2); 412 | width: 50px; 413 | height: 50px; 414 | display: block; 415 | text-decoration: none; 416 | -webkit-border-radius: 35px; 417 | -moz-border-radius: 35px; 418 | border-radius: 35px; 419 | display: none; 420 | -webkit-transition: all 0.3s linear; 421 | -moz-transition: all 0.3s ease; 422 | -ms-transition: all 0.3s ease; 423 | -o-transition: all 0.3s ease; 424 | transition: all 0.3s ease; 425 | } 426 | 427 | #return-to-top i { 428 | color: #fff; 429 | margin: 0; 430 | position: relative; 431 | left: 16px; 432 | top: 13px; 433 | font-size: 19px; 434 | -webkit-transition: all 0.3s ease; 435 | -moz-transition: all 0.3s ease; 436 | -ms-transition: all 0.3s ease; 437 | -o-transition: all 0.3s ease; 438 | transition: all 0.3s ease; 439 | } 440 | 441 | #return-to-top:hover { 442 | background: rgba(0, 0, 0, 0.35); 443 | } 444 | 445 | #return-to-top:hover i { 446 | color: #f0f0f0; 447 | } 448 | 449 | @media print { 450 | .pagebreak { 451 | page-break-before: always; 452 | } 453 | div { 454 | page-break-inside: avoid; 455 | } 456 | pre { 457 | page-break-inside: avoid; 458 | } 459 | } 460 | 461 | .modebar{ 462 | display: none !important; 463 | } -------------------------------------------------------------------------------- /web/style_dark.css: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Michael Bostock. All rights reserved. Do not copy. */ 2 | 3 | @import url(https://fonts.googleapis.com/css?family=PT+Serif|PT+Serif:b|PT+Serif:i|PT+Sans|PT+Sans:b); 4 | 5 | .ocks-org body { 6 | background: hsl(206deg 47% 9%); 7 | color: hsl(0deg 0% 72%); 8 | font-family: "PT Serif", serif; 9 | margin: 1em auto 4em auto; 10 | position: relative; 11 | width: 960px; 12 | padding: 1rem; 13 | } 14 | 15 | .ocks-org header, 16 | .ocks-org footer, 17 | .ocks-org aside, 18 | .ocks-org h1, 19 | .ocks-org h2, 20 | .ocks-org h3, 21 | .ocks-org h4 { 22 | font-family: "PT Sans", sans-serif; 23 | } 24 | 25 | .ocks-org h1, 26 | .ocks-org h2, 27 | .ocks-org h3, 28 | .ocks-org h4 { 29 | color: hsl(0deg 1% 71%); 30 | } 31 | 32 | .ocks-org header, 33 | .ocks-org footer { 34 | color: #636363; 35 | } 36 | 37 | h1 { 38 | font-size: 67px; 39 | font-weight: 300; 40 | letter-spacing: -2px; 41 | margin: 0.3em 0 0.1em 0; 42 | } 43 | 44 | h2 { 45 | margin-top: 2em; 46 | } 47 | 48 | h1, 49 | h2 { 50 | text-rendering: optimizeLegibility; 51 | } 52 | 53 | h2 a[name], 54 | h2 a[id] { 55 | color: hsl(0deg 0% 63% / 49%); 56 | padding-right: 0.3em; 57 | } 58 | 59 | header, 60 | footer { 61 | font-size: small; 62 | } 63 | 64 | .ocks-org header aside, 65 | .ocks-org footer aside { 66 | float: left; 67 | margin-right: 0.5em; 68 | } 69 | 70 | .ocks-org header aside:after, 71 | .ocks-org footer aside:after { 72 | padding-left: 0.5em; 73 | content: "/"; 74 | } 75 | 76 | footer { 77 | margin-top: 6em; 78 | } 79 | 80 | h1 ~ aside { 81 | font-size: small; 82 | right: 0; 83 | position: absolute; 84 | width: 180px; 85 | } 86 | 87 | .attribution { 88 | font-size: small; 89 | margin-bottom: 2em; 90 | } 91 | 92 | body > p, 93 | li > p, 94 | div > p { 95 | line-height: 1.5em; 96 | } 97 | 98 | body > p, 99 | div > p { 100 | width: 720px; 101 | } 102 | 103 | body > blockquote { 104 | width: 640px; 105 | } 106 | 107 | blockquote q { 108 | display: block; 109 | font-style: oblique; 110 | } 111 | 112 | ul { 113 | padding: 0; 114 | } 115 | 116 | li { 117 | width: 690px; 118 | margin-left: 30px; 119 | } 120 | 121 | a { 122 | color: steelblue; 123 | } 124 | 125 | a:not(:hover) { 126 | text-decoration: none; 127 | } 128 | 129 | pre, 130 | code, 131 | textarea { 132 | font-family: "Menlo", "Menlo Web", monospace; 133 | } 134 | 135 | code { 136 | line-height: 1em; 137 | } 138 | 139 | textarea { 140 | font-size: 100%; 141 | } 142 | 143 | pre { 144 | border-left: solid 2px hsl(206deg 34% 14%); 145 | padding-left: 18px; 146 | margin: 1em 0 1em 0; 147 | background: hsl(206deg 34% 14%); 148 | border-radius: 6px; 149 | padding-top: 16px; 150 | padding-bottom: 16px; 151 | } 152 | 153 | .html .value, 154 | .javascript .string, 155 | .javascript .regexp { 156 | color: #756bb1; 157 | } 158 | 159 | .html .tag, 160 | .css .tag, 161 | .javascript .keyword { 162 | color: #3182bd; 163 | } 164 | 165 | .comment { 166 | color: #636363; 167 | } 168 | 169 | .html .doctype, 170 | .javascript .number { 171 | color: #31a354; 172 | } 173 | 174 | .html .attribute, 175 | .css .attribute, 176 | .javascript .class, 177 | .javascript .special { 178 | color: #e6550d; 179 | } 180 | 181 | svg { 182 | font: 10px sans-serif; 183 | } 184 | 185 | .axis path, 186 | .axis line { 187 | fill: none; 188 | stroke: #000; 189 | shape-rendering: crispEdges; 190 | } 191 | 192 | sup, 193 | sub { 194 | line-height: 0; 195 | } 196 | 197 | q:before { 198 | content: "“"; 199 | } 200 | 201 | q:after { 202 | content: "”"; 203 | } 204 | 205 | blockquote q { 206 | line-height: 1.5em; 207 | display: inline; 208 | } 209 | 210 | blockquote q:before, 211 | blockquote q:after { 212 | content: ""; 213 | } 214 | 215 | h3, 216 | h4, 217 | p, 218 | ul { 219 | padding-left: 1.2rem; 220 | } 221 | 222 | .banner { 223 | padding: 0; 224 | } 225 | 226 | #toc { 227 | margin-top: 0; 228 | } 229 | 230 | @media only screen and (max-device-width: 1023px) { 231 | .ocks-org body { 232 | font-size: 72%; 233 | padding: 0.5rem; 234 | } 235 | 236 | body > p, 237 | div > p { 238 | width: 90vw !important; 239 | } 240 | 241 | li { 242 | width: 82vw; 243 | } 244 | 245 | h3, 246 | h4, 247 | p, 248 | ul { 249 | padding-left: .7rem; 250 | width: 90vw; 251 | } 252 | 253 | h1 { 254 | font-size: 2rem; 255 | } 256 | 257 | pre { 258 | padding-left: 0.5rem; 259 | } 260 | 261 | .banner, 262 | h1, 263 | img { 264 | max-width: calc(100vw - 2em); 265 | min-width: calc(100vw - 2em); 266 | } 267 | } 268 | 269 | 270 | 271 | 272 | 273 | /*@import url(web/style.css);*/ 274 | 275 | @font-face {font-family: "Menlo web"; 276 | src: url("OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1\\@font-face\\9f94dc20bb2a09c15241d3a880b7ad01.woff2") format("woff2"), /* chrome、firefox */ 277 | url("OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1\\@font-face\\9f94dc20bb2a09c15241d3a880b7ad01.woff") format("woff"); 278 | font-weight: normal; 279 | } 280 | 281 | @font-face {font-family: "Menlo web"; 282 | src: url("OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88\\Menlo Bold\\@font-face\\a6ffc5d72a96b65159e710ea6d258ba4.woff2") format("woff2"), /* chrome、firefox */ 283 | url("OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88\\Menlo Bold\\@font-face\\a6ffc5d72a96b65159e710ea6d258ba4.woff") format("woff"); 284 | font-weight: bold; 285 | } 286 | 287 | .join, 288 | .link, 289 | .node rect { 290 | fill: none; 291 | stroke: #636363; 292 | stroke-width: 1.5px; 293 | } 294 | 295 | .link { 296 | stroke: #969696; 297 | } 298 | 299 | .node rect { 300 | fill: white; 301 | } 302 | 303 | .link path, 304 | .node rect, 305 | .node text, 306 | .join { 307 | -webkit-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 308 | -moz-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 309 | -ms-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 310 | -o-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 311 | transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 312 | } 313 | 314 | .node .element rect { 315 | fill: #bdbdbd; 316 | stroke: none; 317 | } 318 | 319 | .node .null rect { 320 | fill: none; 321 | stroke: none; 322 | } 323 | 324 | .node .null text { 325 | fill: #636363; 326 | } 327 | 328 | .node .selection rect { 329 | stroke: #e6550d; 330 | } 331 | 332 | .node .data rect { 333 | stroke: #3182bd; 334 | } 335 | 336 | .node .datum rect { 337 | fill: #d9d9d9; 338 | stroke: none; 339 | } 340 | 341 | .node .code text { 342 | font-family: monospace; 343 | color: hsl(0deg 0% 74%) 344 | } 345 | 346 | .node .key rect { 347 | fill: #a1d99b; 348 | stroke: none; 349 | } 350 | 351 | .link .to-key, 352 | .join { 353 | stroke: #a1d99b; 354 | } 355 | 356 | .join { 357 | stroke-dasharray: 2,2; 358 | } 359 | 360 | .link .to-null { 361 | stroke-dasharray: .5,3.5; 362 | stroke-linecap: round; 363 | } 364 | 365 | .link .from-data { 366 | stroke: #3182bd; 367 | } 368 | 369 | .play circle { 370 | fill: #fff; 371 | stroke: #000; 372 | stroke-width: 3px; 373 | } 374 | 375 | .play:hover path { 376 | fill: #f00; 377 | } 378 | 379 | .play.mousedown circle { 380 | fill: #f00; 381 | } 382 | 383 | .play.mousedown path { 384 | fill: #fff; 385 | } 386 | 387 | .play rect { 388 | fill: none; 389 | pointer-events: all; 390 | cursor: pointer; 391 | } 392 | 393 | code span { 394 | -webkit-transition: background 250ms linear; 395 | -moz-transition: background 250ms linear; 396 | -ms-transition: background 250ms linear; 397 | -o-transition: background 250ms linear; 398 | transition: background 250ms linear; 399 | } 400 | 401 | pre.prettyprint, code.prettyprint { 402 | background-color: #222; 403 | border-radius: 8px; 404 | font-size: 15px; 405 | } 406 | 407 | pre.prettyprint { 408 | width: 90%; 409 | margin: 0.5em; 410 | padding: 1em; 411 | white-space: pre-wrap; 412 | } 413 | 414 | #return-to-top { 415 | position: fixed; 416 | bottom: 20px; 417 | right: 20px; 418 | background: rgb(0, 0, 0); 419 | background: rgba(0, 0, 0, 0.2); 420 | width: 50px; 421 | height: 50px; 422 | display: block; 423 | text-decoration: none; 424 | -webkit-border-radius: 35px; 425 | -moz-border-radius: 35px; 426 | border-radius: 35px; 427 | display: none; 428 | -webkit-transition: all 0.3s linear; 429 | -moz-transition: all 0.3s ease; 430 | -ms-transition: all 0.3s ease; 431 | -o-transition: all 0.3s ease; 432 | transition: all 0.3s ease; 433 | } 434 | 435 | #return-to-top i { 436 | color: #fff; 437 | margin: 0; 438 | position: relative; 439 | left: 16px; 440 | top: 13px; 441 | font-size: 19px; 442 | -webkit-transition: all 0.3s ease; 443 | -moz-transition: all 0.3s ease; 444 | -ms-transition: all 0.3s ease; 445 | -o-transition: all 0.3s ease; 446 | transition: all 0.3s ease; 447 | } 448 | 449 | #return-to-top:hover { 450 | background: rgba(0, 0, 0, 0.35); 451 | } 452 | 453 | #return-to-top:hover i { 454 | color: #f0f0f0; 455 | } 456 | 457 | @media print { 458 | .pagebreak { 459 | page-break-before: always; 460 | } 461 | div { 462 | page-break-inside: avoid; 463 | } 464 | pre { 465 | page-break-inside: avoid; 466 | } 467 | } 468 | 469 | .modebar{ 470 | display: none !important; 471 | } -------------------------------------------------------------------------------- /web/style_dark1.css: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Michael Bostock. All rights reserved. Do not copy. */ 2 | 3 | @import url(https://fonts.googleapis.com/css?family=PT+Serif|PT+Serif:b|PT+Serif:i|PT+Sans|PT+Sans:b); 4 | 5 | .ocks-org body { 6 | background: hsl(206deg 47% 9%); 7 | color: hsl(0deg 0% 72%); 8 | font-family: "PT Serif", serif; 9 | margin: 1em auto 4em auto; 10 | position: relative; 11 | width: 960px; 12 | padding: 1rem; 13 | } 14 | 15 | .ocks-org header, 16 | .ocks-org footer, 17 | .ocks-org aside, 18 | .ocks-org h1, 19 | .ocks-org h2, 20 | .ocks-org h3, 21 | .ocks-org h4 { 22 | font-family: "PT Sans", sans-serif; 23 | } 24 | 25 | .ocks-org h1, 26 | .ocks-org h2, 27 | .ocks-org h3, 28 | .ocks-org h4 { 29 | color: hsl(0deg 1% 77%); 30 | } 31 | 32 | .ocks-org header, 33 | .ocks-org footer { 34 | color: #636363; 35 | } 36 | 37 | h1 { 38 | font-size: 67px; 39 | font-weight: 300; 40 | letter-spacing: -2px; 41 | margin: 0.3em 0 0.1em 0; 42 | } 43 | 44 | h2 { 45 | margin-top: 2em; 46 | } 47 | 48 | h1, 49 | h2 { 50 | text-rendering: optimizeLegibility; 51 | } 52 | 53 | h2 a[name], 54 | h2 a[id] { 55 | color: hsl(0deg 0% 75% / 49%); 56 | padding-right: 0.3em; 57 | } 58 | 59 | header, 60 | footer { 61 | font-size: small; 62 | } 63 | 64 | .ocks-org header aside, 65 | .ocks-org footer aside { 66 | float: left; 67 | margin-right: 0.5em; 68 | } 69 | 70 | .ocks-org header aside:after, 71 | .ocks-org footer aside:after { 72 | padding-left: 0.5em; 73 | content: "/"; 74 | } 75 | 76 | footer { 77 | margin-top: 6em; 78 | } 79 | 80 | h1 ~ aside { 81 | font-size: small; 82 | right: 0; 83 | position: absolute; 84 | width: 180px; 85 | } 86 | 87 | .attribution { 88 | font-size: small; 89 | margin-bottom: 2em; 90 | } 91 | 92 | body > p, 93 | li > p, 94 | div > p { 95 | line-height: 1.5em; 96 | } 97 | 98 | body > p, 99 | div > p { 100 | width: 720px; 101 | } 102 | 103 | body > blockquote { 104 | width: 640px; 105 | } 106 | 107 | blockquote q { 108 | display: block; 109 | font-style: oblique; 110 | } 111 | 112 | ul { 113 | padding: 0; 114 | } 115 | 116 | li { 117 | width: 690px; 118 | margin-left: 30px; 119 | } 120 | 121 | a { 122 | color: steelblue; 123 | } 124 | 125 | a:not(:hover) { 126 | text-decoration: none; 127 | } 128 | 129 | pre, 130 | code, 131 | textarea { 132 | font-family: "Menlo", "Menlo Web", monospace; 133 | } 134 | 135 | code { 136 | line-height: 1em; 137 | color: hsl(0deg 0% 96% / 65%); 138 | } 139 | 140 | textarea { 141 | font-size: 100%; 142 | } 143 | 144 | pre { 145 | border-left: solid 2px hsl(206deg 34% 14%); 146 | padding-left: 18px; 147 | margin: 1em 0 1em 0; 148 | background: hsl(206deg 34% 14%); 149 | border-radius: 6px; 150 | padding-top: 16px; 151 | padding-bottom: 16px; 152 | } 153 | 154 | .html .value, 155 | .javascript .string, 156 | .javascript .regexp { 157 | color: #756bb1; 158 | } 159 | 160 | .html .tag, 161 | .css .tag, 162 | .javascript .keyword { 163 | color: #3182bd; 164 | } 165 | 166 | .comment { 167 | color: #636363; 168 | } 169 | 170 | .html .doctype, 171 | .javascript .number { 172 | color: #31a354; 173 | } 174 | 175 | .html .attribute, 176 | .css .attribute, 177 | .javascript .class, 178 | .javascript .special { 179 | color: #e6550d; 180 | } 181 | 182 | svg { 183 | font: 10px sans-serif; 184 | } 185 | 186 | .axis path, 187 | .axis line { 188 | fill: none; 189 | stroke: #000; 190 | shape-rendering: crispEdges; 191 | } 192 | 193 | sup, 194 | sub { 195 | line-height: 0; 196 | } 197 | 198 | q:before { 199 | content: "“"; 200 | } 201 | 202 | q:after { 203 | content: "”"; 204 | } 205 | 206 | blockquote q { 207 | line-height: 1.5em; 208 | display: inline; 209 | } 210 | 211 | blockquote q:before, 212 | blockquote q:after { 213 | content: ""; 214 | } 215 | 216 | h3, 217 | h4, 218 | p, 219 | ul { 220 | padding-left: 1.2rem; 221 | } 222 | 223 | .banner { 224 | padding: 0; 225 | } 226 | 227 | #toc { 228 | margin-top: 0; 229 | } 230 | 231 | @media only screen and (max-device-width: 1023px) { 232 | .ocks-org body { 233 | font-size: 72%; 234 | padding: 0.5rem; 235 | } 236 | 237 | body > p, 238 | div > p { 239 | width: 90vw !important; 240 | } 241 | 242 | li { 243 | width: 82vw; 244 | } 245 | 246 | h3, 247 | h4, 248 | p, 249 | ul { 250 | padding-left: .7rem; 251 | width: 90vw; 252 | } 253 | 254 | h1 { 255 | font-size: 2rem; 256 | } 257 | 258 | pre { 259 | padding-left: 0.5rem; 260 | } 261 | 262 | .banner, 263 | h1, 264 | img { 265 | max-width: calc(100vw - 2em); 266 | min-width: calc(100vw - 2em); 267 | } 268 | } 269 | 270 | 271 | 272 | 273 | 274 | /*@import url(web/style.css);*/ 275 | 276 | @font-face {font-family: "Menlo web"; 277 | src: url("OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1\\@font-face\\9f94dc20bb2a09c15241d3a880b7ad01.woff2") format("woff2"), /* chrome、firefox */ 278 | url("OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1\\@font-face\\9f94dc20bb2a09c15241d3a880b7ad01.woff") format("woff"); 279 | font-weight: normal; 280 | } 281 | 282 | @font-face {font-family: "Menlo web"; 283 | src: url("OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88\\Menlo Bold\\@font-face\\a6ffc5d72a96b65159e710ea6d258ba4.woff2") format("woff2"), /* chrome、firefox */ 284 | url("OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88\\Menlo Bold\\@font-face\\a6ffc5d72a96b65159e710ea6d258ba4.woff") format("woff"); 285 | font-weight: bold; 286 | } 287 | 288 | .join, 289 | .link, 290 | .node rect { 291 | fill: none; 292 | stroke: #636363; 293 | stroke-width: 1.5px; 294 | } 295 | 296 | .link { 297 | stroke: #969696; 298 | } 299 | 300 | .node rect { 301 | fill: white; 302 | } 303 | 304 | .link path, 305 | .node rect, 306 | .node text, 307 | .join { 308 | -webkit-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 309 | -moz-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 310 | -ms-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 311 | -o-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 312 | transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 313 | } 314 | 315 | .node .element rect { 316 | fill: #bdbdbd; 317 | stroke: none; 318 | } 319 | 320 | .node .null rect { 321 | fill: none; 322 | stroke: none; 323 | } 324 | 325 | .node .null text { 326 | fill: #636363; 327 | } 328 | 329 | .node .selection rect { 330 | stroke: #e6550d; 331 | } 332 | 333 | .node .data rect { 334 | stroke: #3182bd; 335 | } 336 | 337 | .node .datum rect { 338 | fill: #d9d9d9; 339 | stroke: none; 340 | } 341 | 342 | .node .code text { 343 | font-family: monospace; 344 | color: hsl(0deg 0% 74%) 345 | } 346 | 347 | .node .key rect { 348 | fill: #a1d99b; 349 | stroke: none; 350 | } 351 | 352 | .link .to-key, 353 | .join { 354 | stroke: #a1d99b; 355 | } 356 | 357 | .join { 358 | stroke-dasharray: 2,2; 359 | } 360 | 361 | .link .to-null { 362 | stroke-dasharray: .5,3.5; 363 | stroke-linecap: round; 364 | } 365 | 366 | .link .from-data { 367 | stroke: #3182bd; 368 | } 369 | 370 | .play circle { 371 | fill: #fff; 372 | stroke: #000; 373 | stroke-width: 3px; 374 | } 375 | 376 | .play:hover path { 377 | fill: #f00; 378 | } 379 | 380 | .play.mousedown circle { 381 | fill: #f00; 382 | } 383 | 384 | .play.mousedown path { 385 | fill: #fff; 386 | } 387 | 388 | .play rect { 389 | fill: none; 390 | pointer-events: all; 391 | cursor: pointer; 392 | } 393 | 394 | code span { 395 | -webkit-transition: background 250ms linear; 396 | -moz-transition: background 250ms linear; 397 | -ms-transition: background 250ms linear; 398 | -o-transition: background 250ms linear; 399 | transition: background 250ms linear; 400 | } 401 | 402 | pre.prettyprint, code.prettyprint { 403 | background-color: #222; 404 | border-radius: 8px; 405 | font-size: 15px; 406 | } 407 | 408 | pre.prettyprint { 409 | width: 90%; 410 | margin: 0.5em; 411 | padding: 1em; 412 | white-space: pre-wrap; 413 | } 414 | 415 | #return-to-top { 416 | position: fixed; 417 | bottom: 20px; 418 | right: 20px; 419 | background: rgb(0, 0, 0); 420 | background: rgba(0, 0, 0, 0.2); 421 | width: 50px; 422 | height: 50px; 423 | display: block; 424 | text-decoration: none; 425 | -webkit-border-radius: 35px; 426 | -moz-border-radius: 35px; 427 | border-radius: 35px; 428 | display: none; 429 | -webkit-transition: all 0.3s linear; 430 | -moz-transition: all 0.3s ease; 431 | -ms-transition: all 0.3s ease; 432 | -o-transition: all 0.3s ease; 433 | transition: all 0.3s ease; 434 | } 435 | 436 | #return-to-top i { 437 | color: #fff; 438 | margin: 0; 439 | position: relative; 440 | left: 16px; 441 | top: 13px; 442 | font-size: 19px; 443 | -webkit-transition: all 0.3s ease; 444 | -moz-transition: all 0.3s ease; 445 | -ms-transition: all 0.3s ease; 446 | -o-transition: all 0.3s ease; 447 | transition: all 0.3s ease; 448 | } 449 | 450 | #return-to-top:hover { 451 | background: rgba(0, 0, 0, 0.35); 452 | } 453 | 454 | #return-to-top:hover i { 455 | color: #f0f0f0; 456 | } 457 | 458 | @media print { 459 | .pagebreak { 460 | page-break-before: always; 461 | } 462 | div { 463 | page-break-inside: avoid; 464 | } 465 | pre { 466 | page-break-inside: avoid; 467 | } 468 | } 469 | 470 | .modebar{ 471 | display: none !important; 472 | } -------------------------------------------------------------------------------- /web/style_dark2.css: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Michael Bostock. All rights reserved. Do not copy. */ 2 | 3 | @import url(https://fonts.googleapis.com/css?family=PT+Serif|PT+Serif:b|PT+Serif:i|PT+Sans|PT+Sans:b); 4 | 5 | .ocks-org body { 6 | background: hsl(206deg 47% 9%); 7 | color: hsl(0deg 0% 72%); 8 | font-family: "PT Serif", serif; 9 | margin: 1em auto 4em auto; 10 | position: relative; 11 | width: 960px; 12 | padding: 1rem; 13 | } 14 | 15 | .ocks-org header, 16 | .ocks-org footer, 17 | .ocks-org aside, 18 | .ocks-org h1, 19 | .ocks-org h2, 20 | .ocks-org h3, 21 | .ocks-org h4 { 22 | font-family: "PT Sans", sans-serif; 23 | } 24 | 25 | .ocks-org h1, 26 | .ocks-org h2, 27 | .ocks-org h3, 28 | .ocks-org h4 { 29 | color: hsl(0deg 1% 71%); 30 | } 31 | 32 | .ocks-org header, 33 | .ocks-org footer { 34 | color: #999999; 35 | } 36 | 37 | h1 { 38 | font-size: 64px; 39 | font-weight: 300; 40 | letter-spacing: -2px; 41 | margin: 0.3em 0 0.1em 0; 42 | } 43 | 44 | h2 { 45 | margin-top: 2em; 46 | } 47 | 48 | h1, 49 | h2 { 50 | text-rendering: optimizeLegibility; 51 | } 52 | 53 | h2 a[name], 54 | h2 a[id] { 55 | color: #5f5c5c; 56 | padding-right: 0.3em; 57 | } 58 | 59 | header, 60 | footer { 61 | font-size: small; 62 | } 63 | 64 | .ocks-org header aside, 65 | .ocks-org footer aside { 66 | float: left; 67 | margin-right: 0.5em; 68 | } 69 | 70 | .ocks-org header aside:after, 71 | .ocks-org footer aside:after { 72 | padding-left: 0.5em; 73 | content: "/"; 74 | } 75 | 76 | footer { 77 | margin-top: 6em; 78 | } 79 | 80 | h1 ~ aside { 81 | font-size: small; 82 | right: 0; 83 | position: absolute; 84 | width: 180px; 85 | } 86 | 87 | .attribution { 88 | font-size: small; 89 | margin-bottom: 2em; 90 | } 91 | 92 | body > p, 93 | li > p, 94 | div > p { 95 | line-height: 1.5em; 96 | } 97 | 98 | body > p, 99 | div > p { 100 | width: 720px; 101 | } 102 | 103 | body > blockquote { 104 | width: 640px; 105 | } 106 | 107 | blockquote q { 108 | display: block; 109 | font-style: oblique; 110 | } 111 | 112 | ul { 113 | padding: 0; 114 | } 115 | 116 | li { 117 | width: 690px; 118 | margin-left: 30px; 119 | } 120 | 121 | a { 122 | color: hsl(187deg 100% 33%); 123 | } 124 | 125 | a:not(:hover) { 126 | text-decoration: none; 127 | } 128 | 129 | pre, 130 | code, 131 | textarea { 132 | font-family: "Menlo", "Menlo Web", monospace; 133 | } 134 | 135 | code { 136 | line-height: 1em; 137 | color: hsl(0deg 0% 74%); 138 | } 139 | 140 | textarea { 141 | font-size: 100%; 142 | } 143 | 144 | pre { 145 | border-left: solid 2px #424242; 146 | padding-left: 18px; 147 | margin: 2em 0 2em 0; 148 | } 149 | 150 | .html .value, 151 | .javascript .string, 152 | .javascript .regexp { 153 | color: #756bb1; 154 | } 155 | 156 | .html .tag, 157 | .css .tag, 158 | .javascript .keyword { 159 | color: #3182bd; 160 | } 161 | 162 | .comment { 163 | color: #636363; 164 | } 165 | 166 | .html .doctype, 167 | .javascript .number { 168 | color: #31a354; 169 | } 170 | 171 | .html .attribute, 172 | .css .attribute, 173 | .javascript .class, 174 | .javascript .special { 175 | color: #e6550d; 176 | } 177 | 178 | svg { 179 | font: 10px sans-serif; 180 | } 181 | 182 | .axis path, 183 | .axis line { 184 | fill: none; 185 | stroke: #000; 186 | shape-rendering: crispEdges; 187 | } 188 | 189 | sup, 190 | sub { 191 | line-height: 0; 192 | } 193 | 194 | q:before { 195 | content: "“"; 196 | } 197 | 198 | q:after { 199 | content: "”"; 200 | } 201 | 202 | blockquote q { 203 | line-height: 1.5em; 204 | display: inline; 205 | } 206 | 207 | blockquote q:before, 208 | blockquote q:after { 209 | content: ""; 210 | } 211 | 212 | h3, 213 | h4, 214 | p, 215 | ul { 216 | padding-left: 1.2rem; 217 | } 218 | 219 | .banner { 220 | padding: 0; 221 | } 222 | 223 | #toc { 224 | margin-top: 0; 225 | } 226 | 227 | @media only screen and (max-device-width: 1023px) { 228 | .ocks-org body { 229 | font-size: 72%; 230 | padding: 0.5rem; 231 | } 232 | 233 | body > p, 234 | div > p { 235 | width: 90vw !important; 236 | } 237 | 238 | li { 239 | width: 82vw; 240 | } 241 | 242 | h3, 243 | h4, 244 | p, 245 | ul { 246 | padding-left: .7rem; 247 | width: 90vw; 248 | } 249 | 250 | h1 { 251 | font-size: 2rem; 252 | } 253 | 254 | pre { 255 | padding-left: 0.5rem; 256 | } 257 | 258 | .banner, 259 | h1, 260 | img { 261 | max-width: calc(100vw - 2em); 262 | min-width: calc(100vw - 2em); 263 | } 264 | } 265 | 266 | 267 | 268 | 269 | 270 | /*@import url(web/style.css);*/ 271 | 272 | @font-face {font-family: "Menlo web"; 273 | src: url("OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1\\@font-face\\9f94dc20bb2a09c15241d3a880b7ad01.woff2") format("woff2"), /* chrome、firefox */ 274 | url("OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1\\@font-face\\9f94dc20bb2a09c15241d3a880b7ad01.woff") format("woff"); 275 | font-weight: normal; 276 | } 277 | 278 | @font-face {font-family: "Menlo web"; 279 | src: url("OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88\\Menlo Bold\\@font-face\\a6ffc5d72a96b65159e710ea6d258ba4.woff2") format("woff2"), /* chrome、firefox */ 280 | url("OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88\\Menlo Bold\\@font-face\\a6ffc5d72a96b65159e710ea6d258ba4.woff") format("woff"); 281 | font-weight: bold; 282 | } 283 | 284 | .join, 285 | .link, 286 | .node rect { 287 | fill: none; 288 | stroke: #636363; 289 | stroke-width: 1.5px; 290 | } 291 | 292 | .link { 293 | stroke: #969696; 294 | } 295 | 296 | .node rect { 297 | fill: white; 298 | } 299 | 300 | .link path, 301 | .node rect, 302 | .node text, 303 | .join { 304 | -webkit-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 305 | -moz-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 306 | -ms-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 307 | -o-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 308 | transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 309 | } 310 | 311 | .node .element rect { 312 | fill: #bdbdbd; 313 | stroke: none; 314 | } 315 | 316 | .node .null rect { 317 | fill: none; 318 | stroke: none; 319 | } 320 | 321 | .node .null text { 322 | fill: #636363; 323 | } 324 | 325 | .node .selection rect { 326 | stroke: #e6550d; 327 | } 328 | 329 | .node .data rect { 330 | stroke: #3182bd; 331 | } 332 | 333 | .node .datum rect { 334 | fill: #d9d9d9; 335 | stroke: none; 336 | } 337 | 338 | .node .code text { 339 | font-family: monospace; 340 | color: hsl(0deg 0% 74%) 341 | } 342 | 343 | .node .key rect { 344 | fill: #a1d99b; 345 | stroke: none; 346 | } 347 | 348 | .link .to-key, 349 | .join { 350 | stroke: #a1d99b; 351 | } 352 | 353 | .join { 354 | stroke-dasharray: 2,2; 355 | } 356 | 357 | .link .to-null { 358 | stroke-dasharray: .5,3.5; 359 | stroke-linecap: round; 360 | } 361 | 362 | .link .from-data { 363 | stroke: #3182bd; 364 | } 365 | 366 | .play circle { 367 | fill: #fff; 368 | stroke: #000; 369 | stroke-width: 3px; 370 | } 371 | 372 | .play:hover path { 373 | fill: #f00; 374 | } 375 | 376 | .play.mousedown circle { 377 | fill: #f00; 378 | } 379 | 380 | .play.mousedown path { 381 | fill: #fff; 382 | } 383 | 384 | .play rect { 385 | fill: none; 386 | pointer-events: all; 387 | cursor: pointer; 388 | } 389 | 390 | code span { 391 | -webkit-transition: background 250ms linear; 392 | -moz-transition: background 250ms linear; 393 | -ms-transition: background 250ms linear; 394 | -o-transition: background 250ms linear; 395 | transition: background 250ms linear; 396 | } 397 | 398 | pre.prettyprint, code.prettyprint { 399 | background-color: #222; 400 | border-radius: 8px; 401 | font-size: 15px; 402 | } 403 | 404 | pre.prettyprint { 405 | width: 90%; 406 | margin: 0.5em; 407 | padding: 1em; 408 | white-space: pre-wrap; 409 | } 410 | 411 | #return-to-top { 412 | position: fixed; 413 | bottom: 20px; 414 | right: 20px; 415 | background: rgb(0, 0, 0); 416 | background: rgba(0, 0, 0, 0.2); 417 | width: 50px; 418 | height: 50px; 419 | display: block; 420 | text-decoration: none; 421 | -webkit-border-radius: 35px; 422 | -moz-border-radius: 35px; 423 | border-radius: 35px; 424 | display: none; 425 | -webkit-transition: all 0.3s linear; 426 | -moz-transition: all 0.3s ease; 427 | -ms-transition: all 0.3s ease; 428 | -o-transition: all 0.3s ease; 429 | transition: all 0.3s ease; 430 | } 431 | 432 | #return-to-top i { 433 | color: #fff; 434 | margin: 0; 435 | position: relative; 436 | left: 16px; 437 | top: 13px; 438 | font-size: 19px; 439 | -webkit-transition: all 0.3s ease; 440 | -moz-transition: all 0.3s ease; 441 | -ms-transition: all 0.3s ease; 442 | -o-transition: all 0.3s ease; 443 | transition: all 0.3s ease; 444 | } 445 | 446 | #return-to-top:hover { 447 | background: rgba(0, 0, 0, 0.35); 448 | } 449 | 450 | #return-to-top:hover i { 451 | color: #f0f0f0; 452 | } 453 | 454 | @media print { 455 | .pagebreak { 456 | page-break-before: always; 457 | } 458 | div { 459 | page-break-inside: avoid; 460 | } 461 | pre { 462 | page-break-inside: avoid; 463 | } 464 | } 465 | 466 | .modebar{ 467 | display: none !important; 468 | } -------------------------------------------------------------------------------- /web/style_dark3.css: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Michael Bostock. All rights reserved. Do not copy. */ 2 | 3 | @import url(https://fonts.googleapis.com/css?family=PT+Serif|PT+Serif:b|PT+Serif:i|PT+Sans|PT+Sans:b); 4 | 5 | .ocks-org body { 6 | background: hsl(206deg 47% 9%); 7 | color: hsl(249deg 11% 76%); 8 | font-family: "PT Serif", serif; 9 | margin: 1em auto 4em auto; 10 | position: relative; 11 | width: 960px; 12 | padding: 1rem; 13 | } 14 | 15 | .ocks-org header, 16 | .ocks-org footer, 17 | .ocks-org aside, 18 | .ocks-org h1, 19 | .ocks-org h2, 20 | .ocks-org h3, 21 | .ocks-org h4 { 22 | font-family: "PT Sans", sans-serif; 23 | } 24 | 25 | .ocks-org h1, 26 | .ocks-org h2, 27 | .ocks-org h3, 28 | .ocks-org h4 { 29 | color: hsl(249deg 11% 75%); 30 | } 31 | 32 | .ocks-org header, 33 | .ocks-org footer { 34 | color: #999999; 35 | } 36 | 37 | h1 { 38 | font-size: 64px; 39 | font-weight: 300; 40 | letter-spacing: -2px; 41 | margin: 0.3em 0 0.1em 0; 42 | } 43 | 44 | h2 { 45 | margin-top: 2em; 46 | } 47 | 48 | h1, 49 | h2 { 50 | text-rendering: optimizeLegibility; 51 | } 52 | 53 | h2 a[name], 54 | h2 a[id] { 55 | color: hsl(249deg 3% 31%); 56 | padding-right: 0.3em; 57 | } 58 | 59 | header, 60 | footer { 61 | font-size: small; 62 | } 63 | 64 | .ocks-org header aside, 65 | .ocks-org footer aside { 66 | float: left; 67 | margin-right: 0.5em; 68 | } 69 | 70 | .ocks-org header aside:after, 71 | .ocks-org footer aside:after { 72 | padding-left: 0.5em; 73 | content: "/"; 74 | } 75 | 76 | footer { 77 | margin-top: 6em; 78 | } 79 | 80 | h1 ~ aside { 81 | font-size: small; 82 | right: 0; 83 | position: absolute; 84 | width: 180px; 85 | } 86 | 87 | .attribution { 88 | font-size: small; 89 | margin-bottom: 2em; 90 | } 91 | 92 | body > p, 93 | li > p, 94 | div > p { 95 | line-height: 1.5em; 96 | } 97 | 98 | body > p, 99 | div > p { 100 | width: 720px; 101 | } 102 | 103 | body > blockquote { 104 | width: 640px; 105 | } 106 | 107 | blockquote q { 108 | display: block; 109 | font-style: oblique; 110 | } 111 | 112 | ul { 113 | padding: 0; 114 | } 115 | 116 | li { 117 | width: 690px; 118 | margin-left: 30px; 119 | } 120 | 121 | a { 122 | color: hsl(187deg 100% 33%); 123 | } 124 | 125 | a:not(:hover) { 126 | text-decoration: none; 127 | } 128 | 129 | pre, 130 | code, 131 | textarea { 132 | font-family: "Menlo", "Menlo Web", monospace; 133 | } 134 | 135 | code { 136 | line-height: 1em; 137 | color: hsl(249deg 11% 78%); 138 | } 139 | 140 | textarea { 141 | font-size: 100%; 142 | } 143 | 144 | pre { 145 | border-left: solid 2px hsl(0deg 0% 26%); 146 | padding-left: 18px; 147 | margin: 2em 0 2em 0; 148 | } 149 | 150 | .html .value, 151 | .javascript .string, 152 | .javascript .regexp { 153 | color: #756bb1; 154 | } 155 | 156 | .html .tag, 157 | .css .tag, 158 | .javascript .keyword { 159 | color: #3182bd; 160 | } 161 | 162 | .comment { 163 | color: #636363; 164 | } 165 | 166 | .html .doctype, 167 | .javascript .number { 168 | color: #31a354; 169 | } 170 | 171 | .html .attribute, 172 | .css .attribute, 173 | .javascript .class, 174 | .javascript .special { 175 | color: #e6550d; 176 | } 177 | 178 | svg { 179 | font: 10px sans-serif; 180 | } 181 | 182 | .axis path, 183 | .axis line { 184 | fill: none; 185 | stroke: #000; 186 | shape-rendering: crispEdges; 187 | } 188 | 189 | sup, 190 | sub { 191 | line-height: 0; 192 | } 193 | 194 | q:before { 195 | content: "“"; 196 | } 197 | 198 | q:after { 199 | content: "”"; 200 | } 201 | 202 | blockquote q { 203 | line-height: 1.5em; 204 | display: inline; 205 | } 206 | 207 | blockquote q:before, 208 | blockquote q:after { 209 | content: ""; 210 | } 211 | 212 | h3, 213 | h4, 214 | p, 215 | ul { 216 | padding-left: 1.2rem; 217 | } 218 | 219 | .banner { 220 | padding: 0; 221 | } 222 | 223 | #toc { 224 | margin-top: 0; 225 | } 226 | 227 | @media only screen and (max-device-width: 1023px) { 228 | .ocks-org body { 229 | font-size: 72%; 230 | padding: 0.5rem; 231 | } 232 | 233 | body > p, 234 | div > p { 235 | width: 90vw !important; 236 | } 237 | 238 | li { 239 | width: 82vw; 240 | } 241 | 242 | h3, 243 | h4, 244 | p, 245 | ul { 246 | padding-left: .7rem; 247 | width: 90vw; 248 | } 249 | 250 | h1 { 251 | font-size: 2rem; 252 | } 253 | 254 | pre { 255 | padding-left: 0.5rem; 256 | } 257 | 258 | .banner, 259 | h1, 260 | img { 261 | max-width: calc(100vw - 2em); 262 | min-width: calc(100vw - 2em); 263 | } 264 | } 265 | 266 | 267 | 268 | 269 | 270 | /*@import url(web/style.css);*/ 271 | 272 | @font-face {font-family: "Menlo web"; 273 | src: url("OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1\\@font-face\\9f94dc20bb2a09c15241d3a880b7ad01.woff2") format("woff2"), /* chrome、firefox */ 274 | url("OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1\\@font-face\\9f94dc20bb2a09c15241d3a880b7ad01.woff") format("woff"); 275 | font-weight: normal; 276 | } 277 | 278 | @font-face {font-family: "Menlo web"; 279 | src: url("OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88\\Menlo Bold\\@font-face\\a6ffc5d72a96b65159e710ea6d258ba4.woff2") format("woff2"), /* chrome、firefox */ 280 | url("OnlineWebFonts_COM_d6ba633f6ea4cafe1a39ab736fe55e88\\Menlo Bold\\@font-face\\a6ffc5d72a96b65159e710ea6d258ba4.woff") format("woff"); 281 | font-weight: bold; 282 | } 283 | 284 | .join, 285 | .link, 286 | .node rect { 287 | fill: none; 288 | stroke: #636363; 289 | stroke-width: 1.5px; 290 | } 291 | 292 | .link { 293 | stroke: #969696; 294 | } 295 | 296 | .node rect { 297 | fill: white; 298 | } 299 | 300 | .link path, 301 | .node rect, 302 | .node text, 303 | .join { 304 | -webkit-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 305 | -moz-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 306 | -ms-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 307 | -o-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 308 | transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; 309 | } 310 | 311 | .node .element rect { 312 | fill: #bdbdbd; 313 | stroke: none; 314 | } 315 | 316 | .node .null rect { 317 | fill: none; 318 | stroke: none; 319 | } 320 | 321 | .node .null text { 322 | fill: #636363; 323 | } 324 | 325 | .node .selection rect { 326 | stroke: #e6550d; 327 | } 328 | 329 | .node .data rect { 330 | stroke: #3182bd; 331 | } 332 | 333 | .node .datum rect { 334 | fill: #d9d9d9; 335 | stroke: none; 336 | } 337 | 338 | .node .code text { 339 | font-family: monospace; 340 | color: hsl(0deg 0% 74%) 341 | } 342 | 343 | .node .key rect { 344 | fill: #a1d99b; 345 | stroke: none; 346 | } 347 | 348 | .link .to-key, 349 | .join { 350 | stroke: #a1d99b; 351 | } 352 | 353 | .join { 354 | stroke-dasharray: 2,2; 355 | } 356 | 357 | .link .to-null { 358 | stroke-dasharray: .5,3.5; 359 | stroke-linecap: round; 360 | } 361 | 362 | .link .from-data { 363 | stroke: #3182bd; 364 | } 365 | 366 | .play circle { 367 | fill: #fff; 368 | stroke: #000; 369 | stroke-width: 3px; 370 | } 371 | 372 | .play:hover path { 373 | fill: #f00; 374 | } 375 | 376 | .play.mousedown circle { 377 | fill: #f00; 378 | } 379 | 380 | .play.mousedown path { 381 | fill: #fff; 382 | } 383 | 384 | .play rect { 385 | fill: none; 386 | pointer-events: all; 387 | cursor: pointer; 388 | } 389 | 390 | code span { 391 | -webkit-transition: background 250ms linear; 392 | -moz-transition: background 250ms linear; 393 | -ms-transition: background 250ms linear; 394 | -o-transition: background 250ms linear; 395 | transition: background 250ms linear; 396 | } 397 | 398 | pre.prettyprint, code.prettyprint { 399 | background-color: #222; 400 | border-radius: 8px; 401 | font-size: 15px; 402 | } 403 | 404 | pre.prettyprint { 405 | width: 90%; 406 | margin: 0.5em; 407 | padding: 1em; 408 | white-space: pre-wrap; 409 | } 410 | 411 | #return-to-top { 412 | position: fixed; 413 | bottom: 20px; 414 | right: 20px; 415 | background: rgb(0, 0, 0); 416 | background: rgba(0, 0, 0, 0.2); 417 | width: 50px; 418 | height: 50px; 419 | display: block; 420 | text-decoration: none; 421 | -webkit-border-radius: 35px; 422 | -moz-border-radius: 35px; 423 | border-radius: 35px; 424 | display: none; 425 | -webkit-transition: all 0.3s linear; 426 | -moz-transition: all 0.3s ease; 427 | -ms-transition: all 0.3s ease; 428 | -o-transition: all 0.3s ease; 429 | transition: all 0.3s ease; 430 | } 431 | 432 | #return-to-top i { 433 | color: #fff; 434 | margin: 0; 435 | position: relative; 436 | left: 16px; 437 | top: 13px; 438 | font-size: 19px; 439 | -webkit-transition: all 0.3s ease; 440 | -moz-transition: all 0.3s ease; 441 | -ms-transition: all 0.3s ease; 442 | -o-transition: all 0.3s ease; 443 | transition: all 0.3s ease; 444 | } 445 | 446 | #return-to-top:hover { 447 | background: rgba(0, 0, 0, 0.35); 448 | } 449 | 450 | #return-to-top:hover i { 451 | color: #f0f0f0; 452 | } 453 | 454 | @media print { 455 | .pagebreak { 456 | page-break-before: always; 457 | } 458 | div { 459 | page-break-inside: avoid; 460 | } 461 | pre { 462 | page-break-inside: avoid; 463 | } 464 | } 465 | 466 | .modebar{ 467 | display: none !important; 468 | } -------------------------------------------------------------------------------- /web/template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Comprehensive Python Cheatsheet 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 |
59 | 60 | 61 |
62 | 63 |
64 | 65 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /web/twitter_card_large.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/twitter_card_large.jpeg -------------------------------------------------------------------------------- /web/twitter_card_large_bckp.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/twitter_card_large_bckp.jpeg -------------------------------------------------------------------------------- /web/update_plots.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Usage: ./update_plots.py 4 | # Updates plots from the Plotly section so they show the latest data. 5 | 6 | from pathlib import Path 7 | import datetime 8 | import pandas as pd 9 | from plotly.express import line 10 | import plotly.graph_objects as go 11 | import re 12 | 13 | 14 | def main(): 15 | print('Updating covid deaths...') 16 | update_covid_deaths() 17 | print('Updating covid cases...') 18 | update_confirmed_cases() 19 | 20 | 21 | def update_covid_deaths(): 22 | covid = pd.read_csv('https://covid.ourworldindata.org/data/owid-covid-data.csv', 23 | usecols=['iso_code', 'date', 'total_deaths', 'population']) 24 | continents = pd.read_csv('https://gist.githubusercontent.com/stevewithington/20a69c0b6d2ff' 25 | '846ea5d35e5fc47f26c/raw/country-and-continent-codes-list-csv.csv', 26 | usecols=['Three_Letter_Country_Code', 'Continent_Name']) 27 | df = pd.merge(covid, continents, left_on='iso_code', right_on='Three_Letter_Country_Code') 28 | df = df.groupby(['Continent_Name', 'date']).sum().reset_index() 29 | df['Total Deaths per Million'] = round(df.total_deaths * 1e6 / df.population) 30 | today = str(datetime.date.today()) 31 | df = df[('2020-02-22' < df.date) & (df.date < today)] 32 | df = df.rename({'date': 'Date', 'Continent_Name': 'Continent'}, axis='columns') 33 | gb = df.groupby('Continent') 34 | df['Max Total Deaths'] = gb[['Total Deaths per Million']].transform('max') 35 | df = df.sort_values(['Max Total Deaths', 'Date'], ascending=[False, True]) 36 | f = line(df, x='Date', y='Total Deaths per Million', color='Continent') 37 | f.update_layout(margin=dict(t=24, b=0), paper_bgcolor='rgba(0, 0, 0, 0)') 38 | update_file('covid_deaths.js', f) 39 | f.layout.paper_bgcolor = 'rgb(255, 255, 255)' 40 | write_to_png_file('covid_deaths.png', f, width=960, height=340) 41 | 42 | 43 | def update_confirmed_cases(): 44 | def main(): 45 | df = wrangle_data(*scrape_data()) 46 | f = get_figure(df) 47 | update_file('covid_cases.js', f) 48 | f.layout.paper_bgcolor = 'rgb(255, 255, 255)' 49 | write_to_png_file('covid_cases.png', f, width=960, height=315) 50 | 51 | def scrape_data(): 52 | def scrape_covid(): 53 | url = 'https://covid.ourworldindata.org/data/owid-covid-data.csv' 54 | df = pd.read_csv(url, usecols=['location', 'date', 'total_cases']) 55 | return df[df.location == 'World'].set_index('date').total_cases 56 | def scrape_yahoo(slug): 57 | url = f'https://query1.finance.yahoo.com/v7/finance/download/{slug}' + \ 58 | '?period1=1579651200&period2=9999999999&interval=1d&events=history' 59 | df = pd.read_csv(url, usecols=['Date', 'Close']) 60 | return df.set_index('Date').Close 61 | out = [scrape_covid(), scrape_yahoo('BTC-USD'), scrape_yahoo('GC=F'), 62 | scrape_yahoo('^DJI')] 63 | return map(pd.Series.rename, out, ['Total Cases', 'Bitcoin', 'Gold', 'Dow Jones']) 64 | 65 | def wrangle_data(covid, bitcoin, gold, dow): 66 | df = pd.concat([dow, gold, bitcoin], axis=1) # Joins columns on dates. 67 | df = df.sort_index().interpolate() # Sorts by date and interpolates NaN-s. 68 | yesterday = str(datetime.date.today() - datetime.timedelta(1)) 69 | df = df.loc['2020-02-23':yesterday] # Discards rows before '2020-02-23'. 70 | df = round((df / df.iloc[0]) * 100, 2) # Calculates percentages relative to day 1 71 | df = df.join(covid) # Adds column with covid cases. 72 | return df.sort_values(df.index[-1], axis=1) # Sorts columns by last day's value. 73 | 74 | def get_figure(df): 75 | figure = go.Figure() 76 | for col_name in reversed(df.columns): 77 | yaxis = 'y1' if col_name == 'Total Cases' else 'y2' 78 | colors = {'Total Cases': '#EF553B', 'Bitcoin': '#636efa', 'Gold': '#FFA15A', 79 | 'Dow Jones': '#00cc96'} 80 | trace = go.Scatter(x=df.index, y=df[col_name], name=col_name, yaxis=yaxis, 81 | line=dict(color=colors[col_name])) 82 | figure.add_trace(trace) 83 | figure.update_layout( 84 | yaxis1=dict(title='Total Cases', rangemode='tozero'), 85 | yaxis2=dict(title='%', rangemode='tozero', overlaying='y', side='right'), 86 | legend=dict(x=1.1), 87 | margin=dict(t=24, b=0), 88 | paper_bgcolor='rgba(0, 0, 0, 0)' 89 | ) 90 | return figure 91 | 92 | main() 93 | 94 | 95 | ### 96 | ## UTIL 97 | # 98 | 99 | def update_file(filename, figure): 100 | lines = read_file(filename) 101 | f_json = figure.to_json(pretty=True).replace('\n', '\n ') 102 | out = lines[:6] + [f' {f_json}\n', ' )\n', '};\n'] 103 | write_to_file(filename, out) 104 | 105 | 106 | def read_file(filename): 107 | p = Path(__file__).resolve().parent / filename 108 | with open(p, encoding='utf-8') as file: 109 | return file.readlines() 110 | 111 | 112 | def write_to_file(filename, lines): 113 | p = Path(__file__).resolve().parent / filename 114 | with open(p, 'w', encoding='utf-8') as file: 115 | file.writelines(lines) 116 | 117 | 118 | def write_to_png_file(filename, figure, width, height): 119 | p = Path(__file__).resolve().parent / filename 120 | figure.write_image(str(p), width=width, height=height) 121 | 122 | 123 | if __name__ == '__main__': 124 | main() 125 | --------------------------------------------------------------------------------