### Dockerfile Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/dockerfile/index.html A sample Dockerfile demonstrating the installation of the Ghost blogging platform and setting up a development environment. It includes steps for updating packages, installing dependencies, 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"] ``` -------------------------------- ### Shell Script Example: Clone Repository and Start Server Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/shell/index.html A shell script demonstrating cloning a Git repository, generating HTTPS certificates, and starting a Node.js server in HTTPS mode. Includes commands for stopping 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 ``` -------------------------------- ### Installing Prelude Utilities in LiveScript Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/livescript/index.html Demonstrates how to install prelude utilities onto a target object. This is a meta-programming utility. ```livescript export installPrelude = !(target) -> unless target.prelude?isInstalled target <<< out$ target.prelude.isInstalled = true ``` -------------------------------- ### List All Plugins Source: https://github.com/jeedom/core/blob/develop/docs/en_US/jsonrpc_api.md Get a list of all installed plugins on Jeedom. ```json { "jsonrpc": "2.0", "id": "1", "method": "plugin::listPlugin" } ``` -------------------------------- ### Example Launch Time Relative to Sunset Source: https://github.com/jeedom/core/blob/develop/docs/en_US/scenario.md Launch times can be dynamic, for example, a specified number of minutes after sunset. ```text #sunset# +10 ``` -------------------------------- ### Example Launch Time Relative to Sunset (with hours) Source: https://github.com/jeedom/core/blob/develop/docs/en_US/scenario.md Launch times can be dynamic, for example, a specified number of hours and minutes after sunset. Note the format for hours and minutes. ```text #sunset# +130 ``` -------------------------------- ### ProtoBuf Syntax Example 2 (proto3) Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/protobuf/index.html Example of a ProtoBuf message definition using proto3 syntax, including imports, options, and nested messages. ```protobuf syntax = "proto3"; package tutorial; import "google/protobuf/timestamp.proto"; option java_package = "com.example.tutorial"; option java_outer_classname = "AddressBookProtos"; option csharp_namespace = "Google.Protobuf.Examples.AddressBook"; message Person { string name = 1; int32 id = 2; // Unique ID number for this person. string email = 3; enum PhoneType { MOBILE = 0; HOME = 1; WORK = 2; } message PhoneNumber { string number = 1; PhoneType type = 2; } repeated PhoneNumber phones = 4; google.protobuf.Timestamp last_updated = 5; } // Our address book file is just one of these. message AddressBook { repeated Person people = 1; } service Test { rpc SayHello (HelloRequest) returns (HelloReply) {} rpc SayHelloAgain (HelloRequest) returns (HelloReply) {} } ``` -------------------------------- ### Asterisk extensions.conf Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/asterisk/index.html A comprehensive example of an Asterisk extensions.conf file, demonstrating various dialplan contexts, extensions, macros, and functions. This serves as a reference for syntax and structure. ```asterisk ; extensions.conf - the Asterisk dial plan ; [general] ; ; If static is set to no, or omitted, then the pbx_config will rewrite ; this file when extensions are modified. Remember that all comments ; made in the file will be lost when that happens. static=yes #include "/etc/asterisk/additional_general.conf [iaxprovider] switch => IAX2/user:[key]@myserver/mycontext [dynamic] #exec /usr/bin/dynamic-peers.pl [trunkint] ; ; International long distance through trunk ; exten => _9011.,1,Macro(dundi-e164,${EXTEN:4}) exten => _9011.,n,Dial(${GLOBAL(TRUNK)}/${FILTER(0-9,${EXTEN:${GLOBAL(TRUNKMSD)}})}) [local] ; ; Master context for local, toll-free, and iaxtel calls only ; ignorepat => 9 include => default [demo] include => stdexten ; ; We start with what to do when a call first comes in. ; exten => s,1,Wait(1) ; Wait a second, just for fun same => n,Answer ; Answer the line same => n,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds same => n,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds same => n(restart),BackGround(demo-congrats) ; Play a congratulatory message same => n(instruct),BackGround(demo-instruct) ; Play some instructions same => n,WaitExten ; Wait for an extension to be dialed. exten => 2,1,BackGround(demo-moreinfo) ; Give some more information. exten => 2,n,Goto(s,instruct) exten => 3,1,Set(LANGUAGE()=fr) ; Set language to french exten => 3,n,Goto(s,restart) ; Start with the congratulations exten => 1000,1,Goto(default,s,1) ; ; ; We also create an example user, 1234, who is on the console and has ; voicemail, etc. ; exten => 1234,1,Playback(transfer,skip) ; "Please hold while..." ; (but skip if channel is not up) exten => 1234,n,Gosub(${EXTEN},stdexten(${GLOBAL(CONSOLE)})) exten => 1234,n,Goto(default,s,1) ; exited Voicemail exten => 1235,1,Voicemail(1234,u) ; Right to voicemail exten => 1236,1,Dial(Console/dsp) ; Ring forever exten => 1236,n,Voicemail(1234,b) ; Unless busy ; ; ; # for when they're done with the demo ; exten => #,1,Playback(demo-thanks) ; "Thanks for trying the demo" exten => #,n,Hangup ; Hang them up. ; ; A timeout and "invalid extension rule" ; exten => t,1,Goto(#,1) ; If they take too long, give up exten => i,1,Playback(invalid) ; "That's not valid, try again" ; ; Create an extension, 500, for dialing the ; Asterisk demo. ; exten => 500,1,Playback(demo-abouttotry); Let them know what's going on exten => 500,n,Dial(IAX2/guest@pbx.digium.com/s@default) ; Call the Asterisk demo exten => 500,n,Playback(demo-nogo) ; Couldn't connect to the demo site exten => 500,n,Goto(s,6) ; Return to the start over message. ; ; Create an extension, 600, for evaluating echo latency. ; exten => 600,1,Playback(demo-echotest) ; Let them know what's going on exten => 600,n,Echo ; Do the echo test exten => 600,n,Playback(demo-echodone) ; Let them know it's over exten => 600,n,Goto(s,6) ; Start over ; ; You can use the Macro Page to intercom a individual user exten => 76245,1,Macro(page,SIP/Grandstream1) ; or if your peernames are the same as extensions exten => _7XXX,1,Macro(page,SIP/${EXTEN}) ; ; ; System Wide Page at extension 7999 ; exten => 7999,1,Set(TIMEOUT(absolute)=60) exten => 7999,2,Page(Local/Grandstream1@page&Local/Xlite1@page&Local/1234@page/n) ; Give voicemail at extension 8500 ; exten => 8500,1,VoicemailMain exten => 8500,n,Goto(s,6) ``` -------------------------------- ### Install Pip for Plugin Dependencies Source: https://github.com/jeedom/core/blob/develop/docs/en_US/faq.md Install or update pip using easy_install to resolve issues with plugin dependency installation, specifically errors related to 'from pip._internal import main'. ```bash sudo easy_install pip sudo easy_install3 pip ``` -------------------------------- ### Erlang Mode Syntax Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/erlang/index.html Demonstrates a basic Erlang module with record definition and a function to expand records. This serves as an example for the Erlang mode's syntax highlighting capabilities. ```erlang %% - -*- mode: erlang; erlang-indent-level: 2 - -*- %%% Created : 7 May 2012 by mats cronqvist %% @doc %% Demonstrates how to print a record. %% @end -module('ex'). -author('mats cronqvist'). -export( [demo/0, rec_info/1] ). -record(demo,{a="One",b="Two",c="Three",d="Four"}). rec_info(demo) -> record_info(fields,demo). demo() -> expand_recs(?MODULE,#demo{a="A",b="BB"}). expand_recs(M,List) when is_list(List) -> [expand_recs(M,L)||L<-List]; expand_recs(M,Tup) when is_tuple(Tup) -> case tuple_size(Tup) of L when L < 1 -> Tup; L -> try Fields = M:rec_info(element(1,Tup)), L = length(Fields)+1, lists:zip(Fields,expand_recs(M,tl(tuple_to_list(Tup)))) catch _:_ -> list_to_tuple(expand_recs(M,tuple_to_list(Tup))) end end; expand_recs(_,Term) -> Term. ``` -------------------------------- ### WebAssembly Text Format Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/wast/index.html An example of WebAssembly text format, defining functions for factorial and addition. ```wast /* Example WebAssembly */ (module $foo (export "fac" (func $fac)) (export "plus" (func $plus)) (func $fac (type $t0) (param $p0 i64) (result i64) (if $I0 (result i64) (i64.lt_s (local.get $p0) (i64.const 1)) (then (i64.const 1)) (else (i64.mul (local.get $p0) (call $fac (i64.sub (local.get $p0) (i64.const 1))))))) (func $plus (param $x i32) (param $y i32) (result i32) (i32.add (local.get $x) (local.get $y)))) ``` -------------------------------- ### Soy Template Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/soy/index.html Demonstrates a basic Soy 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} ``` -------------------------------- ### Example Daily Scheduled Time Source: https://github.com/jeedom/core/blob/develop/docs/en_US/scenario.md Scheduled mode uses Cron syntax. This example shows how to run a scenario at 5 AM daily. ```text 0 5 * * * ``` -------------------------------- ### update::all Source: https://github.com/jeedom/core/blob/develop/docs/en_US/jsonrpc_api.md Returns a list of all installed components, their versions, and associated information. ```APIDOC ## update::all ### Description Returns a list of all installed components, their versions and associated information. ``` -------------------------------- ### LESS CSS Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/css/less.html A comprehensive example demonstrating various LESS syntax features including media queries, pseudo-classes, namespaces, variables, mixins, and imports. ```css @media screen and (device-aspect-ratio: 16/9) { … } @media screen and (device-aspect-ratio: 1280/720) { … } @media screen and (device-aspect-ratio: 2560/1440) { … } 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; } body > h2:not(:first-of-type):not(:last-of-type) html|\*:not(:link):not(:visited) *|\*:not(:hover) p::first-line { text-transform: uppercase } @namespace foo url(http://www.example.com); foo|h1 { color: blue } /\* first rule *\/ span\[hello="Ocean"\].*\[goodbye="Land"\].*\[foo\]{ padding:65px; } input\[type="search"\าลัย::-webkit-search-decoration, input\[type="search"\าลัย::-webkit-search-cancel-button { -webkit-appearance: none; // Inner-padding issues in Chrome OSX, Safari 5 } button::-moz-focus-inner, input::-moz-focus-inner { // Inner padding and border oddities in FF3/4 padding: 0; border: 0; } .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); } fieldset span button, fieldset span input\[type="file"\าลัย { font-size:12px; font-family:Arial, Helvetica, sans-serif; } .rounded-corners (@radius: 5px) { border-radius: @radius; -webkit-border-radius: @radius; -moz-border-radius: @radius; } @import url("something.css"); @light-blue: hsl(190, 50%, 65%); #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); } } ``` -------------------------------- ### Basic CSS Syntax Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/css/index.html A sample of CSS code demonstrating basic syntax, including import statements, body styling, navigation link styling, and heading styles. This is a typical example of CSS that the mode can highlight. ```css /* Some example CSS */ @import url("something.css"); body { margin: 0; padding: 3em 6em; font-family: tahoma, arial, sans-serif; color: #000; } #navigation a { font-weight: bold; text-decoration: none !important; } h1 { font-size: 2.5em; } h2 { font-size: 1.7em; } h1:before, h2:before { content: "::"; } code { font-family: courier, monospace; font-size: 80%; color: #418A8A; } ``` -------------------------------- ### Jade Templating Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/jade/index.html An example of a Jade template structure, demonstrating basic syntax for HTML elements, attributes, and content. ```jade doctype html html head title= "Jade Templating CodeMirror Mode Example" link(rel='stylesheet', href='/css/bootstrap.min.css') link(rel='stylesheet', href='/css/index.css') script(type='text/javascript', src='/js/jquery-1.9.1.min.js') script(type='text/javascript', src='/js/bootstrap.min.js') body div.header h1 Welcome to this Example div.spots if locals.spots each spot in spots div.spot.well div if spot.logo img.img-rounded.logo(src=spot.logo) else img.img-rounded.logo(src="img/placeholder.png") h3 a(href=spot.hash) ##{spot.hash} if spot.title span.title #{spot.title} if spot.desc div #{spot.desc} else h3 There are no spots currently available. ``` -------------------------------- ### RPM Spec File Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/rpm/index.html An example of an RPM .spec file, demonstrating the structure and directives used in package specifications. ```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 ``` -------------------------------- ### Install PHP Extensions for Jeedom Source: https://github.com/jeedom/core/blob/develop/docs/en_US/faq.md Install necessary PHP extensions via apt to resolve 'MYSQL_ATTR_INIT_COMMAND' errors in scenario execution. This command ensures all required modules are present. ```bash yes | sudo apt install -y php-mysql php-curl php-gd php-imap php-xml php-opcache php-soap php-xmlrpc php-common php-dev php-zip php-ssh2 php-mbstring php-ldap ``` -------------------------------- ### network::dnsRun Source: https://github.com/jeedom/core/blob/develop/docs/en_US/jsonrpc_api.md Starts the Jeedom DNS. ```APIDOC ## network::dnsRun ### Description Starts the Jeedom DNS. ``` -------------------------------- ### Mathematica Code Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/mathematica/index.html An example of Mathematica code demonstrating the dualize function, which handles geometric duality based on a quadratic form and a list of polynomials. It includes error handling for singular matrices. ```mathematica (* example Mathematica code *) (* Dualisiert wird anhand einer Polarität an einer Quadrik $x^t Q x = 0$ mit regulärer Matrix $Q$ (also mit $det(Q) \neq 0$), z.B. die Identitätsmatrix. $p$ ist eine Liste von Polynomen - ein Ideal. *) dualize::"singular" = "Q must be regular: found Det[Q]==0."; dualize[ Q_, p_ ] := Block[ { m, n, xv, lv, uv, vars, polys, dual }, If[Det[Q] == 0, Message[dualize::"singular"], m = Length[p]; n = Length[Q] - 1; xv = Table[Subscript[x, i], {i, 0, n}]; lv = Table[Subscript[l, i], {i, 1, m}]; uv = Table[Subscript[u, i], {i, 0, n}]; (* Konstruiere Ideal polys. *) If[m == 0, polys = Q.uv, polys = Join[p, Q.uv - Transpose[Outer[D, p, xv]].lv]]; (* Eliminiere die ersten n + 1 + m Variablen xv und lv aus dem Ideal polys. *) vars = Join[xv, lv]; dual = GroebnerBasis[polys, uv, vars]; (* Ersetze u mit x im Ergebnis. *) ReplaceAll[dual, Rule[u, x]] ] ] ``` -------------------------------- ### plugin::install Source: https://github.com/jeedom/core/blob/develop/docs/en_US/jsonrpc_api.md Installs or updates a given plugin. Requires either plugin_id or logicalId. ```APIDOC ## plugin::install ### Description Installation / Update of a given plugin. ### Settings - **plugin_id** (int, optional): plugin id - **logicalId** (string, optional): plugin name (logical name) ``` -------------------------------- ### Get All Equipment Source: https://github.com/jeedom/core/blob/develop/docs/en_US/jsonrpc_api.md Retrieve a list of all equipment configured in Jeedom. ```json { "jsonrpc": "2.0", "id": "1", "method": "eqLogic::all" } ``` -------------------------------- ### plugin::deamonStart Source: https://github.com/jeedom/core/blob/develop/docs/en_US/jsonrpc_api.md Forces the daemon to start. Requires either plugin_id or logicalId. ```APIDOC ## plugin::deamonStart ### Description Force the demon to start. ### Settings - **plugin_id** (int, optional): plugin id - **logicalId** (string, optional): plugin name (logical name) ``` -------------------------------- ### Factor Time Server Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/factor/index.html A simple time server implementation in Factor, demonstrating basic Factor syntax and structure. ```factor ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. ! A simple time server USING: accessors calendar calendar.format io io.encodings.ascii io.servers kernel threads ; IN: time-server : handle-time-client ( -- ) now timestamp>rfc822 print ; : ( -- threaded-server ) ascii "time-server" >>name 1234 >>insecure [ handle-time-client ] >>handler ; : start-time-server ( -- ) start-server drop ; MAIN: start-time-server ``` -------------------------------- ### Objective-C Example with Protocols and Properties Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/clike/index.html Shows Objective-C syntax including multi-line comments, framework imports, NS_ENUM, class extensions, properties, and string formatting. ```objectivec /* This is a longer comment That spans two lines */ #import "MyClass.h" #import @import BFrameworkModule; NS_ENUM(SomeValues) { aValue = 1 }; // A Class Extension with some properties @interface MyClass () @property(atomic, readwrite, assign) NSInteger anInt; @property(nonatomic, strong, nullable) NSString *aString; @end @implementation YourAppDelegate - (instancetype)initWithString:(NSString *)aStringVar { if ((self = [super init])) { aString = aStringVar; } return self; } - (BOOL)doSomething:(float)progress { NSString *myString = @"This is a ObjC string %f "; myString = [[NSString stringWithFormat:myString, progress] stringByAppendingString:self.aString]; return myString.length > 100 ? NO : YES; } @end ``` -------------------------------- ### Get Scenario Name Source: https://github.com/jeedom/core/blob/develop/docs/en_US/scenario.md Retrieves the name of the current scenario. No specific setup is required beyond having an active scenario object. ```php $scenario->getName(); ``` -------------------------------- ### YAML Example: Shopping List Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/yaml/index.html Shows a basic YAML list representing a shopping list. ```yaml --- # Shopping list [milk, pumpkin pie, eggs, juice] --- ``` -------------------------------- ### Example Custom Launch Time (Hour and Minute) Source: https://github.com/jeedom/core/blob/develop/docs/en_US/scenario.md Custom launch times can be specified using a 'Gi' format (hour without initial zero and minute). ```text 915 ``` -------------------------------- ### Explicit Markup Block Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/rst/index.html Shows 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, footnotes, and comments. ```rst .. _directives: Directives ---------- A directive (:duref:`ref `) is a generic block of explicit markup. ``` -------------------------------- ### Get Equipment by Type Source: https://github.com/jeedom/core/blob/develop/docs/en_US/jsonrpc_api.md Retrieve all equipment belonging to a specified type (plugin). ```json { "jsonrpc": "2.0", "id": "1", "method": "eqLogic::byType", "params": { "type": "virtual" } } ``` -------------------------------- ### Initialize CodeMirror with Lua Mode Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/lua/index.html Initializes a CodeMirror editor instance from a textarea element. This example shows basic setup with theme and bracket matching enabled, suitable for editing Lua code. ```javascript var editor = CodeMirror.fromTextArea(document.getElementById("code"), { matchBrackets: true, theme: "neat" }); ``` -------------------------------- ### Example Custom Launch Time (Hour and Minute) Source: https://github.com/jeedom/core/blob/develop/docs/en_US/scenario.md Custom launch times can be specified using a 'Gi' format (hour without initial zero and minute). ```text 2340 ``` -------------------------------- ### YAML Example: Favorite Movies Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/yaml/index.html Demonstrates a simple YAML list for favorite movies. ```yaml --- # Favorite movies - Casablanca - North by Northwest - The Man Who Wasn't There --- ``` -------------------------------- ### Verilog/SystemVerilog Syntax Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/verilog/index.html Illustrates various Verilog and SystemVerilog constructs including literals, macro definitions, module definitions, and class definitions with comments and tasks. ```verilog // Literals 1'b0 1'bx 1'bz 16'hDC78 'hdeadbeef 'b0011xxzz 1234 32'd5678 3.4e6 -128.7 // Macro definition `define BUS_WIDTH = 8; // Module definition module block( input clk, input rst_n, input [`BUS_WIDTH-1:0] data_in, output [`BUS_WIDTH-1:0] data_out ); always @(posedge clk or negedge rst_n) begin if (~rst_n) begin data_out <= 8'b0; end else begin data_out <= data_in; end if (~rst_n) data_out <= 8'b0; else data_out <= data_in; if (~rst_n) begin data_out <= 8'b0; end else begin data_out <= data_in; end end endmodule // Class definition class test; /** * Sum two integers */ function int sum(int a, int b); int result = a + b; string msg = $sformatf("%d + %d = %d", a, b, result); $display(msg); return result; endfunction task delay(int num_cycles); repeat(num_cycles) #1; endtask endclass ``` -------------------------------- ### XQuery Basic Syntax and Comments Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/xquery/index.html Demonstrates basic XQuery syntax, including version declaration, comments, let bindings, and element constructors. This is a foundational example for understanding XQuery structure. ```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 ``` -------------------------------- ### Turtle RDF Data Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/turtle/index.html An example of RDF data formatted in the Turtle 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/jeedom/core/blob/develop/3rdparty/codemirror/mode/javascript/json-ld.html An example of JSON-LD data structure used for demonstrating the mode. ```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" } } ``` -------------------------------- ### C Language Example with ZMQ and Pthreads Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/clike/index.html Demonstrates C code using ZeroMQ and pthreads for asynchronous communication. Includes context management and thread creation. ```c /* C demo code */ #include #include #include #include #include #include #include typedef struct { void* arg_socket; zmq_msg_t* arg_msg; char* arg_string; unsigned long arg_len; int arg_int, arg_command; int signal_fd; int pad; void* context; sem_t sem; } acl_zmq_context; #define p(X) (context->arg_##X) void* zmq_thread(void* context_pointer) { acl_zmq_context* context = (acl_zmq_context*)context_pointer; char ok = 'K', err = 'X'; int res; while (1) { while ((res = sem_wait(&context->sem)) == EINTR); if (res) {write(context->signal_fd, &err, 1); goto cleanup;} switch(p(command)) { case 0: goto cleanup; case 1: p(socket) = zmq_socket(context->context, p(int)); break; case 2: p(int) = zmq_close(p(socket)); break; case 3: p(int) = zmq_bind(p(socket), p(string)); break; case 4: p(int) = zmq_connect(p(socket), p(string)); break; case 5: p(int) = zmq_getsockopt(p(socket), p(int), (void*)p(string), &p(len)); break; case 6: p(int) = zmq_setsockopt(p(socket), p(int), (void*)p(string), p(len)); break; case 7: p(int) = zmq_send(p(socket), p(msg), p(int)); break; case 8: p(int) = zmq_recv(p(socket), p(msg), p(int)); break; case 9: p(int) = zmq_poll(p(socket), p(int), p(len)); break; } p(command) = errno; write(context->signal_fd, &ok, 1); } cleanup: close(context->signal_fd); free(context_pointer); return 0; } void* zmq_thread_init(void* zmq_context, int signal_fd) { acl_zmq_context* context = malloc(sizeof(acl_zmq_context)); pthread_t thread; context->context = zmq_context; context->signal_fd = signal_fd; sem_init(&context->sem, 1, 0); pthread_create(&thread, 0, &zmq_thread, context); pthread_detach(thread); return context; } ``` -------------------------------- ### Elm Code Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/elm/index.html A basic example demonstrating Elm syntax for graphics and time. ```elm import Color exposing ( .. ) import Graphics.Collage exposing ( .. ) import Graphics.Element exposing ( .. ) import Time exposing ( .. ) main = Signal.map clock (every second) clock t = collage 400 400 [ filled lightGrey (ngon 12 110), outlined (solid grey) (ngon 12 110), hand orange 100 t, hand charcoal 100 (t / 60), hand charcoal 60 (t / 720) ] hand clr len time = let angle = degrees (90 - 6 * inSeconds time) in segment (0, 0) (fromPolar (len, angle)) |> traced (solid clr) ``` -------------------------------- ### Forth Insertion Sort Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/forth/index.html An example of an insertion sort algorithm implemented in Forth. ```forth : cell- 1 cells - ; : insert ( start end -- start ) dup @ >r ( r: v ) begin 2dup < while r@ over cell- @ < while cell- dup @ over cell+ ! repeat then r> swap ! ; : sort ( array len -- ) 1 ?do dup i cells + insert loop drop ; ``` -------------------------------- ### Swift Protocol and Struct Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/swift/index.html Illustrates Swift syntax for protocols, structs, and type casting, demonstrating basic Swift language features. ```swift protocol HeaderViewProtocol { func setTitle(\_ string: String) } struct AnyHeaderView { let view: UIView let headerView: HeaderViewProtocol init(view: T) where T: HeaderViewProtocol { self.view = view self.headerView = view } } let header = AnyHeaderView(view: myView) header.headerView.setTitle("hi") struct HeaderView { let view: UIView let setTitle: (String) -> () } var label = UILabel() let header = HeaderView(view: label) { str in label.text = str } header.setTitle("hello") ``` -------------------------------- ### HTTP Request Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/http/index.html An example of an HTTP request with headers and a body, as highlighted 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! ``` -------------------------------- ### Hxml Configuration Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/haxe/index.html Shows a typical Hxml configuration for a project, including compiler flags, output paths, and library definitions. ```hxml -cp test -js path/to/file.js #-remap nme:flash --next -D source-map-content -cmd 'test' -lib lime ``` -------------------------------- ### Django Template Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/django/index.html An example of a Django template structure including variables, tags, and comments. ```html My Django web application

