CSS Syntax Highlight Test
Source code examples for testing syntax highlighting.
JavaScript (with line numbers and lines 12-15 highlighted)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var ServiceRegistry = require('caplin/core/ServiceRegistry');
var WatchlistServiceEvents = require('caplin/watchlist/WatchlistServiceEvents');
var watchlistService = ServiceRegistry.getService('caplin.watchlist.watchlist-service');
// Map of watchlists
var watchlists = {};
/**
* Comment block
*/
watchlistService.on(WatchlistServiceEvents.ADDED, function(watchlist) {
watchlists['' + watchlist.getId()] = watchlist;
alert('watchlist with following name has been added: ', watchlist.getName());
});
watchlistService.on(WatchlistServiceEvents.REMOVED, function(watchlist) {
delete watchlists['' + watchlist.getId()];
alert('watchlist with following name has been removed: ', watchlist.getName());
});
Java
package com.example.TemplateTradeListener;
/**
* Trade listener
*/
public class TemplateTradeListener implements TradeListener
{
/**
* @param event The TradeEvent
*/
@Override
public void receiveEvent(TradeEvent event) throws TradeException
{
logger.log(Level.INFO, "receiveEvent");
String transition = event.getType();
if (transition.equals("Open")) {
// Fields coming from the client
Map<String, String> fields = event.getFields();
String user = event.getTrade().getChannel().getUser();
String requestID = fields.get("RequestID");
String baseCurrency = fields.get("BaseCurrency");
String termCurrency = fields.get("TermCurrency");
String currencyPair = baseCurrency + "/" + termCurrency;
double amount = Double.parseDouble(fields.get("Amount"));
double price = Double.parseDouble(fields.get("Price"));
String buySellString = fields.get("BuySell");
System.out.println("Open message from user "
+ user + " to " + buySellString + " " + currencyPair);
}
try {
throw new Exception('');
} catch (Exception e) {
//
} finally {
//
}
}
}
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<script type="text/javascript" src="<liberator url>/sljs/streamlink.js"></script>
</head>
<body>
<script>
var streamlink = caplin.streamlink.StreamLinkFactory.create({
liberator_urls: "<liberator url>",
keymaster_url:"<app server url>/keymaster/servlet/StandardKeyMaster",
keymaster_poll_url:"<app server url>/keymaster/servlet/Poll",
keymaster_cross_domain_authentication: true
});
streamlink.getLogger().addListener({
onLog: function(logInfo) {
log(logInfo);
}
}, caplin.streamlink.LogLevel.FINEST);
function log(message) {
var pre = document.createElement("pre");
var txt = document.createTextNode(message);
pre.appendChild(txt);
document.body.appendChild(pre);
}
streamlink.connect();
</script>
</body>
</html>
XML
<?xml version="1.0"?>
<!-- Comment -->
<tradeModels>
<tradeModel name="ESP" initialState="Initial">
<state name="Initial">
<transition target="OpenSent" trigger="Open" source="client">
<field name="StateModelName" description="ESP model name" required="true" />
<field name="RequestID" description="Request ID" required="true" />
<field name="QuoteID" description="Quote ID" required="true" />
<field name="InstrumentName" description="Instrument Name" required="true" />
<field name="DealtCurrency" description="Dealt currency" required="true" />
<field name="BuySell" description="BuySell indicator" required="true" />
<field name="Price" description="Price" />
</transition>
</state>
<state name="Timeout" />
<state name="OpenSent" timeout="10" timeoutState="Timeout">
<transition target="Opened" trigger="OpenAck" source="server">
<field name="RequestID" description="Request ID" required="true" />
<field name="StateModelName" description="ESP model name" required="true" default="ESP" />
<field name="BuySell" description="BuySell indicator" required="true" default="BUY" />
</transition>
</state>
<state name="Opened" timeout="10" timeoutState="Timeout">
<transition target="TradeConfirmed" trigger="TradeConfirmation" source="server">
<field name="RequestID" description="Request ID" required="true" />
<field name="TradeID" description="Request ID" required="true" />
</transition>
<transition target="TradePassed" trigger="Pass" source="server" />
<transition target="TradeExpired" trigger="Expired" source="server" />
</state>
<state name="TradeConfirmed" />
<state name="TradePassed" />
<state name="TradeExpired" />
</tradeModel>
</tradeModels>
SQL
-- Comment
CREATE TABLE IF NOT EXISTS TF_WATCHLIST_PERSISTENCE (
WATCHLIST_USER VARCHAR(250) NOT NULL,
WATCHLIST_ID VARCHAR(250) NOT NULL,
WATCHLIST_DATA TEXT NOT NULL,
WATCHLIST_POSITION NUMBER,
PRIMARY KEY (WATCHLIST_USER, WATCHLIST_ID)
);
CREATE TRIGGER IF NOT EXISTS TF_WATCHLIST_PERSISTENCE_ADD_POSITION
AFTER INSERT ON TF_WATCHLIST_PERSISTENCE
FOR EACH ROW WHEN NEW.WATCHLIST_POSITION IS NULL
BEGIN
UPDATE TF_WATCHLIST_PERSISTENCE
SET WATCHLIST_POSITION = (
SELECT COUNT(*) - 1
FROM TF_WATCHLIST_PERSISTENCE
WHERE WATCHLIST_USER = NEW.WATCHLIST_USER
)
WHERE rowid = NEW.rowid;
END;
YAML
load:
- bundles/i18n/en_i18n.bundle
serve:
- bundles/html.bundle
- bundles/xml.bundle
Bash
#!/bin/bash
# rpm-check.sh
# Queries an rpm file for description, listing,
# and whether it can be installed.
# Saves output to a file.
#
# This script illustrates using a code block.
SUCCESS=0
E_NOARGS=65
if [ -z "$1" ]
then
echo "Usage: `basename $0` rpm-file"
exit $E_NOARGS
fi
{ # Begin code block.
echo
echo "Archive Description:"
rpm -qpi $1 # Query description.
echo
echo "Archive Listing:"
rpm -qpl $1 # Query listing.
echo
rpm -i --test $1 # Query whether rpm file can be installed.
if [ "$?" -eq $SUCCESS ]
then
echo "$1 can be installed."
else
echo "$1 cannot be installed."
fi
echo # End code block.
} > "$1.test" # Redirects output of everything in block to file.
echo "Results of rpm test in file $1.test"
# See rpm man page for explanation of options.
exit 0
JSON
[
{
"color": "red",
"value": "#f00"
},
{
"color": "green",
"value": "#0f0"
},
{
"color": "blue",
"value": "#00f"
},
{
"color": "cyan",
"value": "#0ff"
},
{
"color": "magenta",
"value": "#f0f"
},
{
"color": "yellow",
"value": "#ff0"
},
{
"color": "black",
"value": "#000"
}
]
Lua
require("log")
require("math")
function initialise()
log.log(log.INFO,"Normalisation initialisation happening\n")
end
--
-- Apply these RPN rules to an update
--
-- Rule 1 filter 0 price updates
-- Rule 2 filter >= 40% (four period moving average)
--
-- param update - Current update
-- param cache - Last update
--
-- retval 0 - Rules passed or can't be applied
-- retval 1 - Rule failed
--
function validate(update, cache)
local trdprc1 = update:getfield("TRDPRC_1")
if trdprc1 == nil then
return 0
end
-- Rule 1: reject the update if TRDPRC_1 is zero
-- RPN equivalent: "$TRDPRC_1 0 ="
if tonumber(trdprc1) == 0 then
return 1
end
local trdprc2 = update:getfield("TRDPRC_2")
if trdprc2 == nil then
return 0
end
local trdprc3 = update:getfield("TRDPRC_3")
if trdprc3 == nil then
return 0
end
local trdprc4 = update:getfield("TRDPRC_4")
if trdprc4 == nil then
return 0
end
local trdprc5 = update:getfield("TRDPRC_5")
if trdprc5 == nil then
return 0
end
-- Rule 2: reject the update if the difference between TRDPRC_1 and
-- the four-period moving average is 40% or greater.
-- RPN equivalent: "$TRDPRC_1 $TRDPRC_2 $TRDPRC_3 $TRDPRC_4 $TRDPRC_5 + + + 4 / / 1 - ~ 0.4 }"
local moving_average = math.abs( ( trdprc1 / ( (trdprc2 + trdprc3 + trdprc4 + trdprc5 ) / 4 ) ) - 1 )
if moving_average >= 0.4 then
return 1
end
return 0
end
CSS
audio, canvas, video {
display: inline-block
}
audio:not([controls]) {
display: none;
height: 0
}
[hidden], template {
display: none
}
script {
display: none !important
}
html {
font-family: sans-serif;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%
}
Console
$ sudo pvdisplay
[sudo] password for ianss:
--- Physical volume ---
PV Name /dev/sda5
VG Name xubuntu-vg
PV Size 69.52 GiB / not usable 2.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 17797
Free PE 12
Allocated PE 17785
PV UUID fNpiQZ-0JNU-wha0-BKXk-dkis-lVLC-NA1ViS
$ free -h
total used free shared buff/cache available
Mem: 5.8G 1.3G 3.2G 98M 1.3G 4.2G
Swap: 3.0G 0B 3.0G
INI
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
[mysqld]
#
# Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
DIFF
@Override
public void receiveEvent(TradeEvent event) throws TradeException
{
logger.log(Level.INFO, "receiveEvent");
String transition = event.getType();
if (transition.equals("Open")) {
// Fields coming from the client
Map<String, String> fields = event.getFields();
String user = event.getTrade().getChannel().getUser();
String requestID = fields.get("RequestID");
String baseCurrency = fields.get("BaseCurrency");
String termCurrency = fields.get("TermCurrency");
String currencyPair = baseCurrency + "/" + termCurrency;
double amount = Double.parseDouble(fields.get("Amount"));
double price = Double.parseDouble(fields.get("Price"));
String buySellString = fields.get("BuySell");
System.out.println("Open message from user "
+ user + " to " + buySellString + " " + currencyPair);
- // Send a "Confirm" event to the client
- TradeEvent tradeEvent = event.getTrade().createEvent("Confirm");
- event.getTrade().sendEvent(tradeEvent);
+ System.out.println("Open message from user "
+ + user + " to " + buySellString + " " + currencyPair);
+
+ // Convert buySellString to an FXTradeReport constant
+ char buySell;
+ if (buySellString.equals("BUY")) {
+ buySell = FXTradeReport.BUY;
+ } else {
+ buySell = FXTradeReport.SELL;
+ }
+
+ // Execute the trade
+ messenger.executeTrade(user, requestID, currencyPair,
+ amount, buySell, price);
}
}