-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
541 lines (456 loc) · 19.4 KB
/
index.html
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
537
538
539
540
541
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>
Herry's blog
</title>
<meta name="description" content="">
<meta name="author" content="songcser">
<meta http-equiv="Cache-Control" content="no-transform"/>
<meta http-equiv="Cache-Control" content="no-siteapp">
<link rel="icon" type="image/x-icon" href="">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script>
var _hmt = _hmt || [];
(function(){var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?9dc76ff7c27726f611c9dea1a3b894d5";
var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(hm, s);})();
</script>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-4789341100316359",
enable_page_level_ads: true
});
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/vue/1.0.25-csp/vue.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment.min.js"></script>
</head>
<body id="replica-app">
<nav class="navbar-wrapper">
<div class="navbar">
<div class="container clearfix">
<a href="/" class="navbar-logo"><i class="fa fa-github"></i></a>
<div class="navbar-search float-left desktop-only">
<div class="navbar-search-form">
<label for="gsc-i-id1">This website</label>
<div id="google-search">
<gcse:search></gcse:search>
</div>
</div>
</div>
<ul class="navbar-nav float-left">
<li><a href="/archives">Archives</a></li>
<li><a href="/categories">Categories</a></li>
<li><a href="/tags">Tags</a></li>
<li><a href="/atom.xml" target="_blank">RSS</a></li>
</ul>
<ul class="navbar-nav user-nav float-right desktop-only">
<li class="user-nav-notification">
<a><span class="user-nav-unread"></span><i class="fa fa-bell"></i></a>
</li>
<li>
<a><i class="fa fa-plus"></i> <i class="fa fa-caret-down"></i></a>
</li>
<li class="user-nav-logo">
<a><img src="https://dn-coding-net-production-static.qbox.me/d369021c-643f-480e-ae0a-0f97460665d6.jpg?imageMogr2/auto-orient/format/jpeg/crop/!215x215a39a0/thumbnail/460"> <i class="fa fa-caret-down"></i></i></a>
</li>
</ul>
</div>
</div>
</nav>
<div class="main-container">
<div class="container-lg">
<div class="blog-intro">
<div class="blog-intro-user">
<img class="avatar" src="https://dn-coding-net-production-static.qbox.me/d369021c-643f-480e-ae0a-0f97460665d6.jpg?imageMogr2/auto-orient/format/jpeg/crop/!215x215a39a0/thumbnail/460">
<div class="user-name">
<div class="blog-title">Herry's blog</div>
<div class="blog-author">songcser</div>
<ul class="user-detail mobile-only">
<li>
<i class="fa fa-map-marker"></i>
Shang Hai
</li>
<li>
<i class="fa fa-envelope-o"></i>
<a href="mailto:[email protected]">[email protected]</a>
</li>
<li>
<i class="fa fa-link"></i>
<a href="https://www.songcser.com">https://www.songcser.com</a>
</li>
</ul>
</div>
<div class="blog-description">
</div>
</div>
<ul class="user-detail desktop-only">
<li>
<i class="fa fa-map-marker"></i>
Shang Hai
</li>
<li>
<i class="fa fa-envelope-o"></i>
<a href="mailto:[email protected]">[email protected]</a>
</li>
<li>
<i class="fa fa-link"></i>
<a href="https://www.songcser.com">https://www.songcser.com</a>
</li>
</ul>
<div class="social-media desktop-only">
<h4>Social Media</h4>
<ul>
<li class="social-media-item"><a href="https://github.com/songcser" target="_blank"><i class="fa fa-github"></i></a></li>
<li class="social-media-item"><a href="http://weibo.com/1751043871" target="_blank"><i class="fa fa-weibo"></i></a></li>
<li class="social-media-item"><a href="http://www.linkedin.com/in/herry-song-4954b85a/" target="_blank"><i class="fa fa-linkedin"></i></a></li>
</ul>
</div>
</div>
<div class="blog-detail">
<nav class="blog-detail-nav desktop-only">
<ul class="clearfix">
<li class="selected">
<a href="/">Overview</a></li>
<li class="">
<a href="/archives">Posts <span class="counter">17</span></a>
</li>
<li class="">
<a href="/categories">Categories <span
class="counter">2</span></a></li>
<li class="">
<a href="/tags">Tags <span class="counter">8</span></a></li>
</ul>
</nav>
<div class="body-secondary">
<p class="right-title">Recent post</p>
<ul class="recent-post clearfix">
<li class="recent-post-item">
<div class="clearfix">
<h5 class="post-title text-ellipsis">
<i class="fa fa-bars"></i>
<a href="/2017/11/21/debugging-with-asyncio/">asyncio之调试</a>
</h5>
<p class="post-description text-ellipsis desktop-only">
asyncio构建了一些有用的调试特性。
首先,事件循环在运行时使用logging来发送状态信
</p>
<p class="post-info desktop-only">
<span><i class="fa fa-folder-open"></i> asyncio</span>
<span><i class="fa fa-tag"></i> 3 </span>
</p>
</div>
</li>
<li class="recent-post-item">
<div class="clearfix">
<h5 class="post-title text-ellipsis">
<i class="fa fa-bars"></i>
<a href="/2017/11/13/combining-coroutines-with-threads-and-processes/">asyncio之协程和线程进程组合</a>
</h5>
<p class="post-description text-ellipsis desktop-only">
许多已经存在的库还没有使用原生的asyncio。可能造成阻塞或者依赖并发特性的模块不可用。还是有可
</p>
<p class="post-info desktop-only">
<span><i class="fa fa-folder-open"></i> asyncio</span>
<span><i class="fa fa-tag"></i> 3 </span>
</p>
</div>
</li>
<li class="recent-post-item">
<div class="clearfix">
<h5 class="post-title text-ellipsis">
<i class="fa fa-bars"></i>
<a href="/2017/11/06/receiving-unix-signals/">asyncio之接收Unix信号</a>
</h5>
<p class="post-description text-ellipsis desktop-only">
通常Unix系统事件通知需要中断应用来触发执行。当使用asyncio时,信号处理回调会与事件循环管
</p>
<p class="post-info desktop-only">
<span><i class="fa fa-folder-open"></i> asyncio</span>
<span><i class="fa fa-tag"></i> 3 </span>
</p>
</div>
</li>
<li class="recent-post-item">
<div class="clearfix">
<h5 class="post-title text-ellipsis">
<i class="fa fa-bars"></i>
<a href="/2017/10/26/working-with-subprocesses/">asyncio之子进程交互</a>
</h5>
<p class="post-description text-ellipsis desktop-only">
经常需要和其他的一些程序和进程一起工作,以便使用已经存在的代码而不用重写,或者访问Python中已
</p>
<p class="post-info desktop-only">
<span><i class="fa fa-folder-open"></i> asyncio</span>
<span><i class="fa fa-tag"></i> 3 </span>
</p>
</div>
</li>
<li class="recent-post-item">
<div class="clearfix">
<h5 class="post-title text-ellipsis">
<i class="fa fa-bars"></i>
<a href="/2017/10/25/interacting-with-domain-name-services/">asyncio之域名服务交互</a>
</h5>
<p class="post-description text-ellipsis desktop-only">
应用程序使用网络与服务器进行通信时可能需要域名服务(DNS),如在主机名和IP地址之间进行转换。a
</p>
<p class="post-info desktop-only">
<span><i class="fa fa-folder-open"></i> asyncio</span>
<span><i class="fa fa-tag"></i> 4 </span>
</p>
</div>
</li>
<li class="recent-post-item">
<div class="clearfix">
<h5 class="post-title text-ellipsis">
<i class="fa fa-bars"></i>
<a href="/2017/10/23/using-ssl/">asyncio之使用SSL</a>
</h5>
<p class="post-description text-ellipsis desktop-only">
asyncio内置支持在套接字上启用SSL通信。通过将SSLContext实例传递给协程来创建服务
</p>
<p class="post-info desktop-only">
<span><i class="fa fa-folder-open"></i> asyncio</span>
<span><i class="fa fa-tag"></i> 3 </span>
</p>
</div>
</li>
</ul>
<div class="calendar-container" id="calendar">
<div class="calendar">
<h3>
{{posts.length}} contributions in the last year
</h3>
<div class="calendar-graph-container">
<div class="calendar-graph">
<svg width="676" height="104" @mouseout="mouseoverDate=null">
<g transform="translate(16, 20)">
<g v-for="week in calendar" :transform="week.transform">
<rect v-for="day in week.days"
:x="day.x"
:y="day.y"
:fill="day.fill"
@click="selectedDate=day.date"
@mouseover="mouseoverDate=day.date"
:class="{active:selectedDate===day.date}"
data-count="{{day.posts.length}}"
data-date="{{day.date}}"
class="day" width="10" height="10"
></rect>
</g>
<text v-for="month in monthLabels"
:x="month.x"
y="-5"
class="month">{{month.text}}
</text>
<text text-anchor="start" class="wday" dx="-14" dy="8"
style="display: none;">S
</text>
<text text-anchor="start" class="wday" dx="-14" dy="20">Mon</text>
<text text-anchor="start" class="wday" dx="-14" dy="32"
style="display: none;">T
</text>
<text text-anchor="start" class="wday" dx="-14" dy="44">Wed</text>
<text text-anchor="start" class="wday" dx="-14" dy="57"
style="display: none;">T
</text>
<text text-anchor="start" class="wday" dx="-14" dy="69">Fri</text>
<text text-anchor="start" class="wday" dx="-14" dy="81"
style="display: none;">S
</text>
</g>
</svg>
<div class="svg-tip svg-tip-one-line"
v-bind:style="{ top: svgtip.top, left: svgtip.left, display: svgtip.display}">
<strong>{{svgtip.text}}</strong> on
{{moment(mouseoverDate).format('MMM DD, YYYY')}}
</div>
</div>
<div class="calendar-footer clearfix">
<span>
<a href="#">Learn how we count contributions.</a>
</span>
<div class="calendar-legend">
<span>Less</span>
<ul class="legend">
<li style="background-color: #eee"></li>
<li style="background-color: #d6e685"></li>
<li style="background-color: #8cc665"></li>
<li style="background-color: #44a340"></li>
<li style="background-color: #1e6823"></li>
</ul>
<span>More</span>
</div>
</div>
</div>
</div>
<h3>Contribution activity</h3>
<div class="contribution-list">
<ul>
<li v-for="post in posts | filterBy selectedDate in 'date'">
<a href="{{post.url}}">{{post.title}}
</a>
<span>{{post.date}}</span>
</li>
</ul>
</div>
</div>
<script>
var posts = [{"date":"2017-09-04","title":"Hello World","url":"https://www.songcser.com/2017/09/04/hello-world/"},{"date":"2017-09-20","title":"基于Sanic的微服务基础架构","url":"https://www.songcser.com/2017/09/20/sanic-microservice/"},{"date":"2017-09-24","title":"asyncio之异步协程概念","url":"https://www.songcser.com/2017/09/24/asynchronous-concurrency-concepts/"},{"date":"2017-09-25","title":"asyncio之协程的多任务处理","url":"https://www.songcser.com/2017/09/25/cooperative-multitasking-with-coroutines/"},{"date":"2017-09-26","title":"asyncio之异步生成结果","url":"https://www.songcser.com/2017/09/26/producing-results-asynchronously/"},{"date":"2017-09-26","title":"asyncio之执行并发任务","url":"https://www.songcser.com/2017/09/26/executing-tasks-concurrently/"},{"date":"2017-09-26","title":"asyncio之常规函数调用","url":"https://www.songcser.com/2017/09/26/scheduling-calls-to-regular-functions/"},{"date":"2017-10-10","title":"asyncio之协程控制结构","url":"https://www.songcser.com/2017/10/10/composing-coroutines-with-control-structures/"},{"date":"2017-10-11","title":"asyncio之同步原语","url":"https://www.songcser.com/2017/10/11/synchronization-primitives/"},{"date":"2017-10-13","title":"asyncio之抽象类Protocol异步IO","url":"https://www.songcser.com/2017/10/13/asynchronous-IO-with-protocol-class-abstractions/"},{"date":"2017-10-20","title":"asyncio之协程异步IO流","url":"https://www.songcser.com/2017/10/20/asynchronous-IO-using-coroutines-and-streams/"},{"date":"2017-10-23","title":"asyncio之使用SSL","url":"https://www.songcser.com/2017/10/23/using-ssl/"},{"date":"2017-10-25","title":"asyncio之域名服务交互","url":"https://www.songcser.com/2017/10/25/interacting-with-domain-name-services/"},{"date":"2017-10-26","title":"asyncio之子进程交互","url":"https://www.songcser.com/2017/10/26/working-with-subprocesses/"},{"date":"2017-11-06","title":"asyncio之接收Unix信号","url":"https://www.songcser.com/2017/11/06/receiving-unix-signals/"},{"date":"2017-11-13","title":"asyncio之协程和线程进程组合","url":"https://www.songcser.com/2017/11/13/combining-coroutines-with-threads-and-processes/"},{"date":"2017-11-21","title":"asyncio之调试","url":"https://www.songcser.com/2017/11/21/debugging-with-asyncio/"}];
var today = moment().format('YYYY-MM-DD');
var oneYearAgo = moment(today).subtract(1, 'years');
posts = posts.filter(function(post) {
return new Date(post.date) > oneYearAgo;
});
var monthLabels = [];
var monthName = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
var calendar = getCalendar(posts);
var dateRange = {
start: moment(oneYearAgo).format('MMM D, YYYY'),
end: moment().format('MMM D, YYYY')
}
var app = new Vue({
el: '#calendar',
data: {
posts: posts,
selectedDate: null,
calendar: calendar,
dateRange: dateRange,
mouseoverDate: null,
moment: moment,
monthLabels: monthLabels
},
created: function() {
this.selectedDate = 'none';
},
methods: {},
computed: {
svgtip: function() {
var date = this.mouseoverDate;
var display = date ? 'block' : 'none';
if (date) {
var coordinator = getIndexByDate(date);
var x = coordinator[0];
var y = coordinator[1];
var len = this.calendar[x].days[y].posts.length;
var text = len ? len + ' contributions' : 'No contributions';
var left = coordinator[0] * 12 - 37 + 'px';
coordinator[1] = coordinator[0] ? coordinator[1] : coordinator[1] + oneYearAgo.day();
var top = coordinator[1] * 12 + 12 - 32 + 'px';
}
return {
text: text,
left: left,
top: top,
display: display
}
}
}
});
function getCalendar(posts) {
// raw calendar
var maxCount = 0;
var tmr = new Date();
tmr.setDate(tmr.getDate() + 1);
var tmrStr = tmr.toISOString().slice(0, 10);
var date = new Date();
date.setYear(date.getFullYear() - 1); // start date is a year ago;
var calendar = [];
while (date.toISOString().slice(0, 10) !== tmrStr) {
var day = date.getDay();
if (day === 0 || calendar.length === 0) {
var x = calendar.length * 13;
calendar.push({
transform: 'translate(' + x + ',0)',
days: []
})
}
calendar[calendar.length - 1].days.push({
x: 14 - calendar.length,
y: day * 12,
date: date.toISOString().slice(0, 10),
posts: []
});
if (day === 0 && date.getDate() < 8) {
monthLabels.push({
x: 14 - calendar.length + x,
text: monthName[date.getMonth() - 1]
})
}
date.setDate(date.getDate() + 1);
}
// handle post info
posts.forEach(function(post) {
var x = getIndexByDate(post.date)[0];
var y = getIndexByDate(post.date)[1];
calendar[x].days[y].posts.push({
title: post.title,
url: post.url
});
var len = calendar[x].days[y].posts.length;
maxCount = Math.max(len, maxCount);
})
// handle fill color
calendar.forEach(function(week) {
week.days.forEach(function(day) {
day.fill = getColorByLength(day.posts.length, maxCount);
})
})
return calendar;
}
function getIndexByDate(date) {
date = moment(date);
var firstColumnLen = 7 - oneYearAgo.day();
var days = date.diff(oneYearAgo, 'days');
var x = days > firstColumnLen - 1 ? Math.ceil((days - firstColumnLen + 1) / 7) : 0;
var y = days > firstColumnLen - 1 ? date.day() : date.day() - oneYearAgo.day();
return [x, y];
}
function getColorByLength(len, max) {
var colors = ['#eee', '#d6e685', '#8cc665', '#44a340', '#1e6823'];
var colorsLen = colors.length - 1;
var color = len ? colors[0] : colors[1];
var interval = max / colorsLen;
if (max < colorsLen) {
color = colors[len];
} else {
color = colors[Math.ceil(len / interval)];
}
return color;
}
</script>
</div>
</div>
</div>
</div>
<div class="footer-wrapper container">
<footer class="footer clearfix">
<a href="https://www.songcser.com" class="footer-logo">
<!-- <i class="fa fa-github"></i> -->
鲁ICP备17046128
</a>
<ul class="footer-social-link">
<li>© 2017 songcser</li>
<li><a href="https://www.songcser.com">Home</a></li>
<li><a href="https://github.com/songcser">Github</a></li>
<li><a href="http://weibo.com/1751043871">Weibo</a></li>
<li><a href="http://www.linkedin.com/in/herry-song-4954b85a/">Linkedin</a></li>
</ul>
<div class="footer-theme-info">
<!-- Theme <a href="//github.com/sabrinaluo/hexo-theme-replica">Replica</a> -->
<!-- by <a href="//github.com/sabrinaluo">Hiitea</a> ❤ Powered by Hexo -->
Hosted by <a href="https://pages.coding.me">Coding Pages</a>
</div>
</footer>
</div>
<script src="/js/main.js"></script>
</body>
</html>