-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
536 lines (489 loc) · 25.7 KB
/
Copy pathindex.html
File metadata and controls
536 lines (489 loc) · 25.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>10 Python Tricks To Make Your Code Shorter</title>
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<meta name="HandheldFriendly" content="True" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="apple-touch-icon" sizes="57x57" href="/assets/favicons/apple-touch-icon-57x57.png?v=5637004f39">
<link rel="apple-touch-icon" sizes="60x60" href="/assets/favicons/apple-touch-icon-60x60.png?v=5637004f39">
<link rel="apple-touch-icon" sizes="72x72" href="/assets/favicons/apple-touch-icon-72x72.png?v=5637004f39">
<link rel="apple-touch-icon" sizes="76x76" href="/assets/favicons/apple-touch-icon-76x76.png?v=5637004f39">
<link rel="apple-touch-icon" sizes="114x114" href="/assets/favicons/apple-touch-icon-114x114.png?v=5637004f39">
<link rel="apple-touch-icon" sizes="120x120" href="/assets/favicons/apple-touch-icon-120x120.png?v=5637004f39">
<link rel="apple-touch-icon" sizes="144x144" href="/assets/favicons/apple-touch-icon-144x144.png?v=5637004f39">
<link rel="apple-touch-icon" sizes="152x152" href="/assets/favicons/apple-touch-icon-152x152.png?v=5637004f39">
<link rel="apple-touch-icon" sizes="180x180" href="/assets/favicons/apple-touch-icon-180x180.png?v=5637004f39">
<link rel="icon" type="image/png" href="/assets/favicons/favicon-32x32.png?v=5637004f39" sizes="32x32">
<link rel="icon" type="image/png" href="/assets/favicons/android-chrome-192x192.png?v=5637004f39" sizes="192x192">
<link rel="icon" type="image/png" href="/assets/favicons/favicon-96x96.png?v=5637004f39" sizes="96x96">
<link rel="icon" type="image/png" href="/assets/favicons/favicon-16x16.png?v=5637004f39" sizes="16x16">
<link rel="manifest" href="/assets/favicons/manifest.json?v=5637004f39">
<link rel="mask-icon" href="/assets/favicons/safari-pinned-tab.svg?v=5637004f39" color="#c64842">
<link rel="shortcut icon" href="/favicon.png">
<meta name="msapplication-TileColor" content="#c64842'}}">
<meta name="msapplication-TileImage" content="/assets/favicons/mstile-144x144.png?v=5637004f39">
<meta name="msappliandcation-config" content="/assets/favicons/browserconfig.xml?v=5637004f39">
<meta name="theme-color" content="#c64842">
<link rel="shortcut icon" href="/favicon.png" type="image/png" />
<link rel="canonical" href="https://www.devpy.me/python-tips-and-tricks/" />
<meta name="referrer" content="no-referrer-when-downgrade" />
<link rel="amphtml" href="https://www.devpy.me/python-tips-and-tricks/amp/" />
<meta property="og:site_name" content="DevPy" />
<meta property="og:type" content="article" />
<meta property="og:title" content="10 Python Tricks To Make Your Code Shorter" />
<meta property="og:description" content="These are mainly unique to python, so if you program in another language, these may be surprising. They certainly were for me when I got started with python. 1. Negative indexing &gt;&gt;&gt; a = [1,2,3] &gt;&gt;&gt; a[-2] 2 &gt;&gt;&gt; a[-1] 3" />
<meta property="og:url" content="https://www.devpy.me/python-tips-and-tricks/" />
<meta property="og:image" content="https://www.devpy.me/content/images/2016/05/heroku-x-python-wallpaper-screen-3840-2160-1.png" />
<meta property="article:published_time" content="2015-09-16T19:28:00.000Z" />
<meta property="article:modified_time" content="2017-09-05T20:49:29.000Z" />
<meta property="article:tag" content="programming" />
<meta property="article:tag" content="python" />
<meta property="article:publisher" content="https://www.facebook.com/devpytech" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="10 Python Tricks To Make Your Code Shorter" />
<meta name="twitter:description" content="These are mainly unique to python, so if you program in another language, these may be surprising. They certainly were for me when I got started with python. 1. Negative indexing &gt;&gt;&gt; a = [1,2,3] &gt;&gt;&gt; a[-2] 2 &gt;&gt;&gt; a[-1] 3" />
<meta name="twitter:url" content="https://www.devpy.me/python-tips-and-tricks/" />
<meta name="twitter:image" content="https://www.devpy.me/content/images/2016/05/heroku-x-python-wallpaper-screen-3840-2160-1.png" />
<meta name="twitter:label1" content="Written by" />
<meta name="twitter:data1" content="Robert Washbourne" />
<meta name="twitter:label2" content="Filed under" />
<meta name="twitter:data2" content="programming, python" />
<meta name="twitter:site" content="@devpytech" />
<meta property="og:image:width" content="3840" />
<meta property="og:image:height" content="2160" />
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Article",
"publisher": {
"@type": "Organization",
"name": "DevPy",
"url": "https://www.devpy.me/",
"logo": {
"@type": "ImageObject",
"url": "https://www.devpy.me/content/images/2016/12/devpyc.png"
}
},
"author": {
"@type": "Person",
"name": "Robert Washbourne",
"image": {
"@type": "ImageObject",
"url": "//www.gravatar.com/avatar/69e63cb22a93b5779ab522847f51d0d3?s=250&d=mm&r=x",
"width": 250,
"height": 250
},
"url": "https://www.devpy.me/author/robert/",
"sameAs": []
},
"headline": "10 Python Tricks To Make Your Code Shorter",
"url": "https://www.devpy.me/python-tips-and-tricks/",
"datePublished": "2015-09-16T19:28:00.000Z",
"dateModified": "2017-09-05T20:49:29.000Z",
"image": {
"@type": "ImageObject",
"url": "https://www.devpy.me/content/images/2016/05/heroku-x-python-wallpaper-screen-3840-2160-1.png",
"width": 3840,
"height": 2160
},
"keywords": "programming, python",
"description": "These are mainly unique to python, so if you program in another language, these\nmay be surprising. They certainly were for me when I got started with python.\n\n1. Negative indexing\n>>> a = [1,2,3]\n>>> a[-2] \n2\n>>> a[-1] \n3\n\n\n2. List slices\n>>> a = [1,2,3,4]\n>>> a[2:4] \n[3, 4]\n\n\n3. Grouped naming\n>>> a,b,c = [1,2,3]\n>>> a \n1 \n>>> b \n2\n>>> c \n3\n\n\n\n\n4. Set operations\n>>> a = {1,2,3,6,2,3}\n>>> b = {4,2,5,7,4,3}\n>>> a \nset([1, 2, 3, 6])\n>>> a | b \nset([1, 2, 3, 4, 5, 6, 7])\n>>> a & b \nset([2, 3])\n>>> ",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://www.devpy.me/"
}
}
</script>
<meta name="generator" content="Ghost 3.13" />
<link rel="alternate" type="application/rss+xml" title="DevPy" href="https://www.devpy.me/rss/" />
<style>
h1.lh-title, h2 {
box-decoration-break: clone;
-webkit-box-decoration-break: clone;
padding: 8px !important;
}
.isso-comment:not(:last-of-type), .isso-follow-up .isso-comment {
border-top: 1px solid rgba(0, 0, 0, 0.1);
}
.isso-comment:not(:first-of-type), .isso-follow-up .isso-comment {
border-top: none;
}
#isso-root {
display: flex;
flex-direction: column-reverse;
}
.isso-comment {
flex: 0;
width: 100%;
}
#isso-thread .avatar > svg[data-hash="31bd3215b1cf"] {
background-image: url(https://static.devpy.me/assets/favicons/android-chrome-48x48.png);
background-size: contain;
}
#isso-thread .avatar > svg[data-hash="31bd3215b1cf"] > rect {
display: none;
}
#carbonads {
margin-top: -10px;
z-index: 2;
position: relative;
background: white;
}
#sidebar > div.mt2 {
position: relative;
}
#sidebar > div:first-child::after {
content: "♪♪ ヽ(ˇ∀ˇ )ゞ";
position: absolute;
top: 4px;
z-index: 0;
width: calc(100% - 44px);
text-align: center;
}
</style>
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700" />
<link rel="stylesheet" href="/assets/css/normalize.css?v=5637004f39">
<link rel="stylesheet" href="/assets/css/tachyons.min.css?v=5637004f39">
<link rel="stylesheet" href="/assets/css/screen.css?v=5637004f39">
<link rel="stylesheet" href="/assets/css/prism-tomorrow.min.css?v=5637004f39">
</head>
<body class="fl w-100">
<div class="site-wrapper center mw8 w-100 cf">
<header class="bg-white black-80">
<div style="background-image: url(/content/images/2016/12/background.jpg); background-size: cover; text-align: center;height: 78px;" class="w-100 pt2 pb2">
<a class="blog-logo h-100-l" href="//www.devpy.me/"><img class="h-100" id="header-image" src="/content/images/2016/12/devpyc.png" alt="DevPy" /></a>
<div style="display:none;">The best software recommendations, linux tweaks, and custom code before it's cool.</div>
</div>
<nav id="topnav" class="mt1 pv2 pv3-ns bb w-100">
<a class="link dim black b f6 f5-ns dib mr3" href="/" title="Home">DevPy</a>
<a class=" link dim gray f6 f5-ns dib mr3" href="https://www.devpy.me/search/" title="Search">Search</a>
<a class="subscribe-button link dim gray f6 f5-ns dib" href="/subscribe/">Subscribe</a>
<span class="sharebuttons" style="float:right;margin-top: -0.25rem;">
<a href="https://www.facebook.com/sharer/sharer.php?u=https://www.devpy.me/python-tips-and-tricks/&t=10 Python Tricks To Make Your Code Shorter" onclick="ga('send', 'event', 'Share', 'facebook');window.open(this.href, 'facebook-share','width=580,height=296');return false;" title="Share on Facebook" target="_blank"><img alt="Share on Facebook" src="/assets/black/Facebook.png?v=5637004f39"></a>
<a href="https://twitter.com/intent/tweet?source=https://www.devpy.me/python-tips-and-tricks/&text=10 Python Tricks To Make Your Code Shorter https://www.devpy.me/python-tips-and-tricks/&via=devpytech" onclick="ga('send', 'event', 'Share', 'twitter');window.open(this.href, 'twitter-share', 'width=550,height=235');return false;" target="_blank" title="Tweet"><img alt="Tweet" src="/assets/black/Twitter.png?v=5637004f39"></a>
<a href="https://www.reddit.com/submit?url=https://www.devpy.me/python-tips-and-tricks/&title=10 Python Tricks To Make Your Code Shorter" onclick="ga('send', 'event', 'Share', 'reddit');window.open(this.href, 'reddit-share','width=873,height=692');return false;" target="_blank" title="Submit to Reddit"><img alt="Submit to Reddit" src="/assets/black/Reddit.png?v=5637004f39"></a>
</span>
</nav>
</header>
<div id="sidebar" class="sidebar w-20-l w-100 fr pa2 cf">
<div class="mt2 center bg-white br3 pa3 mv3 ba b--black-10"><script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?serve=CKYIE5Q7&placement=devpyme" id="_carbonads_js"></script></div>
<article id='devpyinfodiv' class="mw5 mt2 center bg-white br3 pa3 mv3 ba b--black-10 frontside-flip" style="clear: both;">
<div class="tc">
<img src="/assets/favicons/android-chrome-192x192.png?v=5637004f39" class="h3 w3 dib" title="DevPy">
</div>
<p class="lh-copy measure center f6 black-70">
On this website, you will find tutorials for installing & managing software, lists of the best linux resources, and in depth guides to linux.
</p>
<a href="https://www.devpy.me/slack" style="
font-weight: bold;
font-size: .875rem;
">Join us on Slack</a>
</article>
<div class="mt2 center bg-white br3 pa3 mv3 ba b--black-10 backside-flip">
<div id="devpromo">
<span>
<span class="devpromo-wrap">
<a href="//bit.ly/extravm" class="devpromo-text" target="_blank">
Get a high performance KVM VPS from ExtraVM. Starting at $3/month for a 512mb 7700k vCPU.
</a>
</span>
</span>
</div>
</div>
</div>
<nav id="articlenav" class="mw8 pv2 pv3-ns bb bg-white w-100" style="display: none;">
<a class="link dim black b f6 f5-ns dib mr3" href="https://www.devpy.me" title="Home">DevPy</a>
<span class="gray f6 f5-ns dib mr3" id="titlenav">10 Python Tricks To Make Your Code Shorter</span>
<span class="sharebuttons" style="position: absolute;right: 0;margin-top: -0.25rem;">
<a href="https://www.facebook.com/sharer/sharer.php?u=https://www.devpy.me/python-tips-and-tricks/" onclick="ga('send', 'event', 'Share', 'facebook');window.open(this.href, 'facebook-share','width=580,height=296');return false;ga('send', 'event', 'Share', 'facebook', 'Share');" title="Share on Facebook" target="_blank"><img alt="Share on Facebook" src="/assets/black/Facebook.png?v=5637004f39"></a>
<a href="https://twitter.com/intent/tweet?source=https://www.devpy.me/python-tips-and-tricks/&text=10 Python Tricks To Make Your Code Shorter https://www.devpy.me/python-tips-and-tricks/&via=devpytech" onclick="ga('send', 'event', 'Share', 'twitter');window.open(this.href, 'twitter-share', 'width=550,height=235');return false;ga('send', 'event', 'Share', 'twitter', 'Share');" target="_blank" title="Tweet"><img alt="Tweet" src="/assets/black/Twitter.png?v=5637004f39"></a>
<a href="https://www.reddit.com/submit?url=https://www.devpy.me/python-tips-and-tricks/" onclick="ga('send', 'event', 'Share', 'reddit');window.open(this.href, 'reddit-share','width=873,height=692');return false;ga('send', 'event', 'Share', 'reddit', 'Share');" target="_blank" title="Submit to Reddit"><img alt="Submit to Reddit" src="/assets/black/Reddit.png?v=5637004f39"></a>
</span>
</nav>
<div class="w-80-l w-100 fl pr3">
<main class="content bg-white black-80" role="main">
<article class="post tag-programming tag-python athelas">
<h1 class="lh-title">10 Python Tricks To Make Your Code Shorter</h1>
<p class="gray db"><a href="/author/robert/">Robert Washbourne</a> - 5 years ago - <a href="/tag/programming/">programming</a>, <a href="/tag/python/">python</a></p>
<img src="/content/images/2016/05/heroku-x-python-wallpaper-screen-3840-2160-1.png" />
<!--kg-card-begin: markdown--><p>These are mainly unique to python, so if you program in another language, these may be surprising. They certainly were for me when I got started with python.</p>
<h2 id="1negativeindexing">1. Negative indexing</h2>
<pre><code class="language-python">>>> a = [1,2,3]
>>> a[-2]
2
>>> a[-1]
3
</code></pre>
<h2 id="2listslices">2. List slices</h2>
<pre><code class="language-python">>>> a = [1,2,3,4]
>>> a[2:4]
[3, 4]
</code></pre>
<h2 id="3groupednaming">3. Grouped naming</h2>
<pre><code class="language-python">>>> a,b,c = [1,2,3]
>>> a
1
>>> b
2
>>> c
3
</code></pre>
<p></p>
<h2 id="4setoperations">4. Set operations</h2>
<pre><code class="language-python">>>> a = {1,2,3,6,2,3}
>>> b = {4,2,5,7,4,3}
>>> a
set([1, 2, 3, 6])
>>> a | b
set([1, 2, 3, 4, 5, 6, 7])
>>> a & b
set([2, 3])
>>> a - b
set([1, 6])
>>> a^b
set([1, 4, 5, 6, 7])
</code></pre>
<h2 id="5nlargestandnsmallest">5. nLargest and nSmallest</h2>
<pre><code class="language-python">>>> import heapq
>>> a = [3,2,5,6,7,34,8,3,42,4,5]
>>> heapq.nsmallest(5,a)
[2, 3, 3, 4, 5]
>>> heapq.nlargest(3,a)
[42, 34, 8]
</code></pre>
<h2 id="6cartesianproducts">6. Cartesian products</h2>
<pre><code class="language-python">>>> import itertools
>>> [print(p) for p in itertools.product([4,3,6,2],[3,6])]
(4, 3)
(4, 6)
(3, 3)
(3, 6)
(6, 3)
(6, 6)
(2, 3)
(2, 6)
</code></pre>
<h2 id="7invertingadictionary">7. Inverting a dictionary</h2>
<pre><code class="language-python">>>> a = {'a':1,'b':2,'c':3}
>>> {x: y for y, x in a.items()}
{1: 'a', 2: 'b', 3: 'c'}
</code></pre>
<h2 id="8generators">8. Generators</h2>
<pre><code class="language-python">>>> a = (x+1 for x in xrange(10))
>>> next(a) 1
>>> next(a) 2
>>> next(a) 3
</code></pre>
<h2 id="9namedtuples">9. Named tuples</h2>
<pre><code class="language-python">>>> import collections
>>> Point = collections.namedtuple('Point',['x','y'])
>>> p = Point(x=1,y=3)
>>> p
Point(x=1, y=3)
>>> p.x
1
>>> p.y
3
</code></pre>
<h2 id="10flattenlists">10. Flatten lists</h2>
<pre><code class="language-python">>>> a = [[1,2],[4,3],[5,2]]
>>> sum(a,[])
[1, 2, 4, 3, 5, 2]
</code></pre>
<!--kg-card-end: markdown-->
</article>
</main>
<section class="post-comments">
<script data-isso="https://comments.devpy.me"
src="https://comments.devpy.me/js/embed.min.js"
data-isso-require-author="true"
data-isso-require-email="true"></script>
<section id="isso-thread"></section>
</section>
<aside class="read-next">
<article class="bg-white w-100 w-50-l h-100 fl mt3">
<div class="ba b--black-10 ma1">
<a href="/how-to-run-as-admin-without-password/" title="How To Run As Administrator Without A Password">
<div style="background-color: grey; background-image: url(/content/images/2016/09/RunasRobGroupPolicyAllowedPath.jpg); height:200px; background-size: cover; background-position: 50% 50%;"></div>
</a>
<div class="pa3">
<a href="/how-to-run-as-admin-without-password/" class="lh-title f5 b pointer dib bg-white black-70 link underline-hover border-box">How To Run As Administrator Without A Password</a>
<p class="gray db" style="height: 84px;">I’m going to show you how to run files as admin without UAC popping up. This is also a <a href="/how-to-run-as-admin-without-password/" class="f5 b pointer dib bg-white black-70 link underline-hover border-box">[...]</a></p>
<small class="gray db pv2"><a href="Robert Washbourne">Robert Washbourne</a> - 5 years ago - <a href="/tag/windows/">windows</a></small>
</div>
</div>
</article>
<article class="bg-white w-100 w-50-l h-100 fl mt3">
<div class="ba b--black-10 ma1">
<a href="/how-to-hack-windows-without-admin/" title="Sethc Windows Exploit">
<div style="background-color: grey; background-image: url(/content/images/2016/09/Blank_Disk.png); height:200px; background-size: cover; background-position: 50% 50%;"></div>
</a>
<div class="pa3">
<a href="/how-to-hack-windows-without-admin/" class="lh-title f5 b pointer dib bg-white black-70 link underline-hover border-box">Sethc Windows Exploit</a>
<p class="gray db" style="height: 84px;">Here is how to become administrator without a password. This is proven on windows 7&8, but this should <a href="/how-to-hack-windows-without-admin/" class="f5 b pointer dib bg-white black-70 link underline-hover border-box">[...]</a></p>
<small class="gray db pv2"><a href="Robert Washbourne">Robert Washbourne</a> - 5 years ago - <a href="/tag/programming/">programming</a></small>
</div>
</div>
</article>
</aside>
</div>
<div id="bio_ep">
<div class="modal" style="padding:20px;">
<img src="/content/images/2016/06/DevPy.png" style="top: 0;width: 270px;position: absolute;right: 100%;">
<div class="modal-title">
<h3>DevPy Newletter</h3>
</div>
<div class="modal-body">
<i>Learn more open source.</i>
<p>We don't spam, and we only send emails once or twice a <s>week</s> month.</p>
<form id="subscribePop" onsubmit="event.preventDefault(); doSubPop();">
<div id="subscribe">
<input type="email" value="" name="EMAIL" class="email gh-input" id="emailPop" placeholder="email address" required>
<input type="submit" value="Subscribe" name="subscribe" class="button" style="width:160px !important">
</div>
</form>
<p id="subresPop"></p>
</div>
</div>
</div>
<script type="text/javascript" src="/assets/bioep.min.js?v=5637004f39"></script>
<script>
try {
bioEp.init({
width: 500,
height: 270,
cookieExp: 200
});
document.getElementById("bio_ep_close").innerHTML = "no thanks";
}
catch (e) {
console.log("welcome back!");
}
</script>
<script async>
var topper, el, flipper, disttop, advert, body, height;
function scrollSidebar() {
var y = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
if (y >= disttop) {
if (advert.className != 'sidebar w-20-l w-100 fr pa2 cf stickycarb') {
topper.style = 'visibility: hidden;';
el.style = 'position: fixed; top: 0; z-index:9999;';
advert.className = 'sidebar w-20-l w-100 fr pa2 cf stickycarb';
}
}
else {
if (advert.className != 'sidebar w-20-l w-100 fr pa2 cf') {
topper.style = 'visibility: visible;';
el.style = 'display: none;';
advert.className = 'sidebar w-20-l w-100 fr pa2 cf';
}
}
if (y >= height) {
if (flipper.className != 'mw5 mt2 center bg-white br3 pa3 mv3 ba b--black-10 frontside-flip flipped') {
flipper.className = 'mw5 mt2 center bg-white br3 pa3 mv3 ba b--black-10 frontside-flip flipped';
}
}
else {
if (flipper.className != 'mw5 mt2 center bg-white br3 pa3 mv3 ba b--black-10 frontside-flip') {
flipper.className = 'mw5 mt2 center bg-white br3 pa3 mv3 ba b--black-10 frontside-flip';
}
}
};
document.addEventListener('DOMContentLoaded', function() {
topper = document.getElementById('topnav');
el = document.getElementById('articlenav');
flipper = document.getElementById('devpyinfodiv');
disttop = document.getElementById('topnav').offsetTop;
advert = document.getElementById('sidebar');
body = document.body,
html = document.documentElement;
height = Math.max( body.scrollHeight, body.offsetHeight,
html.clientHeight, html.scrollHeight, html.offsetHeight ) * 0.15 ;
scrollSidebar();
window.onscroll = scrollSidebar;
}, false);
</script>
<script async>
function post(path, params) {
var http = new XMLHttpRequest();
var url = path;
http.open("POST", url, true);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
var res = JSON.parse(http.responseText);
var subres = document.getElementById("subres");
if (res["status"] === "success") {
subres.innerHTML = "You are now subscribed.";
ga('send', 'event', 'Subscribe', 'subscribe', 'Post');
} else {
subres.innerHTML = res["status"];
}
}
}
http.send(params);
}
function postPop(path, params) {
var http = new XMLHttpRequest();
var url = path;
http.open("POST", url, true);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
var res = JSON.parse(http.responseText);
var subres = document.getElementById("subresPop");
var close = document.getElementById("bio_ep_close");
if (res["status"] === "success") {
subres.innerHTML = "You are now subscribed.";
ga('send', 'event', 'Subscribe', 'subscribe', 'Popup');
close.innerHTML = "close";
} else {
subres.innerHTML = res["status"];
}
}
}
http.send(params);
}
function doSub() {
var em = document.getElementById("email").value;
post('https://grunt.devpy.me/subscribe', "email="+em);
}
function doSubPop() {
var em = document.getElementById("emailPop").value;
postPop('https://grunt.devpy.me/subscribe', "email="+em);
}
</script>
<footer class="mt3 pv3 ph3 ph4-m ph5-l mid-gray w-100 fl bt">
<small class="f6 db tc">© 2020 <b class="ttu">DevPy</b>. Inquiries at <b>robert@devpy.me</b></small>
<div class="tc mt3">
<a href="/tag/themes/" title="Themes" class="f6 dib ph2 link mid-gray dim">Linux Themes</a>
<a href="/tag/desktops/" title="Desktops" class="f6 dib ph2 link mid-gray dim">Linux Desktops</a>
<a href="/pages/" title="All Pages" class="f6 dib ph2 link mid-gray dim">All Pages</a>
<a href="/about/" title="About" class="f6 dib ph2 link mid-gray dim">About</a>
<a href="/privacy-policy/" title="Privacy" class="f6 dib ph2 link mid-gray dim">Privacy</a>
</div>
</footer>
</div>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/assets/service-worker.js');
}
</script>
<script async>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-77238872-2', 'auto');
ga('send', 'pageview');
</script>
<script src="/assets/prism.min.js?v=5637004f39"></script>
<script src="/assets/prism-bash.min.js?v=5637004f39"></script>
<script src="/assets/prism-python.min.js?v=5637004f39"></script>
</body>
</html>