Sandbox Playground Post
First post. It’s here as a placeholder for me to play around with jekyll and it’s markdown handling. Using linenos
attribute in highlight
tag somehow makes everything after highlight
to become included in <pre>
tag.
I also would like to use
``` js
// js code
```
syntax.
- one
- two
- three
- one
- two
- three
^ lists wow
1 #include <iostream>
2 #include <initializer_list>
3 #include <cassert>
4 #include <cmath>
5
6 #include "mpi.h"
7
8 using namespace std;
9
10 template <unsigned rowCount
11 , unsigned columnCount
12 , typename T = float>
13 class Matrix
14 {
15 public:
16 static const int rowCount_ = rowCount;
17 static const int columnCount_ = columnCount;
18
19 T e[columnCount * rowCount];
20
21 Matrix(std::initializer_list<T> l)
22 {
23 assert(l.size() == rowCount * columnCount);
24 for (auto i = l.begin(); i!= l.end(); ++i)
25 {
26 e[i - l.begin()] = *i;
27 }
28 }
29
30 Matrix(std::initializer_list<std::initializer_list<T>> l)
31 {
32 assert(l.size() == rowCount);
33 for (auto r = l.begin(); r != l.end(); ++r)
34 {
35 assert(r->size() == columnCount);
36 for (auto c = r->begin(); c != r->end(); ++c)
37 {
38 e[(r - l.begin()) * columnCount + (c - r->begin())] = *c;
39 }
40 }
41 }
42
43 Matrix()
44 {
45
46 }
47
48 void print()
49 {
50 for (int i = 0; i < rowCount; i++)
51 {
52 for (int j = 0; j < columnCount; j++)
53 {
54 cout << e[i * columnCount + j] << " ";
55 }
56 cout << endl;
57 }
58 }
59 };
60
61 template <unsigned RC1
62 , unsigned CRC12
63 , unsigned CC2
64 , typename T>
65 Matrix<RC1, CC2, T> operator *(const Matrix<RC1, CRC12, T>& lhs
66 , const Matrix<CRC12, CC2, T>& rhs)
67 {
68 Matrix<RC1, CC2, T> r;
69
70 for (int i = 0; i < CC2; i++)
71 {
72 for (int j = 0; j < RC1; j++)
73 {
74 T s = T();
75 for (int k = 0; k < CRC12; k++)
76 {
77 s += lhs.e[CRC12 * j + k] * rhs.e[CC2 * k + i];
78 }
79 r.e[j * CC2 + i] = s;
80 }
81 }
82
83 return r;
84 }
85
86 Matrix<2, 3> a = {{1.0, 2.0, 3.0,},
87 {4.0, 5.0, 6.0,}};
88
89 Matrix<3, 6> b = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0,
90 7.0, 8.0, 9.0, 1.0, 2.0, 3.0,
91 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
92
93 int main(int argc, char** argv)
94 {
95 a.print();
96 b.print();
97
98 auto c = a * b;
99 c.print();
100 return 0;
101 }
1 function connect() {
2
3 // All of sudden a very very long line of comment appears. All of sudden a very very long line of comment appears. All of sudden a very very long line of comment appears. And breaks code layout.
4
5 return new Promise(function (resolve, reject) {
6 utils.assert(sid_ !== undefined, 'sid is undefined');
7 utils.assert(wsURI_ !== undefined, 'wsURI is undefined');
8
9 socket = new WebSocket(wsURI_);
10
11 socket.onmessage = function (event) {
12 var data = JSON.parse(event.data);
13
14 if (data.tick !== undefined) {
15 if (tickHandler_ !== undefined) {
16 tickHandler_(data);
17 }
18
19 } else {
20 var queue = promiseHandlers[data.action];
21 if (queue === undefined || queue.length === 0) {
22 // TODO: unexpected error
23 }
24 var handler = queue.shift();
25 if (data.result === 'ok') {
26 handler.resolve(data);
27 } else {
28 utils.logError(event.data);
29 handler.reject(data);
30 }
31 }
32 };
33
34 socket.onopen = function (event) {
35 resolve();
36 };
37
38 socket.onclose = function (event) {
39 if (event.wasClean) {
40 console.log('Connection closed.');
41
42 } else {
43 console.log('Connection is lost.');
44 }
45 console.log('[Code: ' + event.code + ', reason: ' + event.reason + ']');
46 socket = undefined;
47 };
48 });
49 }
This is how
>
quotations get rendered. This text actually shouldn’t be part of highlighted code block, if it appears so.
Some more text.