Skip to content

Commit

Permalink
Merge pull request #1 from alexandergerber/master
Browse files Browse the repository at this point in the history
added .js for terminal style code highlighting
  • Loading branch information
BerriJ authored Jun 13, 2019
2 parents 28d3786 + 48d229e commit c3c9459
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 18 deletions.
Binary file modified Performance/.DS_Store
Binary file not shown.
18 changes: 14 additions & 4 deletions Performance/ARE.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ output:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
includes:
after_body: terminal_highlight.html
# ratio: "16:9"
---

Expand Down Expand Up @@ -304,11 +306,16 @@ background-size: cover


---
class: center, middle

# xaringan
### xaringan

### /ʃæ.'riŋ.ɡæn/
```terminal
josh@brick ~/repos/aha $ git log -2
<span style="color:olive;">commit 36b0a3af174e204c8d0a7a993ad467cd7be39bca</span>
Author: Ziz <[email protected]>
Date: Fri Aug 3 10:29:43 2012 +0200
Small version changes, make clean, merging, etc.
...
```

---
class: inverse, center, middle
Expand Down Expand Up @@ -842,3 +849,6 @@ class: center, middle
Slides created via the R package [**xaringan**](https://github.com/yihui/xaringan).

The chakra comes from [remark.js](https://remarkjs.com), [**knitr**](http://yihui.name/knitr), and [R Markdown](https://rmarkdown.rstudio.com).



46 changes: 32 additions & 14 deletions Performance/ARE.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="utf-8" />
<meta name="author" content="Martin Arnold" />
<meta name="author" content="Alexander Gerber" />
<meta name="date" content="2019-05-27" />
<meta name="date" content="2019-06-12" />
<script src="libs/htmlwidgets/htmlwidgets.js"></script>
<script src="libs/jquery/jquery.min.js"></script>
<link href="libs/leaflet/leaflet.css" rel="stylesheet" />
Expand All @@ -31,7 +31,7 @@
# Advanced R for Econometricians
### Martin Arnold
### Alexander Gerber
### 2019-05-27
### 2019-06-12

---

Expand Down Expand Up @@ -75,7 +75,7 @@

- We are (mostly) happy to accept the slower speed for the time saved from not having to reinvent the wheel each time we want to implement a new function that, e.g., computes a test statistic.

(meanwhile there are 14290 packages available on [CRAN](https://cran.r-project.org/) with many useful functions waiting to be discovered by you!)
(meanwhile there are 14354 packages available on [CRAN](https://cran.r-project.org/) with many useful functions waiting to be discovered by you!)

---
### (Why) is R slow?
Expand Down Expand Up @@ -220,9 +220,9 @@
```
## Unit: nanoseconds
## expr min lq mean median uq max neval
## g(x) 585 629 1437.214 665 803 17877928 1e+05
## h(x) 584 633 1408.318 669 805 16350847 1e+05
## i(x) 586 629 1265.127 666 804 17243079 1e+05
## g(x) 577 612 1466.433 636 784 19869745 1e+05
## h(x) 584 619 1256.307 642 781 18067517 1e+05
## i(x) 577 615 1405.510 639 783 17562108 1e+05
```

---
Expand Down Expand Up @@ -317,8 +317,8 @@
```
## Unit: nanoseconds
## expr min lq mean median uq max neval
## f1() 108 123 169.6690 131 139 637484 1e+05
## f2() 179 202 381.2106 214 292 3332593 1e+05
## f1() 107 125 190.1854 135 153 1337392 1e+05
## f2() 177 205 378.1311 229 312 2745651 1e+05
```

Arguments trigger promises each time the function is *called*. Superflous arguments mean unecessary overhead.
Expand Down Expand Up @@ -347,11 +347,16 @@


---
class: center, middle

# xaringan

### /ʃæ.'riŋ.ɡæn/
### xaringan

```terminal
josh@brick ~/repos/aha $ git log -2
&lt;span style="color:olive;"&gt;commit 36b0a3af174e204c8d0a7a993ad467cd7be39bca&lt;/span&gt;
Author: Ziz &lt;[email protected]&gt;
Date: Fri Aug 3 10:29:43 2012 +0200
Small version changes, make clean, merging, etc.
...
```

---
class: inverse, center, middle
Expand Down Expand Up @@ -536,7 +541,7 @@
```

```
# [1] "地爆天星" "天照"
# character(0)
```

---
Expand Down Expand Up @@ -1035,6 +1040,19 @@
deleted = true;
});
})();</script>
<script type="text/javascript">
var hljs = remark.highlighter.engine;
</script>
<script src="terminal.language.js" type="text/javascript"></script>
<script type="text/javascript">
var slideshow = remark.create({});
// extract the embedded styling from ansi spans
var highlighted = document.querySelectorAll("code.terminal span.hljs-ansi");
Array.prototype.forEach.call(highlighted, function(next) {
next.insertAdjacentHTML("beforebegin", next.textContent);
next.parentNode.removeChild(next);
});
</script>

<script>
(function() {
Expand Down
Binary file added Performance/ARE_cache/.DS_Store
Binary file not shown.
24 changes: 24 additions & 0 deletions Performance/terminal.language.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Language: terminal console
Author: Josh Bode <[email protected]>
*/

hljs.registerLanguage('terminal', function() {
return {
contains: [
{
className: 'string',
begin: '^([\\w.]+)@([\\w.]+)'
},
{
className: 'constant',
begin: ' (.*) \\$ '
},
{
className: 'ansi',
begin: '<span style\\="([^"]+)">',
end: '<\\/span>'
}
]
}
});
13 changes: 13 additions & 0 deletions Performance/terminal_highlight.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script type="text/javascript">
var hljs = remark.highlighter.engine;
</script>
<script src="terminal.language.js" type="text/javascript"></script>
<script type="text/javascript">
var slideshow = remark.create({});
// extract the embedded styling from ansi spans
var highlighted = document.querySelectorAll("code.terminal span.hljs-ansi");
Array.prototype.forEach.call(highlighted, function(next) {
next.insertAdjacentHTML("beforebegin", next.textContent);
next.parentNode.removeChild(next);
});
</script>

0 comments on commit c3c9459

Please sign in to comment.