{{ page.title|capfirst }}

    {# traverse a list of items and produce links to their views. #} {% for item in items %}
  • {{ item.name }}
  • {% empty %}
  • You have no items in your list.
  • {% endfor %}
{% comment "this is a forgotten footer" %}
{% endcomment %} ``` -------------------------------- ### N-Triples Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/ntriples/index.html Demonstrates the syntax for N-Triples documents, including URIs, literals with language tags, and blank nodes. ```text . "literal 1" . _:bnode3 . _:bnode4 "literal 2"@lang . _:bnode5 "literal 3"^^ . ``` -------------------------------- ### Example Trigger Condition Source: https://github.com/jeedom/core/blob/develop/docs/en_US/scenario.md Conditions can be entered in triggered mode. This example shows how to use a device state as a trigger. ```text #[Garage][Open Garage][Ouverture]# == 1 ``` -------------------------------- ### YAML Example: Complex Structure Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/yaml/index.html A comprehensive YAML example showing nested structures, anchors, aliases, and multi-line strings. ```yaml --- receipt: Oz-Ware Purchase Invoice date: 2007-08-06 customer: given: Dorothy family: Gale items: - part_no: A4786 descrip: Water Bucket (Filled) price: 1.47 quantity: 4 - part_no: E1628 descrip: High Heeled "Ruby" Slippers size: 8 price: 100.27 quantity: 1 bill-to: &id001 street: | 123 Tornado Alley Suite 16 city: East Centerville state: KS ship-to: *id001 specialDelivery: > Follow the Yellow Brick Road to the Emerald City. Pay no attention to the man behind the curtain. --- ``` -------------------------------- ### Fortran Program Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/fortran/index.html A sample Fortran program demonstrating basic input, calculations, and output. This code is used to showcase the syntax highlighting capabilities of the Fortran mode. ```fortran program average ! Read in some numbers and take the average ! As written, if there are no data points, an average of zero is returned ! While this may not be desired behavior, it keeps this example simple implicit none real, dimension(:), allocatable :: points integer :: number_of_points real :: average_points=0., positive_average=0., negative_average=0. write (*,*) "Input number of points to average:" read (*,*) number_of_points allocate (points(number_of_points)) write (*,*) "Enter the points to average:" read (*,*) points ! Take the average by summing points and dividing by number_of_points if (number_of_points > 0) average_points = sum(points) / number_of_points ! Now form average over positive and negative points only if (count(points > 0.) > 0) then positive_average = sum(points, points > 0.) / count(points > 0.) end if if (count(points < 0.) > 0) then negative_average = sum(points, points < 0.) / count(points < 0.) end if deallocate (points) ! Print result to terminal write (*,'(a,g12.4)') 'Average = ', average_points write (*,'(a,g12.4)') 'Average of positive points = ', positive_average write (*,'(a,g12.4)') 'Average of negative points = ', negative_average end program average ``` -------------------------------- ### Example Tornado HTML Template Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/tornado/index.html An example of an HTML file with embedded Tornado template syntax, including variables and loops. ```html My Tornado web application

{{ title }}

    {% for item in items %}
  • {% item.name %}
  • {% empty %}
  • You have no items in your list.
  • {% end %}
``` -------------------------------- ### Pascal Syntax Examples Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/pascal/index.html Demonstrates various Pascal control flow structures including while, if-else, for, repeat-until, and case statements. ```pascal while a <> b do writeln('Waiting'); if a > b then writeln('Condition met') else writeln('Condition not met'); for i := 1 to 10 do writeln('Iteration: ', i:1); repeat a := a + 1 until a = 10; case i of 0: write('zero'); 1: write('one'); 2: write('two') end; ``` -------------------------------- ### Baseline Setup in CoffeeScript Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/coffeescript/index.html Establishes the root object (window or global) and saves the previous value of the '_' variable. ```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._ ``` -------------------------------- ### Gas Assembler Syntax Example Source: https://github.com/jeedom/core/blob/develop/3rdparty/codemirror/mode/gas/index.html This is an example of AT&T assembler syntax handled by the Gas mode, including multi-line and single-line comments. ```gas .syntax unified .global main /* * A * multi-line * comment. */ @ A single line comment. main: push {sp, lr} ldr r0, =message bl puts mov r0, #0 pop {sp, pc} message: .asciz "Hello world!
" ```