### Dockerfile Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/md/lib/codemirror/mode/dockerfile/index.html
A sample Dockerfile demonstrating the installation of the Ghost blogging platform and setup for a development environment. This example includes steps for updating packages, installing dependencies, adding repositories, downloading and unzipping Ghost, configuring it, and exposing the necessary port.
```dockerfile
# Install Ghost blogging platform and run development environment
#
# VERSION 1.0.0
FROM ubuntu:12.10
MAINTAINER Amer Grgic "amer@livebyt.es"
WORKDIR /data/ghost
# Install dependencies for nginx installation
RUN apt-get update
RUN apt-get install -y python g++ make software-properties-common --force-yes
RUN add-apt-repository ppa:chris-lea/node.js
RUN apt-get update
# Install unzip
RUN apt-get install -y unzip
# Install curl
RUN apt-get install -y curl
# Install nodejs & npm
RUN apt-get install -y rlwrap
RUN apt-get install -y nodejs
# Download Ghost v0.4.1
RUN curl -L https://ghost.org/zip/ghost-latest.zip -o /tmp/ghost.zip
# Unzip Ghost zip to /data/ghost
RUN unzip -uo /tmp/ghost.zip -d /data/ghost
# Add custom config js to /data/ghost
ADD ./config.example.js /data/ghost/config.js
# Install Ghost with NPM
RUN cd /data/ghost/ && npm install --production
# Expose port 2368
EXPOSE 2368
# Run Ghost
CMD ["npm","start"]
```
--------------------------------
### Dockerfile Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/sql/md/lib/codemirror/mode/dockerfile/index.html
This is an example Dockerfile demonstrating the installation of the Ghost blogging platform and the setup of a development environment. It includes steps for updating packages, installing dependencies, downloading Ghost, and configuring the application.
```dockerfile
# Install Ghost blogging platform and run development environment
#
# VERSION 1.0.0
FROM ubuntu:12.10
MAINTAINER Amer Grgic "amer@livebyt.es"
WORKDIR /data/ghost
# Install dependencies for nginx installation
RUN apt-get update
RUN apt-get install -y python g++ make software-properties-common --force-yes
RUN add-apt-repository ppa:chris-lea/node.js
RUN apt-get update
# Install unzip
RUN apt-get install -y unzip
# Install curl
RUN apt-get install -y curl
# Install nodejs & npm
RUN apt-get install -y rlwrap
RUN apt-get install -y nodejs
# Download Ghost v0.4.1
RUN curl -L https://ghost.org/zip/ghost-latest.zip -o /tmp/ghost.zip
# Unzip Ghost zip to /data/ghost
RUN unzip -uo /tmp/ghost.zip -d /data/ghost
# Add custom config js to /data/ghost
ADD ./config.example.js /data/ghost/config.js
# Install Ghost with NPM
RUN cd /data/ghost/ && npm install --production
# Expose port 2368
EXPOSE 2368
# Run Ghost
CMD
["npm","start"]
```
--------------------------------
### Shell Script Example: Git Repository Setup and Server Start
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/sql/md/lib/codemirror/mode/shell/index.html
This script demonstrates cloning a Git repository, generating HTTPS credentials using OpenSSL, and starting a Node.js server in HTTPS mode. It also includes a method to stop the server.
```shell
#!/bin/bash
# clone the repository
git clone http://github.com/garden/tree
# generate HTTPS credentials
cd tree
openssl genrsa -aes256 -out https.key 1024
openssl req -new -nodes -key https.key -out https.csr
openssl x509 -req -days 365 -in https.csr -signkey https.key -out https.crt
cp https.key{,.orig}
openssl rsa -in https.key.orig -out https.key
# start the server in HTTPS mode
cd web
sudo node ../server.js 443 'yes' >> ../node.log &
# here is how to stop the server
for pid in `ps aux | grep 'node ../server.js' | awk '{print $2}'` ;
do sudo kill -9 $pid 2> /dev/null
done
exit 0
```
--------------------------------
### Dockerfile Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/au/md/lib/codemirror/mode/dockerfile/index.html
A sample Dockerfile demonstrating instructions for installing the Ghost blogging platform.
```dockerfile
# Install Ghost blogging platform and run development environment
#
# VERSION 1.0.0
FROM ubuntu:12.10
MAINTAINER Amer Grgic "amer@livebyt.es"
WORKDIR /data/ghost
# Install dependencies for nginx installation
RUN apt-get update
RUN apt-get install -y python g++ make software-properties-common --force-yes
RUN add-apt-repository ppa:chris-lea/node.js
RUN apt-get update
# Install unzip
RUN apt-get install -y unzip
# Install curl
RUN apt-get install -y curl
# Install nodejs & npm
RUN apt-get install -y rlwrap
RUN apt-get install -y nodejs
# Download Ghost v0.4.1
RUN curl -L https://ghost.org/zip/ghost-latest.zip -o /tmp/ghost.zip
# Unzip Ghost zip to /data/ghost
RUN unzip -uo /tmp/ghost.zip -d /data/ghost
# Add custom config js to /data/ghost
ADD ./config.example.js /data/ghost/config.js
# Install Ghost with NPM
RUN cd /data/ghost/ && npm install --production
# Expose port 2368
EXPOSE 2368
# Run Ghost
CMD
["npm","start"]
```
--------------------------------
### Shell Script Example: Git Clone and Server Setup
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/au/md/lib/codemirror/mode/shell/index.html
This script demonstrates cloning a Git repository, generating HTTPS credentials using OpenSSL, and starting a Node.js server in HTTPS mode. It also includes logic to stop the server.
```shell
#!/bin/bash
# clone the repository
git clone http://github.com/garden/tree
# generate HTTPS credentials
cd tree
openssl genrsa -aes256 -out https.key 1024
openssl req -new -nodes -key https.key -out https.csr
openssl x509 -req -days 365 -in https.csr -signkey https.key -out https.crt
cp https.key{,.orig}
openssl rsa -in https.key.orig -out https.key
# start the server in HTTPS mode
cd web
sudo node ../server.js 443 'yes' >> ../node.log &
# here is how to stop the server
for pid in `ps aux | grep 'node ../server.js' | awk '{print $2}'` ;
do sudo kill -9 $pid 2> /dev/null
done
exit 0
```
--------------------------------
### Meta-programming and Prelude Installation in LiveScript
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/au/md/lib/codemirror/mode/livescript/index.html
Includes a meta-programming example with `installPrelude` to check and set a prelude installation flag. It also exports the `prelude` object itself.
```livescript
# meta
export installPrelude = !(target) ->
unless target.prelude?isInstalled => target <<< out$
# using out$ generated by livescript
target <<< target.prelude.isInstalled = true
```
```livescript
export prelude = out$
```
--------------------------------
### Shell Script Example: Git Clone and Server Setup
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/md/lib/codemirror/mode/shell/index.html
This script demonstrates cloning a Git repository, generating HTTPS credentials using OpenSSL, and starting a Node.js server in HTTPS mode. It also includes logic to stop the server by killing its process.
```shell
#!/bin/bash
# clone the repository
git clone http://github.com/garden/tree
# generate HTTPS credentials
cd tree
openssl genrsa -aes256 -out https.key 1024
openssl req -new -nodes -key https.key -out https.csr
openssl x509 -req -days 365 -in https.csr -signkey https.key -out https.crt
cp https.key{,.orig}
openssl rsa -in https.key.orig -out https.key
# start the server in HTTPS mode
cd web
sudo node ../server.js 443 'yes' >> ../node.log &
# here is how to stop the server
for pid in `ps aux | grep 'node ../server.js' | awk '{print $2}'` ;
do sudo kill -9 $pid 2> /dev/null
done
exit 0
```
--------------------------------
### Pascal Code Examples
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/md/lib/codemirror/mode/pascal/index.html
Demonstrates various Pascal control flow structures. No specific setup is required beyond a Pascal environment.
```pascal
while a <> b do writeln('Waiting');
```
```pascal
if a > b then writeln('Condition met') else writeln('Condition not met');
```
```pascal
for i := 1 to 10 do writeln('Iteration: ', i:1);
```
```pascal
repeat a := a + 1 until a = 10;
```
```pascal
case i of
0: write('zero');
1: write('one');
2: write('two')
end;
```
--------------------------------
### Puppet Module Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/md/lib/codemirror/mode/puppet/index.html
This snippet demonstrates a Puppet class for installing and configuring AutoMySQLBackup. It includes resource definitions for files and packages, and conditional logic for specific operating systems.
```puppet
# == Class: automysqlbackup
#
# Puppet module to install AutoMySQLBackup for periodic MySQL backups.
#
# class {
# 'automysqlbackup':
# backup_dir => '/mnt/backups',
# }
#
class automysqlbackup (
$bin_dir = $automysqlbackup::params::bin_dir,
$etc_dir = $automysqlbackup::params::etc_dir,
$backup_dir = $automysqlbackup::params::backup_dir,
$install_multicore = undef,
$config = {},
$config_defaults = {},
)
inherits automysqlbackup::params {
# Ensure valid paths are assigned
validate_absolute_path($bin_dir)
validate_absolute_path($etc_dir)
validate_absolute_path($backup_dir)
# Create a subdirectory in /etc for config files
file {
$etc_dir: ensure => directory,
owner => 'root',
group => 'root',
mode => '0750',
}
# Create an example backup file, useful for reference
file {
"${etc_dir}/automysqlbackup.conf.example":
ensure => file,
owner => 'root',
group => 'root',
mode => '0660',
source => 'puppet:///modules/automysqlbackup/automysqlbackup.conf',
}
# Add files from the developer
file {
"${etc_dir}/AMB_README":
source => 'puppet:///modules/automysqlbackup/AMB_README',
}
file {
"${etc_dir}/AMB_LICENSE":
source => 'puppet:///modules/automysqlbackup/AMB_LICENSE',
}
# Install the actual binary file
file {
"${bin_dir}/automysqlbackup":
ensure => file,
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/automysqlbackup/automysqlbackup',
}
# Create the base backup directory
file {
$backup_dir:
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
}
# If you'd like to keep your config in hiera and pass it to this class
if !empty($config) {
create_resources('automysqlbackup::backup', $config, $config_defaults)
}
# If using RedHat family, must have the RPMforge repo's enabled
if $install_multicore {
package {
['pigz', 'pbzip2']:
ensure => installed
}
}
}
```
--------------------------------
### CoffeeScript Baseline Setup and Variable Assignments
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/unit/md/lib/codemirror/mode/coffeescript/index.html
This snippet demonstrates the baseline setup for a CoffeeScript environment, establishing the root object and saving previous variable states. It includes examples of variable assignments and conditional checks.
```coffeescript
# Establish the root object, `window` in the browser, or `global` on the server. root = this # Save the previous value of the `_` variable. previousUnderscore = root._
```
```coffeescript
# Establish the object that gets thrown to break out of a loop iteration. # `StopIteration` is SOP on Mozilla. breaker = if typeof(StopIteration) is 'undefined' then '__break__' else StopIteration
```
--------------------------------
### Prelude Installation in LiveScript
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/md/lib/codemirror/mode/livescript/index.html
A meta-function to install the prelude if it's not already present on a target object. It checks for `target.prelude.isInstalled` and sets it to true upon installation.
```livescript
# meta export installPrelude = !(target) -> unless target.prelude?isInstalled target <<< out$ # using out$ generated by livescript target <<< target.prelude.isInstalled = true
```
```livescript
export prelude = out$
```
--------------------------------
### Puppet Code Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/ui/md/lib/codemirror/mode/puppet/index.html
This is an example of Puppet code, a declarative language used for managing system configurations. It defines a class for installing and configuring AutoMySQLBackup.
```puppet
# == Class: automysqlbackup
#
# Puppet module to install AutoMySQLBackup for periodic MySQL backups.
#
# class {
# 'automysqlbackup':
# backup_dir => '/mnt/backups',
# }
#
class automysqlbackup (
$bin_dir = $automysqlbackup::params::bin_dir,
$etc_dir = $automysqlbackup::params::etc_dir,
$backup_dir = $automysqlbackup::params::backup_dir,
$install_multicore = undef,
$config = {},
$config_defaults = {},
) inherits automysqlbackup::params {
# Ensure valid paths are assigned
validate_absolute_path($bin_dir)
validate_absolute_path($etc_dir)
validate_absolute_path($backup_dir)
# Create a subdirectory in /etc for config files
file {
$etc_dir:
ensure => directory,
owner => 'root',
group => 'root',
mode => '0750',
}
# Create an example backup file, useful for reference
file {
"${etc_dir}/automysqlbackup.conf.example":
ensure => file,
owner => 'root',
group => 'root',
mode => '0660',
source => 'puppet:///modules/automysqlbackup/automysqlbackup.conf',
}
# Add files from the developer
file {
"${etc_dir}/AMB_README":
source => 'puppet:///modules/automysqlbackup/AMB_README',
}
file {
"${etc_dir}/AMB_LICENSE":
source => 'puppet:///modules/automysqlbackup/AMB_LICENSE',
}
# Install the actual binary file
file {
"${bin_dir}/automysqlbackup":
ensure => file,
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/automysqlbackup/automysqlbackup',
}
# Create the base backup directory
file {
$backup_dir:
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
}
# If you'd like to keep your config in hiera and pass it to this class
if !empty($config) {
create_resources('automysqlbackup::backup', $config, $config_defaults)
}
# If using RedHat family, must have the RPMforge repo's enabled
if $install_multicore {
package {
['pigz', 'pbzip2']:
ensure => installed
}
}
}
```
--------------------------------
### Prelude Installation Utility in LiveScript
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/sql/md/lib/codemirror/mode/livescript/index.html
Shows how to install the prelude, a collection of standard functions, onto a target object. This is a meta-programming utility for extending object capabilities.
```livescript
# meta
export installPrelude = !(target) ->
unless target.prelude?isInstalled
target <<< out$
# using out$ generated by livescript
target <<< target.prelude.isInstalled = true
export prelude = out$
```
--------------------------------
### CoffeeScript Baseline Setup
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/au/md/lib/codemirror/mode/coffeescript/index.html
Demonstrates the baseline setup for establishing the root object (window or global) and saving the previous value of the '_' variable.
```coffeescript
# Baseline setup # Establish the root object, `window` in the browser, or `global` on the server. root = this # Save the previous value of the `_` variable. previousUnderscore = root._
```
--------------------------------
### Installing Prelude in LiveScript
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/unit/md/lib/codemirror/mode/livescript/index.html
A meta-function to install the prelude, ensuring that the target object has the necessary prelude functions available.
```livescript
# meta export installPrelude = !(target) -> unless target.prelude?isInstalled target <<< out$ # using out$ generated by livescript target <<< target.prelude.isInstalled = true export prelude = out$
```
--------------------------------
### Puppet Code Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/cv/md/lib/codemirror/mode/puppet/index.html
This is an example of Puppet code demonstrating class definition, parameter handling, and resource declaration for managing files and packages.
```puppet
# == Class: automysqlbackup
#
# Puppet module to install AutoMySQLBackup for periodic MySQL backups.
#
# class {
# 'automysqlbackup':
# backup_dir => '/mnt/backups',
# }
#
class automysqlbackup (
$bin_dir = $automysqlbackup::params::bin_dir,
$etc_dir = $automysqlbackup::params::etc_dir,
$backup_dir = $automysqlbackup::params::backup_dir,
$install_multicore = undef,
$config = {},
$config_defaults = {},
)
inherits automysqlbackup::params {
# Ensure valid paths are assigned
validate_absolute_path($bin_dir)
validate_absolute_path($etc_dir)
validate_absolute_path($backup_dir)
# Create a subdirectory in /etc for config files
file {
$etc_dir:
ensure => directory,
owner => 'root',
group => 'root',
mode => '0750',
}
# Create an example backup file, useful for reference
file {
"${etc_dir}/automysqlbackup.conf.example":
ensure => file,
owner => 'root',
group => 'root',
mode => '0660',
source => 'puppet:///modules/automysqlbackup/automysqlbackup.conf',
}
# Add files from the developer
file {
"${etc_dir}/AMB_README":
source => 'puppet:///modules/automysqlbackup/AMB_README',
}
file {
"${etc_dir}/AMB_LICENSE":
source => 'puppet:///modules/automysqlbackup/AMB_LICENSE',
}
# Install the actual binary file
file {
"${bin_dir}/automysqlbackup":
ensure => file,
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/automysqlbackup/automysqlbackup',
}
# Create the base backup directory
file {
$backup_dir:
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
}
# If you'd like to keep your config in hiera and pass it to this class
if !empty($config) {
create_resources('automysqlbackup::backup', $config, $config_defaults)
}
# If using RedHat family, must have the RPMforge repo's enabled
if $install_multicore {
package {
['pigz', 'pbzip2']:
ensure => installed
}
}
}
```
--------------------------------
### Tornado Template Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/au/md/lib/codemirror/mode/tornado/index.html
An example of an HTML file with embedded Tornado template syntax, demonstrating loops and variable output.
```html
My Tornado web application
{{ title }}
{% for item in items %}
- {% item.name %}
{% empty %}
- You have no items in your list.
{% end %>
```
--------------------------------
### RPM Spec File Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/md/lib/codemirror/mode/rpm/index.html
This is an example of an RPM spec file. It includes package information, description, build, install, and file sections.
```rpm-spec
# # spec file for package minidlna # # Copyright (c) 2011, Sascha Peilicke # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. Name: libupnp6 Version: 1.6.13 Release: 0 Summary: Portable Universal Plug and Play (UPnP) SDK Group: System/Libraries License: BSD-3-Clause Url: http://sourceforge.net/projects/pupnp/ Source0: http://downloads.sourceforge.net/pupnp/libupnp-%{version}.tar.bz2 BuildRoot: %{\_tmppath}/%{name}-%{version}-build %description The portable Universal Plug and Play (UPnP) SDK provides support for building UPnP-compliant control points, devices, and bridges on several operating systems. %package -n libupnp-devel Summary: Portable Universal Plug and Play (UPnP) SDK Group: Development/Libraries/C and C++ Provides: pkgconfig(libupnp) Requires: %{name} = %{version} %description -n libupnp-devel The portable Universal Plug and Play (UPnP) SDK provides support for building UPnP-compliant control points, devices, and bridges on several operating systems. %prep %setup -n libupnp-%{version} %build %configure --disable-static make %{?_smp_mflags} %install %makeinstall find %{buildroot} -type f -name '*.la' -exec rm -f {} ';' %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %files %defattr(-,root,root,-) %doc ChangeLog NEWS README TODO %{\_libdir}/libixml.so.\* %{\_libdir}/libthreadutil.so.\* %{\_libdir}/libupnp.so.\* %files -n libupnp-devel %defattr(-,root,root,-) %{\_libdir}/pkgconfig/libupnp.pc %{\_libdir}/libixml.so %{\_libdir}/libthreadutil.so %{\_libdir}/libupnp.so %{\_includedir}/upnp/ %changelog
```
--------------------------------
### XQuery Syntax Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/md/lib/codemirror/mode/xquery/index.html
Demonstrates basic XQuery syntax including version declaration, comments, let bindings, and element construction.
```xquery
xquery version "1.0-ml"; (: this is : a "comment" :)
let $let := "test"function() $var {function()} {$var}
let $joe:=1
return element element { attribute attribute { 1 }, element test { 'a' }, attribute foo { "bar" }, fn:doc()[
foo/@bar eq $let
], //x
} (: a more 'evil' test :)
(: Modified Blakeley example (: with nested comment :) ... :)
declare private function local:declare() {()};
declare private function local:private() {()};
declare private function local:function() {()};
declare private function local:local() {()};
let $let := let $let := "let"
return element element { attribute attribute { try { xdmp:version() } catch($e) { xdmp:log($e) } }, attribute fn:doc { "bar" castable as xs:string }, element text { text { "text" } }, fn:doc()[
child::eq/(@bar | attribute::attribute) eq $let
], //fn:doc
```
--------------------------------
### Basic XQuery Syntax Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/au/md/lib/codemirror/mode/xquery/index.html
Demonstrates basic XQuery syntax including comments, let bindings, and element constructors.
```xquery
xquery version "1.0-ml"; (: this is : a "comment" :)
let $let := "test"function() $var {function()} {$var}
let $joe:=1
return element element { attribute attribute { 1 }, element test { 'a' }, attribute foo { "bar" }, fn:doc()[
foo/@bar eq $let
], //x } (: a more 'evil' test :) (: Modified Blakeley example (: with nested comment :) ... :)
```
--------------------------------
### XQuery Syntax Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/cv/md/lib/codemirror/mode/xquery/index.html
Demonstrates basic XQuery syntax including version declaration, comments, let bindings, element constructors, and attribute assignments.
```xquery
xquery version "1.0-ml"; (: this is : a "comment" :)
let $let := "test"function() $var {function()} {$var}
let $joe:=1
return element element { attribute attribute { 1 }, element test { 'a' }, attribute foo { "bar" }, fn:doc()[
foo/@bar eq $let
], //x
} (: a more 'evil' test :)
(: Modified Blakeley example (: with nested comment :) ... :)
```
--------------------------------
### GET Request for Specific Columns
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-JavaScript/APIJSON-JS/get/column.html
Use the '@column' key within the JSON request to specify which columns to retrieve. This example fetches 'id', 'userId', and 'content' for the record with 'id' equal to 15.
```javascript
var json = { "Moment":{ "@column":"id,userId,content", "id":15 } };
request(URL_GET, json);
```
--------------------------------
### D Compile-Time String Formatting Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/au/md/lib/codemirror/mode/d/index.html
Demonstrates compile-time string formatting using the Format template, analogous to string.format. Ensure necessary imports are present.
```d
import std.metastrings;
import std.stdio;
void main() {
string s = Format!("Arg %s = %s", "foo", 27);
writefln(s);
}
```
--------------------------------
### reST Explicit Markup Block Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/md/lib/codemirror/mode/rst/index.html
Illustrates the basic structure of an explicit markup block in reStructuredText, which starts with '.. ' and is terminated by the next paragraph at the same indentation level. This is used for directives, comments, and other special constructs.
```rst
.. _directives: Directives ----------
A directive is a generic block of explicit markup.
```
--------------------------------
### Q Language Query and Data Initialization
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/sql/md/lib/codemirror/mode/q/index.html
Shows how to select specific columns from the 'info' table and how to initialize or query data using the 'info0' table. The 'infolike' function is used for pattern matching on column headers.
```q
info:info0[;()] / by default don't restrict columns infolike: {[file;pattern] info0[file;{x where x like y}[lower colhdrs[file];pattern]]} / .csv.infolike[file;"*time"] \d .
```
--------------------------------
### APL Game of Life Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/md/lib/codemirror/mode/apl/index.html
This APL code demonstrates Conway's game of life, including creature definition, board setup, and generation logic. It's used to show APL's matrix manipulation capabilities.
```apl
⍝ Conway's game of life ⍝ This example was inspired by the impressive demo at ⍝ http://www.youtube.com/watch?v=a9xAKttWgP4 ⍝ Create a matrix: ⍝ 0 1 1 ⍝ 1 1 0 ⍝ 0 1 0 creature ← (3 3 ⍴ ⍳ 9) ∈ 1 2 3 4 7 ⍝ Original creature from demo creature ← (3 3 ⍴ ⍳ 9) ∈ 1 3 6 7 8 ⍝ Glider ⍝ Place the creature on a larger board, near the centre board ← ¯1 ⊖ ¯2 ⌽ 5 7 ↑ creature ⍝ A function to move from one generation to the next life ← {∨/ 1 ⍵ ∧ 3 4 = ⊂+/ +⌿ 1 0 ¯1 ∘.⊖ 1 0 ¯1 ⌽¨ ⊂⍵} ⍝ Compute n-th generation and format it as a ⍝ character matrix gen ← {' #'\(life ⍣ ⍵) board] ⍝ Show first three generations (gen 1) (gen 2) (gen 3)
```
--------------------------------
### Stylus Syntax Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/au/md/lib/codemirror/mode/stylus/index.html
Demonstrates basic Stylus syntax including selectors, properties, variables, and mixins.
```stylus
/* Stylus mode */
#id .class article
font-family Arial, sans-serif
#id, .class, article {
font-family: Arial, sans-serif;
}
// Variables
font-size-base = 16px
line-height-base = 1.5
font-family-base = "Helvetica Neue", Helvetica, Arial, sans-serif
text-color = lighten(#000, 20%)
body {
font font-size-base/line-height-base font-family-base color text-color
color: #333;
}
// Variables
link-color = darken(#428bca, 6.5%)
link-hover-color = darken(link-color, 15%)
link-decoration = none
link-hover-decoration = false
// Mixin
tab-focus() {
outline: thin dotted
outline: 5px auto -webkit-focus-ring-color
outline-offset: -2px
}
a {
color: link-color
if link-decoration {
text-decoration: link-decoration
}
&:hover,
&:focus {
color: link-hover-color
}
&:focus {
tab-focus()
}
}
a:hover, a:focus {
color: #2f6ea7;
}
a:focus {
outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
```
--------------------------------
### reStructuredText Directive Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/cv/md/lib/codemirror/mode/rst/index.html
Illustrates the structure of a reStructuredText directive, including its name, arguments, options, and content. Options must be indented to the same level as the directive content, and the content follows after a blank line, indented relative to the directive start.
```rst
.. function:: foo(x)
foo(y, z)
:module: some.module.name
Return a line of text input from the user.
```
--------------------------------
### GET Rely Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-JavaScript/APIJSON-JS/get/rely.html
This snippet shows how to use the rely feature to reference data from the 'Moment' object within the 'User' object. The '@' symbol indicates a reference, and the `encodeURIComponent` function is automatically applied to ensure proper encoding of the reference path.
```javascript
var json = { "Moment":{ "id":15 }, "User":{ "id@":"Moment/userId" //已通过encode函数自动转义 encodeURIComponent("Moment/userId") } };
request(URL_GET, json);
```
--------------------------------
### Properties File Syntax Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/au/md/lib/codemirror/mode/properties/index.html
Illustrates the syntax of a properties file, including comments, key-value pairs, multi-line values using backslashes, and Unicode characters.
```properties
# This is a properties file a.key = A value another.key = http://example.com ! Exclamation mark as comment but.not=Within ! A value # indeed # Spaces at the beginning of a line spaces.before.key=value backslash=Used for multi\ line entries,\ that's convenient. # Unicode sequences unicode.key=This is \u0020 Unicode no.multiline=here # Colons colons : can be used too # Spaces spaces\ in\ keys=Not very common...
```
--------------------------------
### Q Language Query Examples
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/ui/md/lib/codemirror/mode/q/index.html
Illustrates querying and filtering data in Q. It shows how to select specific columns and apply conditions.
```q
info:info0[;()] / by default don't restrict columns
```
```q
infolike: {[file;pattern] info0[file;{x where x like y}[lower colhdrs[file];pattern]]} / .csv.infolike[file;"*time"]
```
--------------------------------
### LESS Syntax Examples
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/cv/md/lib/codemirror/mode/css/less.html
Demonstrates various LESS syntax features including media queries, pseudo-classes, namespaces, attribute selectors, vendor prefixes, mixins, and imports.
```less
@media screen and (device-aspect-ratio: 16/9) { … }
@media screen and (device-aspect-ratio: 1280/720) { … }
@media screen and (device-aspect-ratio: 2560/1440) { … }
```
```less
html:lang(fr-be) tr:nth-child(2n+1) /* represents every odd row of an HTML table */
img:nth-of-type(2n+1) { float: right; }
img:nth-of-type(2n) { float: left; }
```
```less
body > h2:not(:first-of-type):not(:last-of-type)
```
```less
html|*:not(:link):not(:visited) *|*:not(:hover)
p::first-line { text-transform: uppercase }
```
```less
@namespace foo url(http://www.example.com);
foo|h1 { color: blue }
```
```less
/* first rule */
span[hello="Ocean"][goodbye="Land"] E[foo] { padding:65px; }
```
```less
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
-webkit-appearance: none; /* Inner-padding issues in Chrome OSX, Safari 5 */
}
```
```less
button::-moz-focus-inner,
input::-moz-focus-inner {
/* Inner padding and border oddities in FF3/4 */
padding: 0;
border: 0;
}
```
```less
.btn {
/* reset here as of 2.0.3 due to Recess property order */
border-color: #ccc;
border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);
}
```
```less
fieldset span button,
fieldset span input[type="file"] {
font-size:12px;
font-family:Arial, Helvetica, sans-serif;
}
```
```less
.rounded-corners (@radius: 5px) {
border-radius: @radius;
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
}
```
```less
@import url("something.css");
```
```less
@light-blue: hsl(190, 50%, 65%);
```
```less
#menu {
position: absolute;
width: 100%;
z-index: 3;
clear: both;
display: block;
background-color: @blue;
height: 42px;
border-top: 2px solid lighten(@alpha-blue, 20%);
border-bottom: 2px solid darken(@alpha-blue, 25%);
.box-shadow(0, 1px, 8px, 0.6);
-moz-box-shadow: 0 0 0 #000; /* Because firefox sucks. */
&.docked {
background-color: hsla(210, 60%, 40%, 0.4);
}
&:hover {
background-color: @blue;
}
#dropdown {
margin: 0 0 0 117px;
padding: 0;
padding-top: 5px;
display: none;
width: 190px;
border-top: 2px solid @medium;
color: @highlight;
border: 2px solid darken(@medium, 25%);
border-left-color: darken(@medium, 15%);
border-right-color: darken(@medium, 15%);
border-top-width: 0;
background-color: darken(@medium, 10%);
ul {
padding: 0px;
}
li {
font-size: 14px;
display: block;
text-align: left;
padding: 0;
border: 0;
a {
display: block;
padding: 0px 15px;
text-decoration: none;
color: white;
&:hover {
background-color: darken(@medium, 15%);
text-decoration: none;
}
}
}
.border-radius(5px, bottom);
.box-shadow(0, 6px, 8px, 0.5);
}
}
```
--------------------------------
### Turtle RDF Data Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/cv/md/lib/codemirror/mode/turtle/index.html
An example of data formatted in the Turtle RDF syntax.
```turtle
@prefix foaf: .
@prefix geo: .
@prefix rdf: .
a foaf:Person;
foaf:interest ;
foaf:based_near [
geo:lat "34.0736111" ;
geo:lon "-118.3994444"
]
```
--------------------------------
### JSON-LD Example Data
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/cv/md/lib/codemirror/mode/javascript/json-ld.html
An example of JSON-LD data structure representing the Empire State Building.
```json
{ "@context": { "name": "http://schema.org/name", "description": "http://schema.org/description", "image": { "@id": "http://schema.org/image", "@type": "@id" }, "geo": "http://schema.org/geo", "latitude": { "@id": "http://schema.org/latitude", "@type": "xsd:float" }, "longitude": { "@id": "http://schema.org/longitude", "@type": "xsd:float" }, "xsd": "http://www.w3.org/2001/XMLSchema#" }, "name": "The Empire State Building", "description": "The Empire State Building is a 102-story landmark in New York City.", "image": "http://www.civil.usherbrooke.ca/cours/gci215a/empire-state-building.jpg", "geo": { "latitude": "40.75", "longitude": "73.98" } }
```
--------------------------------
### JSON-LD Example Data
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/au/md/lib/codemirror/mode/javascript/json-ld.html
An example of data formatted in JSON-LD, used for structured data on the web.
```json
{
"@context": {
"name": "http://schema.org/name",
"description": "http://schema.org/description",
"image": {
"@id": "http://schema.org/image",
"@type": "@id"
},
"geo": "http://schema.org/geo",
"latitude": {
"@id": "http://schema.org/latitude",
"@type": "xsd:float"
},
"longitude": {
"@id": "http://schema.org/longitude",
"@type": "xsd:float"
},
"xsd": "http://www.w3.org/2001/XMLSchema#"
},
"name": "The Empire State Building",
"description": "The Empire State Building is a 102-story landmark in New York City.",
"image": "http://www.civil.usherbrooke.ca/cours/gci215a/empire-state-building.jpg",
"geo": {
"latitude": "40.75",
"longitude": "73.98"
}
}
```
--------------------------------
### Jinja2 Syntax Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/sql/md/lib/codemirror/mode/jinja2/index.html
Demonstrates various Jinja2 template syntax elements including comments, loops, conditionals, variable access, and includes.
```jinja2
{# this is a comment #} {%- for item in li -%}
{{ item.label }}
{% endfor -%} {{ item.sand == true and item.keyword == false ? 1 : 0 }} {{ app.get(55, 1.2, true) }} {% if app.get('_route') == ('_home') %}home{% endif %} {% if app.session.flashbag.has('message') %} {% for message in app.session.flashbag.get('message') %} {{ message.content }} {% endfor %} {% endif %} {{ path('_home', {'section': app.request.get('section')}) }} {{ path('_home', { 'section': app.request.get('section'), 'boolean': true, 'number': 55.33 }) }} {% include ('test.incl.html.twig') %}
```
--------------------------------
### Soy Template Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/md/lib/codemirror/mode/soy/index.html
Demonstrates basic Soy syntax for defining a template with parameters and conditional logic.
```soy
{namespace example}
/**
* Says hello to the world.
*/
{template .helloWorld}
{@param name: string}
{@param? score: number}
Hello {$name}!
{if $score}
{$score} points
{else}
no score
{/if}
{/template}
{template .alertHelloWorld kind="js"}
alert('Hello World');
{/template}
```
--------------------------------
### IDL Code Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/md/lib/codemirror/mode/idl/index.html
This is an example of IDL code that calculates the average and standard deviation of an array.
```idl
;; Example IDL code
FUNCTION mean_and_stddev,array
;; This program reads in an array of numbers
;; and returns a structure containing the
;; average and standard deviation
ave = 0.0
count = 0.0
for i=0,N_ELEMENTS(array)-1 do begin
ave = ave + array[i]
count = count + 1
endfor
ave = ave/count
std = stddev(array)
return, {average:ave,std:std}
END
```
--------------------------------
### HTTP Request Example
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/md/lib/codemirror/mode/http/index.html
This is an example of an HTTP request formatted for syntax highlighting by the HTTP mode.
```http
POST /somewhere HTTP/1.1
Host: example.com
If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
Content-Type: application/x-www-form-urlencoded; charset=utf-8
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Ubuntu/12.04 Chromium/20.0.1132.47 Chrome/20.0.1132.47 Safari/536.11
This is the request body!
```
--------------------------------
### GraalJS: Get Array Length
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONDemo-Script/README.md
Use `length_graalJS` to get the number of elements in a GraalJS array.
```javascript
{
"func": {
"var": [1,2,3],
"length_graalJS()": "length_graalJS(var)"
}
}
```
--------------------------------
### Objective-C Example with Comments and Arrays
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/sql/md/lib/codemirror/mode/clike/index.html
Shows Objective-C syntax including multi-line comments, import statements, and C-style character array declaration.
```objectivec
/* This is a longer comment That spans two lines */
#import
@implementation YourAppDelegate
// This is a one-line comment
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
char myString[] = "This is a C character array";
int test = 5;
return YES;
}
```
--------------------------------
### Lua: Get Array Length
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONDemo-Script/README.md
Use `length_lua` to get the number of elements in a Lua array.
```lua
{
"func": {
"var": [1,2,3,'dd'],
"length_lua()": "length_lua(var)"
}
}
```
--------------------------------
### Example Delegate Interface POST Request
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/README.md
An example of a POST request to the /delegate interface, demonstrating how to proxy a JSON request to 'http://apijson.cn:8080/get/User' with specific recording and header configurations.
```text
POST /delegate?$_record=1&$_type=JSON&$_delegate_id=FEA2B2AE5ACE68C5557B127B57CEFB38&$_delegate_url=http%3A%2F%2Fapijson.cn%3A8080%2Fget%2FUser&$_headers=token%3A%20%20test%0AContent-Type%3A%20%20application%2Fjson
```
--------------------------------
### JavaScript: Get Array Length
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONDemo-Script/README.md
Use `length` to get the number of elements in a JavaScript array.
```javascript
{
"func": {
"var": [1,2,3],
"length()": "length(var)"
}
}
```
--------------------------------
### C++ Example with Templates and Raw Strings
Source: https://github.com/apijson/apijson-demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/au/md/lib/codemirror/mode/clike/index.html
Demonstrates C++ features including enums, unicode strings, raw string literals, class templates, and inheritance. Includes a namespace example.
```cpp
#include #include "mystuff/util.h" namespace { enum Enum { VAL1, VAL2, VAL3 }; char32_t unicode_string = U"\U0010FFFF"; string raw_string = R"delim(anything you want)delim"; int Helper(const MyType& param) { return 0; } } // namespace class ForwardDec; template class Class : public BaseClass { const MyType member_; public: const MyType& Method() const { return member_; } void Method2(MyType* value); } template void Class::Method2(MyType* value) { std::out << 1 >> method(); value->Method3(member_); member_ = value; }
```