daux.io/Examples/Code_Highlighting.html
2018-06-07 18:43:42 +00:00

2161 regels
58 KiB
HTML
Ruw Blame Geschiedenis

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<title>Code Highlighting - DAUX.IO</title>
<meta name="description" content="The Easiest Way To Document Your Project">
<meta name="author" content="Stéphane Goetz">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="icon" href="../themes/daux/img/favicon-blue.png" type="image/x-icon">
<!-- Mobile -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Font -->
<!-- CSS -->
<link href='../themes/daux/css/theme-blue.min.css' rel='stylesheet' type='text/css'>
<!-- Tipue Search -->
<link href="../tipuesearch/tipuesearch.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="../themes/daux/js/html5shiv-3.7.3.min.js"></script>
<![endif]-->
</head>
<body class="with-float ">
<div class="Columns content">
<aside class="Columns__left Collapsible">
<button type="button" class="Button Collapsible__trigger">
<span class="Collapsible__trigger__bar"></span>
<span class="Collapsible__trigger__bar"></span>
<span class="Collapsible__trigger__bar"></span>
</button>
<a class="Brand" href="../index.html">DAUX.IO</a>
<div class="Search">
<svg class="Search__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 451 451">
<path d="M447.05 428l-109.6-109.6c29.4-33.8 47.2-77.9 47.2-126.1C384.65 86.2 298.35 0 192.35 0 86.25 0 .05 86.3.05 192.3s86.3 192.3 192.3 192.3c48.2 0 92.3-17.8 126.1-47.2L428.05 447c2.6 2.6 6.1 4 9.5 4s6.9-1.3 9.5-4c5.2-5.2 5.2-13.8 0-19zM26.95 192.3c0-91.2 74.2-165.3 165.3-165.3 91.2 0 165.3 74.2 165.3 165.3s-74.1 165.4-165.3 165.4c-91.1 0-165.3-74.2-165.3-165.4z"/>
</svg>
<input type="search" id="tipue_search_input" class="Search__field" placeholder="Search..." autocomplete="on"
results=25 autosave=text_search>
</div>
<div class="Collapsible__content">
<!-- Navigation -->
<ul class='Nav'><li class='Nav__item '><a href="../Getting_Started.html">Getting Started</a></li><li class='Nav__item has-children'><a href="../Features/Auto_Syntax_Highlight.html" class="folder"><i class="Nav__arrow">&nbsp;</i>Features</a><ul class='Nav'><li class='Nav__item '><a href="../Features/Auto_Syntax_Highlight.html">Auto Syntax Highlight</a></li><li class='Nav__item '><a href="../Features/CommonMark_compliant.html">CommonMark compliant</a></li><li class='Nav__item '><a href="../Features/Edit_on_GitHub_links.html">Edit on GitHub links</a></li><li class='Nav__item '><a href="../Features/Front_Matter.html">Front Matter</a></li><li class='Nav__item '><a href="../Features/Internal_links.html">Internal links</a></li><li class='Nav__item '><a href="../Features/Landing_page.html">Landing page</a></li><li class='Nav__item '><a href="../Features/Live_mode.html">Live mode</a></li><li class='Nav__item '><a href="../Features/Multilanguage.html">Multilanguage</a></li><li class='Nav__item '><a href="../Features/Multiple_Output_Formats.html">Multiple Output Formats</a></li><li class='Nav__item '><a href="../Features/Navigation_and_Sorting.html">Navigation and Sorting</a></li><li class='Nav__item '><a href="../Features/Search.html">Search</a></li><li class='Nav__item '><a href="../Features/Static_Site_Generation.html">Static Site Generation</a></li><li class='Nav__item '><a href="../Features/Table_of_contents.html">Table of contents</a></li></ul></li><li class='Nav__item Nav__item--open has-children'><a href="../Examples/index.html" class="folder"><i class="Nav__arrow">&nbsp;</i>Examples</a><ul class='Nav'><li class='Nav__item Nav__item--active'><a href="../Examples/Code_Highlighting.html">Code Highlighting</a></li><li class='Nav__item '><a href="../Examples/Hello_World.html">Hello World</a></li><li class='Nav__item '><a href="../Examples/Hello_World_de.html">Hallo Welt</a></li><li class='Nav__item '><a href="../Examples/привет_мир.html">привет мир</a></li><li class='Nav__item '><a href="../Examples/你好世界.html">你好世界</a></li></ul></li><li class='Nav__item has-children'><a href="../Configuration/index.html" class="folder"><i class="Nav__arrow">&nbsp;</i>Configuration</a><ul class='Nav'><li class='Nav__item '><a href="../Configuration/Confluence_upload.html">Confluence upload</a></li><li class='Nav__item '><a href="../Configuration/Html_export.html">Html export</a></li></ul></li><li class='Nav__item has-children'><a href="../For_Developers/Creating_a_Processor.html" class="folder"><i class="Nav__arrow">&nbsp;</i>For Developers</a><ul class='Nav'><li class='Nav__item '><a href="../For_Developers/Creating_a_Processor.html">Creating a Processor</a></li><li class='Nav__item '><a href="../For_Developers/Creating_a_Theme.html">Creating a Theme</a></li></ul></li></ul>
<div class="Links">
<hr/>
<a href="https://github.com/dauxio/daux.io/archive/master.zip" target="_blank">Download</a>
<br />
<a href="https://github.com/dauxio/daux.io" target="_blank">GitHub Repo</a>
<br />
<a href="https://github.com/dauxio/daux.io/issues" target="_blank">Help/Support/Bugs</a>
<br />
</div>
<div class="CodeToggler">
<hr/>
<span class="CodeToggler__text">Code blocks</span>
<div class="ButtonGroup" role="group">
<button class="Button Button--default Button--small CodeToggler__button CodeToggler__button--hide">No</button>
<button class="Button Button--default Button--small CodeToggler__button CodeToggler__button--below">Below</button>
<button class="Button Button--default Button--small CodeToggler__button CodeToggler__button--float">Inline</button>
</div>
</div>
<div class="Twitter">
<hr/>
<iframe allowtransparency="true" frameborder="0" scrolling="no" style="width:162px; height:20px;" src="https://platform.twitter.com/widgets/follow_button.html?screen_name=onigoetz&amp;show_count=false"></iframe>
<br />
<br />
</div>
<div class="PoweredBy">
<hr/>
Powered by Daux.io </div>
</div>
</aside>
<div class="Columns__right Columns__right--float">
<div class="Columns__right__content">
<div class="doc_content">
<article class="Page">
<div class="Page__header">
<h1><a href="../Examples/index.html">Examples</a> <svg class="Page__header--separator" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 477.175 477.175"><path d="M360.73 229.075l-225.1-225.1c-5.3-5.3-13.8-5.3-19.1 0s-5.3 13.8 0 19.1l215.5 215.5-215.5 215.5c-5.3 5.3-5.3 13.8 0 19.1 2.6 2.6 6.1 4 9.5 4 3.4 0 6.9-1.3 9.5-4l225.1-225.1c5.3-5.2 5.3-13.8.1-19z"/></svg> <a href="../Examples/Code_Highlighting.html">Code Highlighting</a></h1>
<span class="ModifiedDate">
Thursday, June 7, 2018 11:42 AM </span>
<span class="EditOn">
<a href="https://github.com/dauxio/daux.io/blob/master/docs/02_Examples/05_Code_Highlighting.md" target="_blank">
Edit on GitHub </a>
</span>
</div>
<div class="s-content">
<p>Highlight.js highlights syntax in code examples on blogs, forums and in fact on any web pages. It's very easy to use because it works automatically: finds blocks of code, detects a language, highlights it. <a href="https://highlightjs.org/" class="Link--external">Learn more.</a></p>
<p>You can even use <a href="../Features/CommonMark_compliant.html">Github Flavored Markdown</a></p>
<p><strong>Python</strong></p>
<pre><code>@requires_authorization
def somefunc(param1='', param2=0):
r'''A docstring'''
if param1 &gt; param2: # interesting
print 'Gre\'ater'
return (param2 - param1 + 1) or None
class SomeClass:&lt;br&gt; pass
&gt;&gt;&gt; message = '''interpreter
... prompt'''
</code></pre>
<p><strong>Python's profiler output</strong></p>
<pre><code> 261917242 function calls in 686.251 CPU seconds
ncalls tottime filename:lineno(function)
152824 513.894 {method 'sort' of 'list' objects}
129590630 83.894 rrule.py:842(__cmp__)
129590630 82.439 {cmp}
153900 1.296 rrule.py:399(_iter)
304393/151570 0.963 rrule.py:102(_iter_cached)
</code></pre>
<p><strong>Ruby</strong></p>
<pre><code>class A &lt; B; def self.create(object = User) object end end
class Zebra; def inspect; &quot;X#{2 + self.object_id}&quot; end end
module ABC::DEF
include Comparable
# @param test
# @return [String] nothing
def foo(test)
Thread.new do |blockvar|
ABC::DEF.reverse(:a_symbol, :'a symbol', :&lt;=&gt;, 'test' + test)
end.join
end
def [](index) self[index] end
def ==(other) other == self end
end
anIdentifier = an_identifier
Constant = 1
render action: :new
</code></pre>
<p><strong>Haml</strong></p>
<pre><code>!!! XML
%html
%body
%h1.jumbo{:id=&gt;&quot;a&quot;, :style=&gt;'font-weight: normal', :title=&gt;title} highlight.js
/html comment
-# ignore this line
%ul(style='margin: 0')
-items.each do |i|
%i= i
= variable
=variable2
~ variable3
~variable4
The current year is #{DataTime.now.year}.
</code></pre>
<p><strong>Perl</strong></p>
<pre><code># loads object
sub load
{
my $flds = $c-&gt;db_load($id,@_) || do {
Carp::carp &quot;Can`t load (class: $c, id: $id): '$!'&quot;; return undef
};
my $o = $c-&gt;_perl_new();
$id12 = $id / 24 / 3600;
$o-&gt;{'ID'} = $id12 + 123;
#$o-&gt;{'SHCUT'} = $flds-&gt;{'SHCUT'};
my $p = $o-&gt;props;
my $vt;
$string =~ m/^sought_text$/;
$items = split //, 'abc';
for my $key (keys %$p)
{
if(${$vt.'::property'}) {
$o-&gt;{$key . '_real'} = $flds-&gt;{$key};
tie $o-&gt;{$key}, 'CMSBuilder::Property', $o, $key;
}
}
$o-&gt;save if delete $o-&gt;{'_save_after_load'};
return $o;
}
=head1 NAME
POD till the end of file
</code></pre>
<p><strong>PHP</strong></p>
<pre><code>require_once 'Zend/Uri/Http.php';
abstract class URI extends BaseURI
{
/**
* Returns a URI
*
* @return URI
*/
static public function _factory($stats = array(), $uri = 'http')
{
$uri = explode(':', $uri, 0b10);
$schemeSpecific = isset($uri[1]) ? $uri[1] : '';
$desc = 'Multi
line description';
// Security check
if (!ctype_alnum($scheme)) {
throw new Zend_Uri_Exception('Illegal scheme');
}
return [
'uri' =&gt; $uri,
'value' =&gt; null,
];
}
}
__halt_compiler () ; datahere
datahere
datahere */
datahere
</code></pre>
<p><strong>Scala</strong></p>
<pre><code>object abstractTypes extends Application {
abstract class SeqBuffer {
type T; val element: Seq[T]; def length = element.length
}
}
/** Turn command line arguments to uppercase */
object Main {
def main(args: Array[String]) {
val res = for (a &lt;- args) yield a.toUpperCase
println(&quot;Arguments: &quot; + res.toString)
}
}
/** Maps are easy to use in Scala. */
object Maps {
val colors = Map(&quot;red&quot; -&gt; 0xFF0000,
&quot;turquoise&quot; -&gt; 0x00FFFF,
&quot;black&quot; -&gt; 0x000000,
&quot;orange&quot; -&gt; 0xFF8040,
&quot;brown&quot; -&gt; 0x804000)
def main(args: Array[String]) {
for (name &lt;- args) println(
colors.get(name) match {
case Some(code) =&gt;
name + &quot; has code: &quot; + code
case None =&gt;
&quot;Unknown color: &quot; + name
}
)
}
}
</code></pre>
<p><strong>Go</strong></p>
<pre><code>package main
import (
&quot;fmt&quot;
&quot;rand&quot;
&quot;os&quot;
)
const (
Sunday = iota
Partyday
numberOfDays // this constant is not exported
)
type Foo interface {
FooFunc(int, float32) (complex128, []int)
}
// simple comment
type Bar struct {
os.File /* multi
line
comment */
PublicData chan int
}
func main() {
ch := make(chan int)
ch &lt;- 1
x, ok := &lt;- ch
ok = true
x = nil
float_var := 1.0e10
defer fmt.Println('\'')
defer fmt.Println(`exitting now\`)
var fv1 float64 = 0.75
go println(len(&quot;hello world!&quot;))
return
}
</code></pre>
<p><strong>XML</strong></p>
<pre><code>&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;response value=&quot;ok&quot; xml:lang=&quot;en&quot;&gt;
&lt;text&gt;Ok&lt;/text&gt;
&lt;comment html_allowed=&quot;true&quot;/&gt;
&lt;ns1:description&gt;&lt;![CDATA[
CDATA is &lt;not&gt; magical.
]]&gt;&lt;/ns1:description&gt;
&lt;a&gt;&lt;/a&gt; &lt;a/&gt;
&lt;/response&gt;
</code></pre>
<p><strong>HTML (with inline css and javascript)</strong></p>
<pre><code>&lt;!DOCTYPE html&gt;
&lt;title&gt;Title&lt;/title&gt;
&lt;style&gt;body {width: 500px;}&lt;/style&gt;
&lt;script type=&quot;application/javascript&quot;&gt;
function $init() {return true;}
&lt;/script&gt;
&lt;body&gt;
&lt;p checked class=&quot;title&quot; id='title'&gt;Title&lt;/p&gt;
&lt;!-- here goes the rest of the page --&gt;
&lt;/body&gt;
</code></pre>
<p><strong>Lasso</strong></p>
<pre><code>&lt;?LassoScript
/* Lasso 8 */
local('query' = 'SELECT * FROM `'+var:'table'+'` WHERE `id` &gt; 10
ORDER BY `Name` LIMIT 30');
Inline: -Username=$DBuser, -Password=$DBpass, -Database=$DBname, -sql=#query;
var(&quot;class.name&quot; = (found_count != 0 ? `subtotal` | `nonefound`));
records;
output: ?&gt;&lt;tr&gt;[loop_count]&lt;/tr&gt;&lt;?=;
/records;
/Inline;
?&gt;&lt;div class=&quot;[$class.name]&quot;&gt;[found_count]&lt;/div&gt;
[noprocess] causes [delimiters] to be skipped until the next [/noprocess]
&lt;?lasso
/* Lasso 9 */
define strings_combine(value::string, ...other)::string =&gt; {
local(result = #value-&gt;append(#other-&gt;asString))
return #result
}
/**! descriptive text */
define person =&gt; type {
data name::string, protected nickname
data birthdate::date
data private ssn = null
public showName() =&gt; return .'name'
protected fullName() =&gt; '&quot;' + .nickname + '&quot;' + .'name'
public ssnListed =&gt; .ssn ? true | false
}
define person-&gt;name=(value) =&gt; {
.'name' = #value
return self-&gt;'name'
}
// query expression
with n in array(-1, 0xABCD, 3.14159e14)
let swapped = pair(#n-&gt;second, #n-&gt;first)
group #swapped by #n-&gt;first into t
let key = #t-&gt;key
order by #key
select pair(#key, #t)
do {^
#n-&gt;upperCase
^}
?&gt;
</code></pre>
<p><strong>Markdown</strong></p>
<pre><code># hello world
you can write text [with links](http://example.com).
* one _thing_ has *em*phasis
* two __things__ are **bold**
---
hello world
===========
&lt;this_is inline=&quot;xml&quot;&gt;&lt;/this_is&gt;
&gt; markdown is so cool
so are code segments
1. one thing (yeah!)
2. two thing `i can write code`, and `more` wipee!
</code></pre>
<p><strong>AsciiDoc</strong></p>
<pre><code>Hello, World!
============
Author Name, &lt;author@domain.foo&gt;
you can write text http://example.com[with links], optionally
using an explicit link:http://example.com[link prefix].
* single quotes around a phrase place 'emphasis'
** alternatively, you can put underlines around a phrase to add _emphasis_
* astericks around a phrase make the text *bold*
* pluses around a phrase make it +monospaced+
- escape characters are supported
- you can escape a quote inside emphasized text like 'here\'s johnny!'
term:: definition
another term:: another definition
// this is just a comment
Let's make a break.
'''
////
we'll be right with you
after this brief interruption.
////
== We're back!
Want to see a image::images/tiger.png[Tiger]?
.Nested highlighting
++++
&lt;this_is inline=&quot;xml&quot;&gt;&lt;/this_is&gt;
++++
____
asciidoc is so powerful.
____
another quote:
[quote, Sir Arthur Conan Doyle, The Adventures of Sherlock Holmes]
____
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
____
Getting Literal
---------------
want to get literal? prefix a line with a space.
....
I'll join that party, too.
....
. one thing (yeah!)
. two thing `i can write code`, and `more` wipee!
NOTE: AsciiDoc is quite cool, you should try it.
</code></pre>
<p><strong>Django templates</strong></p>
<pre><code>{% if articles|length %}
{% for article in articles %}
{# Striped table #}
&lt;tr class=&quot;{% cycle odd,even %}&quot;&gt;
&lt;td&gt;{{ article|default:&quot;Hi... &quot;|escape }}&lt;/td&gt;
&lt;td {% if article.today %}class=&quot;today&quot;{% endif %}&gt;{{ article.date|date:&quot;d.m.Y&quot; }}&lt;/td&gt;
&lt;/tr&gt;
{% endfor %}
{% endif %}
{% comment %}
Comments may be long and
multiline.
{% endcomment %}
</code></pre>
<p><strong>Handlebars</strong></p>
<pre><code>&lt;h3&gt;Hours&lt;/h3&gt;
&lt;ul&gt;
{{#each content.users}}
&lt;li {{bindAttr hello=&quot;world&quot;}}&gt;{{firstName}}&lt;/li&gt;
{{/each}}
&lt;/ul&gt;
</code></pre>
<p><strong>CSS</strong></p>
<pre><code>@media screen and (-webkit-min-device-pixel-ratio: 0) {
body:first-of-type pre::after {
content: 'highlight: ' attr(class);
}
body {
background: linear-gradient(45deg, blue, red);
}
}
@import url('print.css');
@page:right {
margin: 1cm 2cm 1.3cm 4cm;
}
@font-face {
font-family: Chunkfive; src: url('Chunkfive.otf');
}
div.text,
#content,
li[lang=ru] {
font: Tahoma, Chunkfive, sans-serif;
background: url('hatch.png') /* wtf? */; color: #F0F0F0 !important;
width: 100%;
}
</code></pre>
<p><strong>SCSS</strong></p>
<pre><code>@import &quot;compass/reset&quot;;
// variables
$colorGreen: #008000;
$colorGreenDark: darken($colorGreen, 10);
@mixin container {
max-width: 980px;
}
// mixins with parameters
@mixin button($color:green) {
@if ($color == green) {
background-color: #008000;
}
@else if ($color == red) {
background-color: #B22222;
}
}
button {
@include button(red);
}
div,
.navbar,
#header,
input[type=&quot;input&quot;] {
font-family: &quot;Helvetica Neue&quot;, Arial, sans-serif;
width: auto;
margin: 0 auto;
display: block;
}
.row-12 &gt; [class*=&quot;spans&quot;] {
border-left: 1px solid #B5C583;
}
// nested definitions
ul {
width: 100%;
padding: {
left: 5px; right: 5px;
}
li {
float: left; margin-right: 10px;
.home {
background: url('http://placehold.it/20') scroll no-repeat 0 0;
}
}
}
.banner {
@extend .container;
}
a {
color: $colorGreen;
&amp;:hover { color: $colorGreenDark; }
&amp;:visited { color: #c458cb; }
}
@for $i from 1 through 5 {
.span#{$i} {
width: 20px*$i;
}
}
@mixin mobile {
@media screen and (max-width : 600px) {
@content;
}
}
</code></pre>
<p><strong>JSON</strong></p>
<pre><code>[
{
&quot;title&quot;: &quot;apples&quot;,
&quot;count&quot;: [12000, 20000],
&quot;description&quot;: {&quot;text&quot;: &quot;...&quot;, &quot;sensitive&quot;: false}
},
{
&quot;title&quot;: &quot;oranges&quot;,
&quot;count&quot;: [17500, null],
&quot;description&quot;: {&quot;text&quot;: &quot;...&quot;, &quot;sensitive&quot;: false}
}
]
</code></pre>
<p><strong>JavaScript</strong></p>
<pre><code>function $initHighlight(block, flags) {
try {
if (block.className.search(/\bno\-highlight\b/) != -1)
return processBlock(block, true, 0x0F) + ' class=&quot;&quot;';
} catch (e) {
/* handle exception */
var e4x =
&lt;div&gt;Example
&lt;p&gt;1234&lt;/p&gt;&lt;/div&gt;;
}
for (var i = 0 / 2; i &lt; classes.length; i++) { // &quot;0 / 2&quot; should not be parsed as regexp
if (checkCondition(classes[i]) === undefined)
return /\d+[\s/]/g;
}
}
</code></pre>
<p><strong>CoffeeScript</strong></p>
<pre><code># Divisions
x = 6/foo/i
x = 6 /foo
x = 6 / foo
x = 6 /foo * 2/gm
x = f /foo
x = f / foo / gm
x = f /foo * 2/6
# Regexps
x = f /6 * 2/ - 3
x = f /foo * 2/gm
x = if true then /\n/ else /[.,]+/
grade = (student, period=(if b? then 7 else 6), messages={&quot;A&quot;: &quot;Excellent&quot;}) -&gt;
if student.excellentWork
&quot;A+&quot;
else if student.okayStuff
if student.triedHard then &quot;B&quot; else &quot;B-&quot;
else
&quot;C&quot;
square = (x) -&gt; x * x
two = -&gt; 2
math =
root: Math.sqrt
square: square
cube: (x) -&gt; x * square x
race = (winner, runners...) -&gt;
print winner, runners
class Animal extends Being
constructor: (@name) -&gt;
move: (meters) -&gt;
alert @name + &quot; moved #{meters}m.&quot;
hi = `function() {
return [document.title, &quot;Hello JavaScript&quot;].join(&quot;: &quot;);
}`
heredoc = &quot;&quot;&quot;
CoffeeScript subst test #{ 010 + 0xf / 0b10 + &quot;nested string #{ /\n/ }&quot;}
&quot;&quot;&quot;
###
CoffeeScript Compiler v1.2.0
Released under the MIT License
###
OPERATOR = /// ^ (
?: [-=]&gt; # function
) ///
</code></pre>
<p><strong>ActionScript</strong></p>
<pre><code>package org.example.dummy {
import org.dummy.*;
/*define package inline interface*/
public interface IFooBarzable {
public function foo(... pairs):Array;
}
public class FooBar implements IFooBarzable {
static private var cnt:uint = 0;
private var bar:String;
//constructor
public function TestBar(bar:String):void {
bar = bar;
++cnt;
}
public function foo(... pairs):Array {
pairs.push(bar);
return pairs;
}
}
}
</code></pre>
<p><strong>VB.NET</strong></p>
<pre><code>Import System
Import System.IO
#Const DEBUG = True
Namespace Highlighter.Test
''' &lt;summary&gt;This is an example class.&lt;/summary&gt;
Public Class Program
Protected Shared hello As Integer = 3
Private Const ABC As Boolean = False
#Region &quot;Code&quot;
' Cheers!
&lt;STAThread()&gt; _
Public Shared Sub Main(ByVal args() As String, ParamArray arr As Object) Handles Form1.Click
On Error Resume Next
If ABC Then
While ABC : Console.WriteLine() : End While
For i As Long = 0 To 1000 Step 123
Try
System.Windows.Forms.MessageBox.Show(CInt(&quot;1&quot;).ToString())
Catch ex As Exception ' What are you doing? Well...
Dim exp = CType(ex, IOException)
REM ORZ
Return
End Try
Next
Else
Dim l As New System.Collections.List&lt;String&gt;()
SyncLock l
If TypeOf l Is Decimal And l IsNot Nothing Then
RemoveHandler button1.Paint, delegate
End If
Dim d = New System.Threading.Thread(AddressOf ThreadProc)
Dim a = New Action(Sub(x, y) x + y)
Static u = From x As String In l Select x.Substring(2, 4) Where x.Length &gt; 0
End SyncLock
Do : Laugh() : Loop Until hello = 4
End If
End Sub
#End Region
End Class
End Namespace
</code></pre>
<p><strong>HTTP</strong></p>
<pre><code>POST /task?id=1 HTTP/1.1
Host: example.org
Content-Type: application/json; charset=utf-8
Content-Length: 19
{&quot;status&quot;: &quot;ok&quot;, &quot;extended&quot;: true}
</code></pre>
<p><strong>Lua</strong></p>
<pre><code>--[[
Simple signal/slot implementation
]]
local signal_mt = {
__index = {
register = table.insert
}
}
function signal_mt.__index:emit(... --[[ Comment in params ]])
for _, slot in ipairs(self) do
slot(self, ...)
end
end
local function create_signal()
return setmetatable({}, signal_mt)
end
-- Signal test
local signal = create_signal()
signal:register(function(signal, ...)
print(...)
end)
signal:emit('Answer to Life, the Universe, and Everything:', 42)
--[==[ [=[ [[
Nested ]]
multi-line ]=]
comment ]==]
[==[ Nested
[=[ multi-line
[[ string
]] ]=] ]==]
</code></pre>
<p><strong>AppleScript</strong></p>
<pre><code>repeat 5 times
if foo is greater than bar then
display dialog &quot;Hello there&quot;
else
beep
end if
end repeat
(* comment (*nested comment*) *)
on do_something(s, y)
return {s + pi, y mod 4}
end do_something
do shell script &quot;/bin/echo 'hello'&quot;
</code></pre>
<p><strong>Delphi</strong></p>
<pre><code>TList=Class(TObject)
Private
Some: String;
Public
Procedure Inside; // Suxx
End;{TList}
Procedure CopyFile(InFileName,var OutFileName:String);
Const
BufSize=4096; (* Huh? *)
Var
InFile,OutFile:TStream;
Buffer:Array[1..BufSize] Of Byte;
ReadBufSize:Integer;
Begin
InFile:=Nil;
OutFile:=Nil;
Try
InFile:=TFileStream.Create(InFileName,fmOpenRead);
OutFile:=TFileStream.Create(OutFileName,fmCreate);
Repeat
ReadBufSize:=InFile.Read(Buffer,BufSize);
OutFile.Write(Buffer,ReadBufSize);
Until ReadBufSize&lt;&gt;BufSize;
Log('File '''+InFileName+''' copied'#13#10);
Finally
InFile.Free;
OutFile.Free;
End;{Try}
End;{CopyFile}
</code></pre>
<p><strong>Java</strong></p>
<pre><code>/**
* @author John Smith &lt;john.smith@example.com&gt;
* @version 1.0
*/
package l2f.gameserver.model;
import java.util.ArrayList;
public abstract class L2Character extends L2Object {
public static final Short ABNORMAL_EFFECT_BLEEDING = 0x0001; // not sure
public void moveTo(int x, int y, int z) {
_ai = null;
_log.warning(&quot;Should not be called&quot;);
if (1 &gt; 5) {
return;
}
}
/** Task of AI notification */
@SuppressWarnings( { &quot;nls&quot;, &quot;unqualified-field-access&quot;, &quot;boxing&quot; })
public class NotifyAITask implements Runnable {
private final CtrlEvent _evt;
public void run() {
try {
getAI().notifyEvent(_evt, null, null);
} catch (Throwable t) {
t.printStackTrace();
}
}
}
}
</code></pre>
<p><strong>C++</strong></p>
<pre><code>#include &lt;iostream&gt;
int main(int argc, char *argv[]) {
/* An annoying &quot;Hello World&quot; example */
for (auto i = 0; i &lt; 0xFFFF; i++)
cout &lt;&lt; &quot;Hello, World!&quot; &lt;&lt; endl;
char c = '\n';
unordered_map &lt;string, vector&lt;string&gt; &gt; m;
m[&quot;key&quot;] = &quot;\\\\&quot;; // this is an error
return -2e3 + 12l;
}
</code></pre>
<p><strong>Objective C</strong></p>
<pre><code>#import &lt;UIKit/UIKit.h&gt;
#import &quot;Dependency.h&quot;
@protocol WorldDataSource
@optional
- (NSString*)worldName;
@required
- (BOOL)allowsToLive;
@end
@interface Test : NSObject &lt;HelloDelegate, WorldDataSource&gt; {
NSString *_greeting;
}
@property (nonatomic, readonly) NSString *greeting;
- (IBAction) show;
@end
@implementation Test
@synthesize test=_test;
+ (id) test {
return [self testWithGreeting:@&quot;Hello, world!\nFoo bar!&quot;];
}
+ (id) testWithGreeting:(NSString*)greeting {
return [[[self alloc] initWithGreeting:greeting] autorelease];
}
- (id) initWithGreeting:(NSString*)greeting {
if ( (self = [super init]) ) {
_greeting = [greeting retain];
}
return self;
}
- (void) dealloc {
[_greeting release];
[super dealloc];
}
@end
</code></pre>
<p><strong>Vala</strong></p>
<pre><code>using DBus;
namespace Test {
class Foo : Object {
public signal void some_event (); // definition of the signal
public void method () {
some_event (); // emitting the signal (callbacks get invoked)
}
}
}
/* defining a class */
class Track : GLib.Object, Test.Foo { /* subclassing 'GLib.Object' */
public double mass; /* a public field */
public double name { get; set; } /* a public property */
private bool terminated = false; /* a private field */
public void terminate() { /* a public method */
terminated = true;
}
}
const ALL_UPPER_CASE = &quot;you should follow this convention&quot;;
var t = new Track(); // same as: Track t = new Track();
var s = &quot;hello&quot;; // same as: string s = &quot;hello&quot;;
var l = new List&lt;int&gt;(); // same as: List&lt;int&gt; l = new List&lt;int&gt;();
var i = 10; // same as: int i = 10;
#if (ololo)
Regex regex = /foo/;
#endif
/*
* Entry point can be outside class
*/
void main () {
var long_string = &quot;&quot;&quot;
Example of &quot;verbatim string&quot;.
Same as in @&quot;string&quot; in C#
&quot;&quot;&quot;
var foo = new Foo ();
foo.some_event.connect (callback_a); // connecting the callback functions
foo.some_event.connect (callback_b);
foo.method ();
}
</code></pre>
<p><strong>C</strong></p>
<pre><code>using System;
#pragma warning disable 414, 3021
public class Program
{
/// &lt;summary&gt;The entry point to the program.&lt;/summary&gt;
public static int Main(string[] args)
{
Console.WriteLine(&quot;Hello, World!&quot;);
string s = @&quot;This
&quot;&quot;string&quot;&quot;
spans
multiple
lines!&quot;;
return 0;
}
}
async Task&lt;int&gt; AccessTheWebAsync()
{
// ...
string urlContents = await getStringTask;
return urlContents.Length;
}
</code></pre>
<p><strong>F</strong></p>
<pre><code>open System
// Single line comment...
(*
This is a
multiline comment.
*)
let checkList alist =
match alist with
| [] -&gt; 0
| [a] -&gt; 1
| [a; b] -&gt; 2
| [a; b; c] -&gt; 3
| _ -&gt; failwith &quot;List is too big!&quot;
type IEncoding =
abstract Encode : string -&gt; string
abstract Decode : string -&gt; string
let text = &quot;Some text...&quot;
let text2 = @&quot;A &quot;&quot;verbatim&quot;&quot; string...&quot;
let catalog = &quot;&quot;&quot;
Some &quot;long&quot; string...
&quot;&quot;&quot;
let rec fib x = if x &lt;= 2 then 1 else fib(x-1) + fib(x-2)
let fibs =
Async.Parallel [ for i in 0..40 -&gt; async { return fib(i) } ]
|&gt; Async.RunSynchronously
type Sprocket(gears) =
member this.Gears : int = gears
[&lt;AbstractClass&gt;]
type Animal =
abstract Speak : unit -&gt; unit
type Widget =
| RedWidget
| GreenWidget
type Point = {X: float; Y: float;}
[&lt;Measure&gt;]
type s
let minutte = 60&lt;s&gt;
</code></pre>
<p><strong>D</strong></p>
<pre><code>#!/usr/bin/rdmd
// Computes average line length for standard input.
import std.stdio;
/+
this is a /+ nesting +/ comment
+/
enum COMPILED_ON = __TIMESTAMP__; // special token
enum character = '©';
enum copy_valid = '&amp;copy;';
enum backslash_escaped = '\\';
// string literals
enum str = `hello &quot;world&quot;!`;
enum multiline = r&quot;lorem
ipsum
dolor&quot;; // wysiwyg string, no escapes here allowed
enum multiline2 = &quot;sit
amet
\&quot;adipiscing\&quot;
elit.&quot;;
enum hex = x&quot;66 6f 6f&quot;; // same as &quot;foo&quot;
#line 5
// float literals
enum f = [3.14f, .1, 1., 1e100, 0xc0de.01p+100];
static if (something == true) {
import std.algorithm;
}
void main() pure nothrow @safe {
ulong lines = 0;
double sumLength = 0;
foreach (line; stdin.byLine()) {
++lines;
sumLength += line.length;
}
writeln(&quot;Average line length: &quot;,
lines ? sumLength / lines : 0);
}
</code></pre>
<p><strong>RenderMan RSL</strong></p>
<pre><code>#define TEST_DEFINE 3.14
/* plastic surface shader
*
* Pixie is:
* (c) Copyright 1999-2003 Okan Arikan. All rights reserved.
*/
surface plastic (float Ka = 1, Kd = 0.5, Ks = 0.5, roughness = 0.1;
color specularcolor = 1;) {
normal Nf = faceforward (normalize(N),I);
Ci = Cs * (Ka*ambient() + Kd*diffuse(Nf)) + specularcolor * Ks *
specular(Nf,-normalize(I),roughness);
Oi = Os;
Ci *= Oi;
}
</code></pre>
<p><strong>RenderMan RIB</strong></p>
<pre><code>FrameBegin 0
Display &quot;Scene&quot; &quot;framebuffer&quot; &quot;rgb&quot;
Option &quot;searchpath&quot; &quot;shader&quot; &quot;+&amp;:/home/kew&quot;
Option &quot;trace&quot; &quot;int maxdepth&quot; [4]
Attribute &quot;visibility&quot; &quot;trace&quot; [1]
Attribute &quot;irradiance&quot; &quot;maxerror&quot; [0.1]
Attribute &quot;visibility&quot; &quot;transmission&quot; &quot;opaque&quot;
Format 640 480 1.0
ShadingRate 2
PixelFilter &quot;catmull-rom&quot; 1 1
PixelSamples 4 4
Projection &quot;perspective&quot; &quot;fov&quot; 49.5502811377
Scale 1 1 -1
WorldBegin
ReadArchive &quot;Lamp.002_Light/instance.rib&quot;
Surface &quot;plastic&quot;
ReadArchive &quot;Cube.004_Mesh/instance.rib&quot;
# ReadArchive &quot;Sphere.010_Mesh/instance.rib&quot;
# ReadArchive &quot;Sphere.009_Mesh/instance.rib&quot;
ReadArchive &quot;Sphere.006_Mesh/instance.rib&quot;
WorldEnd
FrameEnd
</code></pre>
<p><strong>MEL (Maya Embedded Language)</strong></p>
<pre><code>proc string[] getSelectedLights()
{
string $selectedLights[];
string $select[] = `ls -sl -dag -leaf`;
for ( $shape in $select )
{
// Determine if this is a light.
//
string $class[] = getClassification( `nodeType $shape` );
if ( ( `size $class` ) &gt; 0 &amp;&amp; ( &quot;light&quot; == $class[0] ) )
{
$selectedLights[ `size $selectedLights` ] = $shape;
}
}
// Result is an array of all lights included in
// current selection list.
return $selectedLights;
}
</code></pre>
<p><strong>GLSL</strong></p>
<pre><code>// vertex shader
#version 150
in vec2 in_Position;
in vec3 in_Color;
out vec3 ex_Color;
void main(void) {
gl_Position = vec4(in_Position.x, in_Position.y, 0.0, 1.0);
ex_Color = in_Color;
}
// geometry shader
#version 150
layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;
void main() {
for(int i = 0; i &lt; gl_in.length(); i++) {
gl_Position = gl_in[i].gl_Position;
EmitVertex();
}
EndPrimitive();
}
// fragment shader
#version 150
precision highp float;
in vec3 ex_Color;
out vec4 gl_FragColor;
void main(void) {
gl_FragColor = vec4(ex_Color, 1.0);
}
</code></pre>
<p><strong>SQL</strong></p>
<pre><code>BEGIN;
CREATE TABLE &quot;topic&quot; (
&quot;id&quot; serial NOT NULL PRIMARY KEY,
&quot;forum_id&quot; integer NOT NULL,
&quot;subject&quot; varchar(255) NOT NULL
);
ALTER TABLE &quot;topic&quot; ADD CONSTRAINT forum_id FOREIGN KEY (&quot;forum_id&quot;) REFERENCES &quot;forum&quot; (&quot;id&quot;);
-- Initials
insert into &quot;topic&quot; (&quot;forum_id&quot;, &quot;subject&quot;) values (2, 'D''artagnian');
select count(*) from cicero_forum;
-- this line lacks ; at the end to allow people to be sloppy and omit it in one-liners
COMMIT
</code></pre>
<p><strong>SmallTalk</strong></p>
<pre><code>Object&gt;&gt;method: num
&quot;comment 123&quot;
| var1 var2 |
(1 to: num) do: [:i | |var| ^i].
Klass with: var1.
Klass new.
arr := #('123' 123.345 #hello Transcript var $@).
arr := #().
var2 = arr at: 3.
^ self abc
heapExample
&quot;HeapTest new heapExample&quot;
&quot;Multiline
decription&quot;
| n rnd array time sorted |
n := 5000.
&quot;# of elements to sort&quot;
rnd := Random new.
array := (1 to: n)
collect: [:i | rnd next].
&quot;First, the heap version&quot;
time := Time
millisecondsToRun: [sorted := Heap withAll: array.
1
to: n
do: [:i |
sorted removeFirst.
sorted add: rnd next]].
Transcript cr; show: 'Time for Heap: ' , time printString , ' msecs'.
&quot;The quicksort version&quot;
time := Time
millisecondsToRun: [sorted := SortedCollection withAll: array.
1
to: n
do: [:i |
sorted removeFirst.
sorted add: rnd next]].
Transcript cr; show: 'Time for SortedCollection: ' , time printString , ' msecs'
</code></pre>
<p><strong>Lisp</strong></p>
<pre><code>#!/usr/bin/env csi
(defun prompt-for-cd ()
&quot;Prompts
for CD&quot;
(prompt-read &quot;Title&quot; 1.53 1 2/4 1.7 1.7e0 2.9E-4 +42 -7 #b001 #b001/100 #o777 #O777 #xabc55 #c(0 -5.6))
(prompt-read &quot;Artist&quot; &amp;rest)
(or (parse-integer (prompt-read &quot;Rating&quot;) :junk-allowed t) 0)
(if x (format t &quot;yes&quot;) (format t &quot;no&quot; nil) ;and here comment
)
;; second line comment
'(+ 1 2)
(defvar *lines*) ; list of all lines
(position-if-not #'sys::whitespacep line :start beg))
(quote (privet 1 2 3))
'(hello world)
(* 5 7)
(1 2 34 5)
(:use &quot;aaaa&quot;)
(let ((x 10) (y 20))
(print (+ x y))
)
</code></pre>
<p><strong>Clojure</strong></p>
<pre><code>; You must not remove this notice, or any other, from this software.
(ns ^{:doc &quot;The core Clojure language.&quot;
:author &quot;Rich Hickey&quot;}
clojure.core)
(def unquote)
(def
^{:macro true
:added &quot;1.0&quot;}
let (fn* let [&amp;form &amp;env &amp; decl] (cons 'let* decl)))
(def
defn (fn defn [&amp;form &amp;env name &amp; fdecl]
(let [m (conj {:arglists (list 'quote (sigs fdecl))} m)
m (let [inline (:inline m)
ifn (first inline)
iname (second inline)]
;; same as: (if (and (= 'fn ifn) (not (symbol? iname))) ...)
(if (if (clojure.lang.Util/equiv 'fn ifn)
(if (instance? clojure.lang.Symbol iname) false true))
;; inserts the same fn name to the inline fn if it does not have one
(assoc m :inline (cons ifn (cons (clojure.lang.Symbol/intern (.concat (.getName ^clojure.lang.Symbol name) &quot;__inliner&quot;))
(next inline))))
m))
m (conj (if (meta name) (meta name) {}) m)]
(list 'def (with-meta name m)
;;todo - restore propagation of fn name
;;must figure out how to convey primitive hints to self calls first
(cons `fn fdecl) ))))
(. (var defn) (setMacro))
</code></pre>
<p><strong>Ini file</strong></p>
<pre><code>;Settings relating to the location and loading of the database
[Database]
ProfileDir=.
ShowProfileMgr=smart
Profile1_Name[] = &quot;\|/_-=MegaDestoyer=-_\|/&quot;
DefaultProfile=True
AutoCreate = no
[AutoExec]
use-prompt=&quot;prompt&quot;
Glob=autoexec_*.ini
AskAboutIgnoredPlugins=0
</code></pre>
<p><strong>Apache</strong></p>
<pre><code># rewrite`s rules for wordpress pretty url
LoadModule rewrite_module modules/mod_rewrite.so
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [NC,L]
ExpiresActive On
ExpiresByType application/x-javascript &quot;access plus 1 days&quot;
&lt;Location /maps/&gt;
RewriteMap map txt:map.txt
RewriteMap lower int:tolower
RewriteCond %{REQUEST_URI} ^/([^/.]+)\.html$ [NC]
RewriteCond ${map:${lower:%1}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /index.php?q=${map:${lower:%1}} [NC,L]
&lt;/Location&gt;
</code></pre>
<p><strong>nginx</strong></p>
<pre><code>user www www;
worker_processes 2;
pid /var/run/nginx.pid;
error_log /var/log/nginx.error_log debug | info | notice | warn | error | crit;
events {
connections 2000;
use kqueue | rtsig | epoll | /dev/poll | select | poll;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] '
'&quot;$request&quot; $status $bytes_sent '
'&quot;$http_referer&quot; &quot;$http_user_agent&quot; '
'&quot;$gzip_ratio&quot;';
send_timeout 3m;
client_header_buffer_size 1k;
gzip on;
gzip_min_length 1100;
#lingering_time 30;
server {
server_name one.example.com www.one.example.com;
access_log /var/log/nginx.access_log main;
rewrite (.*) /index.php?page=$1 break;
location / {
proxy_pass http://127.0.0.1/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
charset koi8-r;
}
location /api/ {
fastcgi_pass 127.0.0.1:9000;
}
location ~* \.(jpg|jpeg|gif)$ {
root /spool/www;
}
}
}
</code></pre>
<p><strong>Diff</strong></p>
<pre><code>Index: languages/ini.js
===================================================================
--- languages/ini.js (revision 199)
+++ languages/ini.js (revision 200)
@@ -1,8 +1,7 @@
hljs.LANGUAGES.ini =
{
case_insensitive: true,
- defaultMode:
- {
+ defaultMode: {
contains: ['comment', 'title', 'setting'],
illegal: '[^\\s]'
},
*** /path/to/original timestamp
--- /path/to/new timestamp
***************
*** 1,3 ****
--- 1,9 ----
+ This is an important
+ notice! It should
+ therefore be located at
+ the beginning of this
+ document!
! compress the size of the
! changes.
It is important to spell
</code></pre>
<p><strong>DOS batch files</strong></p>
<pre><code>cd \
copy a b
ping 192.168.0.1
@rem ping 192.168.0.1
net stop sharedaccess
del %tmp% /f /s /q
del %temp% /f /s /q
ipconfig /flushdns
taskkill /F /IM JAVA.EXE /T
cd Photoshop/Adobe Photoshop CS3/AMT/
if exist application.sif (
ren application.sif _application.sif
) else (
ren _application.sif application.sif
)
taskkill /F /IM proquota.exe /T
sfc /SCANNOW
set path = test
xcopy %1\*.* %2
</code></pre>
<p><strong>Bash</strong></p>
<pre><code>#!/bin/bash
###### BEGIN CONFIG
ACCEPTED_HOSTS=&quot;/root/.hag_accepted.conf&quot;
BE_VERBOSE=false
###### END CONFIG
if [ &quot;$UID&quot; -ne 0 ]
then
echo &quot;Superuser rights is required&quot;
echo 'Printing the # sign'
exit 2
fi
if test $# -eq 0
then
elif test [ $1 == 'start' ]
else
fi
genApacheConf(){
if [[ &quot;$2&quot; = &quot;www&quot; ]]
then
full_domain=$1
else
full_domain=$2.$1
fi
host_root=&quot;${APACHE_HOME_DIR}$1/$2/$(title)&quot;
echo -e &quot;# Host $1/$2 :&quot;
}
</code></pre>
<p><strong>CMake</strong></p>
<pre><code>project(test)
cmake_minimum_required(VERSION 2.6)
# IF LINUX
if (${CMAKE_SYSTEM_NAME} MATCHES Linux)
message(&quot;\nOS:\t\tLinux&quot;)
endif()
# IF WINDOWS
if (${CMAKE_SYSTEM_NAME} MATCHES Windows)
message(&quot;\nOS:\t\tWindows&quot;)
endif()
set(test test0.cpp test1.cpp test2.cpp)
include_directories(./)
set(EXECUTABLE_OUTPUT_PATH ../bin)
add_subdirectory(src)
add_executable(test WIN32 ${test})
target_link_libraries(test msimg32)
</code></pre>
<p><strong>Axapta</strong></p>
<pre><code>class ExchRateLoadBatch extends RunBaseBatch {
ExchRateLoad rbc;
container currencies;
boolean actual;
boolean overwrite;
date beg;
date end;
#define.CurrentVersion(5)
#localmacro.CurrentList
currencies,
actual,
beg,
end
#endmacro
}
public boolean unpack(container packedClass) {
container base;
boolean ret;
Integer version = runbase::getVersion(packedClass);
switch (version) {
case #CurrentVersion:
[version, #CurrentList] = packedClass;
return true;
default:
return false;
}
return ret;
}
</code></pre>
<p><strong>Oracle Rules Language</strong></p>
<pre><code>//This is a comment
ABORT &quot;You experienced an abort.&quot;;
WARN &quot;THIS IS A WARNING&quot;;
CALL &quot;RIDER_X&quot;;
DONE;
FOR EACH X IN CSV_FILE &quot;d:\lodestar\user\d377.lse&quot;
LEAVE FOR;
END FOR;
IF ((BILL_KW = 0) AND (KW &gt; 0)) THEN
END IF;
INCLUDE &quot;R1&quot;;
LEAVE RIDER;
SELECT BILL_PERIOD
WHEN &quot;WINTER&quot;
BLOCK KWH
FROM 0 TO 400 CHARGE $0.03709
FROM 400 CHARGE $0.03000
TOTAL $ENERGY_CHARGE_WIN;
WHEN &quot;SUMMER&quot;
$VOLTAGE_DISCOUNT_SUM = $0.00
OTHERWISE
$VOLTAGE_DISCOUNT_SUM = $1.00
END SELECT;
/* Report top five peaks */
LABEL PK.NM &quot;Peak Number&quot;;
SAVE_UPDATE MV TO TABLE &quot;METERVALUE&quot;;
FOR EACH INX IN ARRAYUPPERBOUND(#MYARRAY[])
#MYARRAY[INX].VALUE = 2;
CLEAR #MYARRAY[];
END FOR
//Interval Data
HNDL_1_ADD_EDI = INTDADDATTRIBUTE(HNDL_1, &quot;EDI_TRANSACTION&quot;, EDI_ID);
HNDL_1_ADD_VAL_MSG = INTDADDVMSG(HNDL_1,&quot;Missing (Status Code 9) values found&quot;);
EMPTY_HNDL = INTDCREATEHANDLE('05/03/2006 00:00:00', '05/03/2006 23:59:59', 3600, &quot;Y&quot;, &quot;0&quot;, &quot; &quot;);
</code></pre>
<p><strong>1С</strong></p>
<pre><code>#Если Клиент Тогда
Перем СимвольныйКодКаталога = &quot;ля-ля-ля&quot;; //комментарий
Функция Сообщить(Знач ТекстСообщения, ТекстСообщения2) Экспорт //комментарий к функции
x=ТекстСообщения+ТекстСообщения2+&quot;
|строка1
|строка2
|строка3&quot;;
КонецФункции
#КонецЕсли
// Процедура ПриНачалеРаботыСистемы
//
Процедура ПриНачалеРаботыСистемы()
Обработки.Помощник.ПолучитьФорму(&quot;Форма&quot;).Открыть();
d = '21.01.2008'
КонецПроцедуры
</code></pre>
<p><strong>AVR Assembler</strong></p>
<pre><code>;* Title: Block Copy Routines
;* Version: 1.1
.include &quot;8515def.inc&quot;
rjmp RESET ;reset handle
.def flashsize=r16 ;size of block to be copied
flash2ram:
lpm ;get constant
st Y+,r0 ;store in SRAM and increment Y-pointer
adiw ZL,1 ;increment Z-pointer
dec flashsize
brne flash2ram ;if not end of table, loop more
ret
.def ramtemp =r1 ;temporary storage register
.def ramsize =r16 ;size of block to be copied
</code></pre>
<p><strong>VHDL</strong></p>
<pre><code> /*
* RS-trigger with assynch. reset
*/
library ieee;
use ieee.std_logic_1164.all;
entity RS_trigger is
generic (T: Time := 0ns);
port ( R, S : in std_logic;
Q, nQ : out std_logic;
reset, clock : in std_logic );
end RS_trigger;
architecture behaviour of RS_trigger is
signal QT: std_logic; -- Q(t)
begin
process(clock, reset) is
subtype RS is std_logic_vector (1 downto 0);
begin
if reset = '0' then
QT &lt;= '0';
else
if rising_edge(C) then
if not (R'stable(T) and S'stable(T)) then
QT &lt;= 'X';
else
case RS'(R&amp;S) is
when &quot;01&quot; =&gt; QT &lt;= '1';
when &quot;10&quot; =&gt; QT &lt;= '0';
when &quot;11&quot; =&gt; QT &lt;= 'X';
when others =&gt; null;
end case;
end if;
end if;
end if;
end process;
Q &lt;= QT;
nQ &lt;= not QT;
end architecture behaviour;
</code></pre>
<p><strong>Parser 3</strong></p>
<pre><code>@CLASS
base
@USE
module.p
@BASE
class
# Comment for code
@create[aParam1;aParam2][local1;local2]
^connect[mysql://host/database?ClientCharset=windows-1251]
^for[i](1;10){
&lt;p class=&quot;paragraph&quot;&gt;^eval($i+10)&lt;/p&gt;
^connect[mysql://host/database]{
$tab[^table::sql{select * from `table` where a='1'}]
$var_Name[some${value}]
}
}
^rem{
Multiline comment with code: $var
^while(true){
^for[i](1;10){
^sleep[]
}
}
}
^taint[^#0A]
@GET_base[]
## Comment for code
# Isn't comment
$result[$.hash_item1[one] $.hash_item2[two]]
</code></pre>
<p><strong>TeX</strong></p>
<pre><code>\documentclass{article}
\usepackage[koi8-r]{inputenc}
\hoffset=0pt
\voffset=.3em
\tolerance=400
\newcommand{\eTiX}{\TeX}
\begin{document}
\section*{Highlight.js}
\begin{table}[c|c]
$\frac 12\, + \, \frac 1{x^3}\text{Hello \! world}$ &amp; \textbf{Goodbye\~ world} \\\eTiX $ \pi=400 $
\end{table}
Ch\'erie, \c{c}a ne me pla\^\i t pas! % comment \b
G\&quot;otterd\&quot;ammerung~45\%=34.
$$
\int\limits_{0}^{\pi}\frac{4}{x-7}=3
$$
\end{document}
</code></pre>
<p><strong>Haskell</strong></p>
<pre><code>{-# LANGUAGE TypeSynonymInstances #-}
module Network.UDP
( DataPacket(..)
, openBoundUDPPort
, openListeningUDPPort
, pingUDPPort
, sendUDPPacketTo
, recvUDPPacket
, recvUDPPacketFrom
) where
{- this is a {- nested -} comment -}
import qualified Data.ByteString as Strict (ByteString, concat, singleton)
import qualified Data.ByteString.Lazy as Lazy (ByteString, toChunks, fromChunks)
import Data.ByteString.Char8 (pack, unpack)
import Network.Socket hiding (sendTo, recv, recvFrom)
import Network.Socket.ByteString (sendTo, recv, recvFrom)
-- Type class for converting StringLike types to and from strict ByteStrings
class DataPacket a where
toStrictBS :: a -&gt; Strict.ByteString
fromStrictBS :: Strict.ByteString -&gt; a
instance DataPacket Strict.ByteString where
toStrictBS = id
{-# INLINE toStrictBS #-}
fromStrictBS = id
{-# INLINE fromStrictBS #-}
openBoundUDPPort :: String -&gt; Int -&gt; IO Socket
openBoundUDPPort uri port = do
s &lt;- getUDPSocket
bindAddr &lt;- inet_addr uri
let a = SockAddrInet (toEnum port) bindAddr
bindSocket s a
return s
pingUDPPort :: Socket -&gt; SockAddr -&gt; IO ()
pingUDPPort s a = sendTo s (Strict.singleton 0) a &gt;&gt; return ()
</code></pre>
<p><strong>Erlang</strong></p>
<pre><code>-module(ssh_cli).
-behaviour(ssh_channel).
-include(&quot;ssh.hrl&quot;).
%% backwards compatibility
-export([listen/1, listen/2, listen/3, listen/4, stop/1]).
%% state
-record(state, {
cm,
channel
}).
test(Foo)-&gt;Foo.
init([Shell, Exec]) -&gt;
{ok, #state{shell = Shell, exec = Exec}};
init([Shell]) -&gt;
false = not true,
io:format(&quot;Hello, \&quot;~p!~n&quot;, [atom_to_list('World')]),
{ok, #state{shell = Shell}}.
concat([Single]) -&gt; Single;
concat(RList) -&gt;
EpsilonFree = lists:filter(
fun (Element) -&gt;
case Element of
epsilon -&gt; false;
_ -&gt; true
end
end,
RList),
case EpsilonFree of
[Single] -&gt; Single;
Other -&gt; {concat, Other}
end.
union_dot_union({union, _}=U1, {union, _}=U2) -&gt;
union(lists:flatten(
lists:map(
fun (X1) -&gt;
lists:map(
fun (X2) -&gt;
concat([X1, X2])
end,
union_to_list(U2)
)
end,
union_to_list(U1)
))).
</code></pre>
<p><strong>Erlang REPL</strong></p>
<pre><code>1&gt; Str = &quot;abcd&quot;.
&quot;abcd&quot;
2&gt; L = test:length(Str).
4
3&gt; Descriptor = {L, list_to_atom(Str)}.
{4,abcd}
4&gt; L.
4
5&gt; b().
Descriptor = {4,abcd}
L = 4
Str = &quot;abcd&quot;
ok
6&gt; f(L).
ok
7&gt; b().
Descriptor = {4,abcd}
Str = &quot;abcd&quot;
ok
8&gt; {L, _} = Descriptor.
{4,abcd}
9&gt; L.
4
10&gt; 2#101.
5
11&gt; 1.85e+3.
1850
</code></pre>
<p><strong>Rust</strong></p>
<pre><code>use std;
import std::io;
export fac, test1;
123; // type int
123u; // type uint
123_u; // type uint
0xff00; // type int
0xff_u8; // type u8
0b1111_1111_1001_0000_i32; // type i32
123.0; // type float
0.1; // type float
3f; // type float
0.1f32; // type f32
12E+99_f64; // type f64
/* Factorial */
fn fac(n: int) -&gt; int {
let s: str = &quot;This is
a multi-line string.
It ends with an unescaped '\&quot;'.&quot;;
let c: char = 'Ф';
let result = 1, i = 1;
while i &lt;= n { // No parens around the condition
result *= i;
i += 1;
}
ret result;
}
pure fn pure_length&lt;T&gt;(ls: list&lt;T&gt;) -&gt; uint { /* ... */ }
type t = map::hashtbl&lt;int,str&gt;;
let x = id::&lt;int&gt;(10);
// Define some modules.
#[path = &quot;foo.rs&quot;]
mod foo;
iface seq&lt;T&gt; {
fn len() -&gt; uint;
}
impl &lt;T&gt; of seq&lt;T&gt; for [T] {
fn len() -&gt; uint { vec::len(self) }
fn iter(b: fn(T)) {
for elt in self { b(elt); }
}
}
enum list&lt;T&gt; {
nil;
cons(T, @list&lt;T&gt;);
}
let a: list&lt;int&gt; = cons(7, @cons(13, @nil));
</code></pre>
<p><strong>Matlab</strong></p>
<pre><code>n = 20; % number of points
points = [random('unid', 100, n, 1), random('unid', 100, n, 1)];
len = zeros(1, n - 1);
points = sortrows(points);
%% Initial set of points
plot(points(:,1),points(:,2));
for i = 1: n-1
len(i) = points(i + 1, 1) - points(i, 1);
end
while(max(len) &gt; 2 * min(len))
[d, i] = max(len);
k = on_margin(points, i, d, -1);
m = on_margin(points, i + 1, d, 1);
xm = 0; ym = 0;
%% New point
if(i == 1 || i + 1 == n)
xm = mean(points([i,i+1],1))
ym = mean(points([i,i+1],2))
else
[xm, ym] = dlg1(points([k, i, i + 1, m], 1), ...
points([k, i, i + 1, m], 2))
end
points = [ points(1:i, :); [xm, ym]; points(i + 1:end, :)];
end
function [net] = get_fit_network(inputs, targets)
% Create Network
numHiddenNeurons = 20; % Adjust as desired
net = newfit(inputs,targets,numHiddenNeurons);
net.trainParam.goal = 0.01;
net.trainParam.epochs = 1000;
% Train and Apply Network
[net,tr] = train(net,inputs,targets);
end
foo_matrix = [1, 2, 3; 4, 5, 6]''';
foo_cell = {1, 2, 3; 4, 5, 6}''.'.';
</code></pre>
<p><strong>R</strong></p>
<pre><code>library(ggplot2)
centre &lt;- function(x, type, ...) {
switch(type,
mean = mean(x),
median = median(x),
trimmed = mean(x, trim = .1))
}
myVar1
myVar.2
data$x
foo &quot;bar&quot; baz
# test &quot;test&quot;
&quot;test # test&quot;
(123) (1) (10) (0.1) (.2) (1e-7)
(1.2e+7) (2e) (3e+10) (0x0) (0xa)
(0xabcdef1234567890) (123L) (1L)
(0x10L) (10000000L) (1e6L) (1.1L)
(1e-3L) (4123.381E-10i)
(3.) (3.E10) # BUG: .E10 should be part of number
# Numbers in some different contexts
1L
0x40
.234
3.
1L + 30
plot(cars, xlim=20)
plot(cars, xlim=0x20)
foo&lt;-30
my.data.3 &lt;- read() # not a number
c(1,2,3)
1%%2
&quot;this is a quote that spans
multiple lines
\&quot;
is this still a quote? it should be.
# even still!
&quot; # now we're done.
'same for
single quotes #'
# keywords
NULL, NA, TRUE, FALSE, Inf, NaN, NA_integer_,
NA_real_, NA_character_, NA_complex_, function,
while, repeat, for, if, in, else, next, break,
..., ..1, ..2
# not keywords
the quick brown fox jumped over the lazy dogs
null na true false inf nan na_integer_ na_real_
na_character_ na_complex_ Function While Repeat
For If In Else Next Break .. .... &quot;NULL&quot; `NULL` 'NULL'
# operators
+, -, *, /, %%, ^, &gt;, &gt;=, &lt;, &lt;=, ==, !=, !, &amp;, |, ~,
-&gt;, &lt;-, &lt;&lt;-, $, :, ::
# infix operator
foo %union% bar
%&quot;test&quot;%
`&quot;test&quot;`
</code></pre>
<p><strong>Mizar</strong></p>
<pre><code>::: ## Lambda calculus
environ
vocabularies LAMBDA,
NUMBERS,
NAT_1, XBOOLE_0, SUBSET_1, FINSEQ_1, XXREAL_0, CARD_1,
ARYTM_1, ARYTM_3, TARSKI, RELAT_1, ORDINAL4, FUNCOP_1;
:: etc...
begin
reserve D for DecoratedTree,
p,q,r for FinSequence of NAT,
x for set;
definition
let D;
attr D is LambdaTerm-like means
(dom D qua Tree) is finite &amp;
::&gt; *143,306
for r st r in dom D holds
r is FinSequence of {0,1} &amp;
r^&lt;*0*&gt; in dom D implies D.r = 0;
end;
registration
cluster LambdaTerm-like for DecoratedTree of NAT;
existence;
::&gt; *4
end;
definition
mode LambdaTerm is LambdaTerm-like DecoratedTree of NAT;
end;
::: Then we extend this ordinary one-step beta reduction, that is,
::: any subterm is also allowed to reduce.
definition
let M,N;
pred M beta N means
ex p st
M|p beta_shallow N|p &amp;
for q st not p is_a_prefix_of q holds
[r,x] in M iff [r,x] in N;
end;
theorem Th4:
ProperPrefixes (v^&lt;*x*&gt;) = ProperPrefixes v \/ {v}
proof
thus ProperPrefixes (v^&lt;*x*&gt;) c= ProperPrefixes v \/ {v}
proof
let y;
assume y in ProperPrefixes (v^&lt;*x*&gt;);
then consider v1 such that
A1: y = v1 and
A2: v1 is_a_proper_prefix_of v^&lt;*x*&gt; by TREES_1:def 2;
v1 is_a_prefix_of v &amp; v1 &lt;&gt; v or v1 = v by A2,TREES_1:9;
then
v1 is_a_proper_prefix_of v or v1 in {v} by TARSKI:def 1,XBOOLE_0:def 8;
then y in ProperPrefixes v or y in {v} by A1,TREES_1:def 2;
hence thesis by XBOOLE_0:def 3;
end;
let y;
assume y in ProperPrefixes v \/ {v};
then A3: y in ProperPrefixes v or y in {v} by XBOOLE_0:def 3;
A4: now
assume y in ProperPrefixes v;
then consider v1 such that
A5: y = v1 and
A6: v1 is_a_proper_prefix_of v by TREES_1:def 2;
v is_a_prefix_of v^&lt;*x*&gt; by TREES_1:1;
then v1 is_a_proper_prefix_of v^&lt;*x*&gt; by A6,XBOOLE_1:58;
hence thesis by A5,TREES_1:def 2;
end;
v^{} = v by FINSEQ_1:34;
then
v is_a_prefix_of v^&lt;*x*&gt; &amp; v &lt;&gt; v^&lt;*x*&gt; by FINSEQ_1:33,TREES_1:1;
then v is_a_proper_prefix_of v^&lt;*x*&gt; by XBOOLE_0:def 8;
then y in ProperPrefixes v or y = v &amp; v in ProperPrefixes (v^&lt;*x*&gt;)
by A3,TARSKI:def 1,TREES_1:def 2;
hence thesis by A4;
end;
</code></pre>
</div>
<nav>
<ul class="Pager">
<li class=Pager--prev><a href="../Examples/index.html">Previous</a></li> <li class=Pager--next><a href="../Examples/Hello_World.html">Next</a></li> </ul>
</nav>
</article>
</div>
</div>
</div>
</div>
<script>
(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','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-3551397-7', '');
ga('send', 'pageview');
</script>
<!-- JS -->
<script src="../themes/daux/js/jquery-1.11.3.min.js"></script><script src="../themes/daux/js/highlight.pack.js"></script><script src="../themes/daux/js/daux.js"></script>
<!-- Tipue Search -->
<script type="text/javascript" src="../tipuesearch/tipuesearch.js"></script>
<script>
window.onunload = function(){}; // force $(document).ready to be called on back/forward navigation in firefox
$(function() {
tipuesearch({
'base_url': '../'
});
});
</script>
</body>
</html>