Skip to content

Commit 4253d8d

Browse files
committed
Merge branch 'master' into pygame
2 parents 5c77a7d + 4c3cdeb commit 4253d8d

26 files changed

+69
-235
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ flatter_list = list(itertools.chain.from_iterable(<list>))
5353
product_of_elems = functools.reduce(lambda out, x: out * x, <collection>)
5454
list_of_chars = list(<str>)
5555
```
56-
* **Check out module [operator](#operator) for alternative versions of examples.**
56+
* **Module [operator](#operator) provides functions itemgetter() and mul() that offer the same functionality as lambda expressions above.**
5757

5858
```python
5959
<int> = <list>.count(<el>) # Returns number of occurrences. Also works on strings.
@@ -2294,7 +2294,8 @@ async def random_controller(id_, moves):
22942294
await asyncio.sleep(random.random() / 2)
22952295

22962296
async def human_controller(screen, moves):
2297-
while (ch := screen.getch()) != 27:
2297+
while True:
2298+
ch = screen.getch()
22982299
key_mappings = {259: D.n, 261: D.e, 258: D.s, 260: D.w}
22992300
if ch in key_mappings:
23002301
moves.put_nowait(('*', key_mappings[ch]))

index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203

204204
<body>
205205
<header>
206-
<aside>December 15, 2019</aside>
206+
<aside>March 7, 2020</aside>
207207
<a href="../" rel="author">Jure Šorn</a>
208208
</header>
209209

@@ -250,7 +250,7 @@
250250
list_of_chars = list(&lt;str&gt;)
251251
</code></pre>
252252
<ul>
253-
<li><strong>Check out module <a href="#operator">operator</a> for alternative versions of examples.</strong></li>
253+
<li><strong>Module <a href="#operator">operator</a> provides functions itemgetter() and mul() that offer the same functionality as lambda expressions above.</strong></li>
254254
</ul>
255255
<pre><code class="python language-python hljs">&lt;int&gt; = &lt;list&gt;.count(&lt;el&gt;) <span class="hljs-comment"># Returns number of occurrences. Also works on strings.</span>
256256
index = &lt;list&gt;.index(&lt;el&gt;) <span class="hljs-comment"># Returns index of first occurrence or raises ValueError.</span>
@@ -1990,7 +1990,8 @@
19901990
<span class="hljs-keyword">await</span> asyncio.sleep(random.random() / <span class="hljs-number">2</span>)
19911991

19921992
<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">human_controller</span><span class="hljs-params">(screen, moves)</span>:</span>
1993-
<span class="hljs-keyword">while</span> (ch := screen.getch()) != <span class="hljs-number">27</span>:
1993+
<span class="hljs-keyword">while</span> <span class="hljs-keyword">True</span>:
1994+
ch = screen.getch()
19941995
key_mappings = {<span class="hljs-number">259</span>: D.n, <span class="hljs-number">261</span>: D.e, <span class="hljs-number">258</span>: D.s, <span class="hljs-number">260</span>: D.w}
19951996
<span class="hljs-keyword">if</span> ch <span class="hljs-keyword">in</span> key_mappings:
19961997
moves.put_nowait((<span class="hljs-string">'*'</span>, key_mappings[ch]))
@@ -2721,7 +2722,7 @@
27212722

27222723

27232724
<footer>
2724-
<aside>December 15, 2019</aside>
2725+
<aside>March 7, 2020</aside>
27252726
<a href="../" rel="author">Jure Šorn</a>
27262727
</footer>
27272728

parse.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ const showdown = require('showdown');
1515
const hljs = require('highlightjs');
1616

1717

18-
const PDF_BUTTON =
19-
'<a href="https://transactions.sendowl.com/products/78175486/4422834F/view" rel="nofollow"><img src="web/button.png" style="max-width: none; min-width: 0;"/></a>\n';
20-
2118
const TOC =
2219
'<br>' +
2320
'<h2 id="toc">Contents</h2>\n' +
@@ -96,19 +93,13 @@ function getMd() {
9693
}
9794

9895
function modifyPage() {
99-
// addPdfButton()
10096
removeOrigToc();
10197
addToc();
10298
insertLinks();
10399
unindentBanner();
104100
highlightCode();
105101
}
106102

