Test fonts and syntax highlight
5 Feb 2017
To be, or not to be, Ay there’s the point, To Die, to sleep, is that all? Aye all: No, to sleep, to dream, aye marry there it goes, For in that dream of death, when we awake, And borne before an everlasting Judge, From whence no passenger ever returned, The undiscovered country, at whose sight The happy smile, and the accursed damn’d. But for this, the joyful hope of this, Who’d bear the scorns and flattery of the world, Scorned by the right rich, the rich cursed of the poor? The widow being oppressed, the orphan wrong’d, The taste of hunger, or a tyrants reign, And thousand more calamities besides, To grunt and sweat under this weary life, When that he may his full Quietus make, With a bare bodkin, who would this endure, But for a hope of something after death? Which puzzles the brain, and doth confound the sense, Which makes us rather bear those evils we have, Than fly to others that we know not of. Aye that, O this conscience makes cowards of us all, Lady in thy orizons, be all my sins remembered.
“To be, or not to be” is one of the most widely known and quoted lines in modern English, and the soliloquy has been referenced in innumerable works of theatre, literature and music.
春眠不觉晓,处处闻啼鸟。 夜来风雨声,花落知多少。
春眠不觉晓,处处闻啼鸟。 夜来风雨声,花落知多少。
移舟泊烟渚
日暮客愁新
野旷天低树
江清月近人
江清月近人
- 独上高楼望尽天涯路。
- 衣带渐宽终不悔,为伊消得人憔悴。
- 众里寻他千百度,暮然回首,那人正在灯火阑珊处。
- 昔我往矣,杨柳依依。今我来思,雨雪霏霏。
- 蒹葭(jiān jiā)苍苍,白露为霜。 所谓伊人,在水一方。
- 彼采葛兮,一日不见,如三月兮。彼采萧兮,一日不见,如三秋兮。彼采艾兮,一日不见,如三岁兮。
Test syntax highlighting
go
pckage main
import (
"fmt"
"time"
)
func readword(ch chan string) {
fmt.Println("Type a word, then hit Enter.")
var word string
fmt.Scanf("%s", &word)
ch <- word
}
func timeout(t chan bool) {
time.Sleep(5 * time.Second)
t <- true
}
func main() {
t := make(chan bool)
go timeout(t)
ch := make(chan string)
go readword(ch)
select {
case word := <-ch:
fmt.Println("Received", word)
case <-t:
fmt.Println("Timeout.")
}
}
Bash
[ -r ~/.profile ] && . ~/.profile # set up environment, once, Bourne-sh syntax only
if [ -n "$PS1" ] ; then # are we interactive?
[ -r ~/.bashrc ] && . ~/.bashrc # tty/prompt/function setup for interactive shells
[ -r ~/.bash_login ] && . ~/.bash_login # any at-login tasks for login shell only
fi # End of "if" block
JavaScript
var counter = (function () {
var i = 0; // private property
return { // public methods
get: function () {
alert(i);
},
set: function (value) {
i = value;
},
increment: function () {
alert(++i);
}
};
})(); // module
counter.get(); // shows 0
counter.set(6);
counter.increment(); // shows 7
counter.increment(); // shows 8
HTML
<!DOCTYPE html>
<html>
<head>
<title>MathJax TeX Test Page</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML">
</script>
</head>
<body>
When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are
$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
</body>
</html>
Scala
var correct = 0
var questions = 0
var heads = 0
var trials = 10000
// Let's run some trials
(1 to trials).foreach { trial =>
// toss a fair coin
scala.util.Random.nextBoolean() match {
case true => // Heads was tossed. Wake on Monday.
// Sleeping Beauty always bet Heads was tossed;
// ... in this case, only once.
questions += 1
correct += 1
heads += 1
case _ => // Tails was tossed. Wake on Monday and Tuesday.
// Sleeping Beauty always bet Heads was tossed;
// ... in this case, it will bet both on Monday
// and Tuesday. But it will fail!
questions += 2
}
}
println("Probability of SB being correct: " + correct.toDouble/questions)
println("Probability of Heads being tossed: " + heads.toDouble/trials)
Here’s a sample run:
Probability of SB being correct: 0.33636242148870776
Probability of Heads being tossed: 0.5034
Test for MathJax (Tex/LaTeX)
When , there are two solutions to and they are
we assume this definition:
A note for MathJax when using single $
When using the single-dollar delimiters, ”… the cost is $2.50 for the first one, and $2.00 for each additional one …” would cause the phrase “2.50 for the first one, and” to be treated as mathematics since it falls between dollar signs. For this reason, if you want to use single-dollars for in-line math mode, you must enable that explicitly in your configuration:
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
<script type="text/javascript" async
src="path-to-mathjax/MathJax.js?config=TeX-AMS_CHTML"></script>
There has been an extensive discussion on this topic, see more details in this page.