107-
function addPdfButton() {
108-
const nodes = $.parseHTML(PDF_BUTTON);
109-
$('img').first().parent().before(nodes);
110-
}
111-
112103
function removeOrigToc() {
113104
const headerContents = $('#contents');
114105
const contentsList = headerContents.next();
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

pdf/descripitive image_final-01.png

167 KB
Loading
File renamed without changes.

pdf/how_to_create_pdf.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
How To Create PDF (on macOS)
2+
============================
3+
PDF file can also be purchased here: https://transactions.sendowl.com/products/78175486/4422834F/view
4+
5+
Setup
6+
-----
7+
* Install Adobe Acrobat Pro DC.
8+
* Copy headers and footers from `pdf/Adobe/` folder to `/Users/<username>/Library/Preferences/Adobe/Acrobat/DC/HeaderFooter/`.
9+
* Change date in header and footer element of `web/template.html`.
10+
* Run `./parse.js` and commit changes.
11+
12+
Printing to PDF
13+
---------------
14+
### Normal PDF
15+
* Open `index.html` in text editor and first remove element `<p><br></p>` before the `<h1>Libraries</h1>`.
16+
* Then replace the footer and last three `<br>` elements with contents of `pdf/index_for_pdf.html` file and save.
17+
* Open `index.html` in Chrome and select 'Print...'.
18+
* Select destination 'Save as PDF', paper size 'A4', margins and scale 'Default' and no headers and footers and save.
19+
20+
### PDF optimized for laser color printing
21+
* Run `./parse.js` again.
22+
* Open `index.html` in text editor and first remove element `<p><br></p>` before the `<h1>Libraries</h1>`.
23+
* Then replace the footer and last three `<br>` elements with contents of `pdf/index_for_pdf_print.html` file and save.
24+
* Change all links in text to normal text. They can be found with this regex: `<strong>.*a href.*</strong>`.
25+
* Open `index.html` in Chrome.
26+
* 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.
27+
* Change lightness (L) percentage to:
28+
* 0% for the text.
29+
* 87% for the gray line on the left side of the code.
30+
* 89% for the gray hash characters by the titles
31+
* 37% for the red text and function names (they use their own red).
32+
* 60% for the blue text and the text in the contents (it uses its own blue), but leave color of decorators and the `>>>` intact.
33+
* 58% for the comments.
34+
* Individually change brightness of every comment line that starts with: `# $ pip3 install
35+
...` and of comments in basic script template to 57%, by adding `color: hsla(0, 0%, 57%, 1);` to their element.style.
36+
* Select 'Print...' and destination 'Save as PDF', paper size 'A4', margins and scale 'Default' and no headers and footers and save.
37+
38+
Adding headers and footers to PDF (the same for both files)
39+
-----------------------------------------------------------
40+
* Open the PDF file in Adobe Acrobat Pro DC.
41+
* Select 'Organize Pages' tab and remove last empty page.
42+
* Right click on one of the pages and select 'Crop Pages...'.
43+
* In 'Change page size' section select 'A4' for 'Page Sizes' set 'XOffset' to '0.1 in' and select page range All.
44+
* 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. Repeat the process for each preset.
45+
* If presets get lost, the font and the margins are as follow: 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.
46+
* Set title and author by selecting 'File/Propertiess...'.
47+
* Save.
48+
49+
Printing the PDF
50+
----------------
51+
* Open a 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.
52+
53+
54+
55+

web/index_for_pdf.html renamed to pdf/index_for_pdf.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
<div class="pagebreak"></div>
3+
<br>
24
<div class="pagebreak"></div>
35
<h2 id="index"><a href="#index" name="index">#</a>Index</h2>
46

web/index_for_pdf_print.html renamed to pdf/index_for_pdf_print.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
<!-- Brightnesses: sideline: 87, hash_symbol: 89, red: 37, blue: 60, comments: 58, pip_install_comments: 57 / scale-when-saving: 100%, scale-when-printing: 98% -->
2-
<!-- Change page size: fixed sizes: A4, XOffset: 0.1 in-->
3-
<!-- 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 -->
4-
51

2+
<div class="pagebreak"></div>
3+
<br>
64
<div class="pagebreak"></div>
75
<h2 id="index"><a href="#index" name="index">#</a>Index</h2>
86

web/button.png

-2.36 KB
Binary file not shown.

web/external_link.png

-3.29 KB
Binary file not shown.

web/index_tmp.txt

Lines changed: 0 additions & 149 deletions
This file was deleted.

web/mario_bros.png

1.18 KB
Loading

web/script.js

Lines changed: 0 additions & 65 deletions
This file was deleted.

web/sprite.png

-7.12 KB
Binary file not shown.

web/template.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,15 @@
203203

204204
<body>
205205
<header>
206-
<aside>December 15, 2019</aside>
206+
<aside>March 7, 2020</aside>
207207
<a href="../" rel="author">Jure Šorn</a>
208208
</header>
209209

210210
<a href="javascript:" id="return-to-top"><i class="icon-chevron-up"></i></a>
211211
<div id=main_container></div>
212212

213213
<footer>
214-
<aside>December 15, 2019</aside>
214+
<aside>March 7, 2020</aside>
215215
<a href="../" rel="author">Jure Šorn</a>
216216
</footer>
217217

0 commit comments

Comments
 (0)