From 11b6fdfd382f24200f564b328e0bb1be1a6bb22c Mon Sep 17 00:00:00 2001 From: Kevin Batdorf Date: Wed, 16 Aug 2023 00:21:48 -0400 Subject: [PATCH 1/2] feat: add additional sample code --- packages/shiki/samples/Marko.sample | 13 -- packages/shiki/samples/ada.sample | 29 +-- packages/shiki/samples/apache.sample | 39 ++++ packages/shiki/samples/apex.sample | 22 ++- packages/shiki/samples/apl.sample | 37 ++++ packages/shiki/samples/astro.sample | 38 ++-- packages/shiki/samples/bash.sample | 28 +++ packages/shiki/samples/bat.sample | 34 ++-- packages/shiki/samples/bibtex.sample | 28 +++ packages/shiki/samples/clj.sample | 14 ++ packages/shiki/samples/cobol.sample | 106 +++++++++-- packages/shiki/samples/codeql.sample | 8 +- packages/shiki/samples/css.sample | 49 +++-- packages/shiki/samples/cypher.sample | 26 ++- packages/shiki/samples/dream-maker.sample | 24 +++ packages/shiki/samples/elixir.sample | 34 +++- packages/shiki/samples/gherkin.sample | 11 ++ packages/shiki/samples/gnuplot.sample | 20 +++ packages/shiki/samples/graphql.sample | 15 ++ packages/shiki/samples/groovy.sample | 18 ++ packages/shiki/samples/hack.sample | 23 +++ packages/shiki/samples/haml.sample | 40 +++++ packages/shiki/samples/handlebars.sample | 17 ++ packages/shiki/samples/haskell.sample | 23 +++ packages/shiki/samples/hlsl.sample | 20 +++ packages/shiki/samples/html.sample | 67 ++++--- packages/shiki/samples/http.sample | 28 +-- packages/shiki/samples/ini.sample | 12 ++ packages/shiki/samples/java.sample | 38 +++- packages/shiki/samples/javascript.sample | 45 ++--- packages/shiki/samples/jinja-html.sample | 22 +++ packages/shiki/samples/json.sample | 38 ++++ packages/shiki/samples/json5.sample | 2 +- packages/shiki/samples/jsonc.sample | 34 ++++ packages/shiki/samples/jsonl.sample | 31 ++++ packages/shiki/samples/jsonnet.sample | 33 ++++ packages/shiki/samples/jsx.sample | 30 ++++ packages/shiki/samples/julia.sample | 16 ++ packages/shiki/samples/latex.sample | 31 ++++ packages/shiki/samples/less.sample | 31 ++++ packages/shiki/samples/lisp.sample | 25 +++ packages/shiki/samples/logo.sample | 21 +++ packages/shiki/samples/lua.sample | 18 ++ packages/shiki/samples/make.sample | 26 +++ packages/shiki/samples/markdown.sample | 161 +++++++++++++++++ packages/shiki/samples/marko.sample | 2 +- packages/shiki/samples/matlab.sample | 22 +++ packages/shiki/samples/mdx.sample | 13 ++ packages/shiki/samples/mermaid.sample | 23 +++ packages/shiki/samples/nginx.sample | 72 ++++++++ packages/shiki/samples/nim.sample | 49 +++++ packages/shiki/samples/nix.sample | 44 +++++ packages/shiki/samples/objective-c.sample | 13 ++ packages/shiki/samples/objective-cpp.sample | 33 ++++ packages/shiki/samples/ocaml.sample | 23 +++ packages/shiki/samples/pascal.sample | 109 +++++++++++ packages/shiki/samples/perl.sample | 24 +++ packages/shiki/samples/php.sample | 29 +++ packages/shiki/samples/plsql.sample | 20 +++ packages/shiki/samples/postcss.sample | 19 ++ packages/shiki/samples/powershell.sample | 22 +++ packages/shiki/samples/prolog.sample | 179 +++++++++++++++++++ packages/shiki/samples/pug.sample | 18 ++ packages/shiki/samples/puppet.sample | 19 ++ packages/shiki/samples/purescript.sample | 81 +++++++++ packages/shiki/samples/r.sample | 21 +++ packages/shiki/samples/raku.sample | 37 ++++ packages/shiki/samples/razor.sample | 25 +++ packages/shiki/samples/riscv.sample | 30 ++++ packages/shiki/samples/rst.sample | 27 +++ packages/shiki/samples/rust.sample | 39 ++++ packages/shiki/samples/sas.sample | 17 ++ packages/shiki/samples/sass.sample | 27 +++ packages/shiki/samples/scala.sample | 14 ++ packages/shiki/samples/scheme.sample | 26 +++ packages/shiki/samples/scss.sample | 17 ++ packages/shiki/samples/shaderlab.sample | 60 +++++++ packages/shiki/samples/shellscript.sample | 28 +++ packages/shiki/samples/smalltalk.sample | 11 ++ packages/shiki/samples/solidity.sample | 51 ++++++ packages/shiki/samples/sql.sample | 17 ++ packages/shiki/samples/ssh-config.sample | 47 +++++ packages/shiki/samples/stylus.sample | 33 ++++ packages/shiki/samples/svelte.sample | 28 +++ packages/shiki/samples/swift.sample | 20 +++ packages/shiki/samples/system-verilog.sample | 30 ++++ packages/shiki/samples/tcl.sample | 51 ++++++ packages/shiki/samples/tex.sample | 29 +++ packages/shiki/samples/toml.sample | 25 +++ packages/shiki/samples/twig.sample | 18 ++ packages/shiki/samples/typescript.sample | 24 +++ packages/shiki/samples/vb.sample | 38 ++++ packages/shiki/samples/verilog.sample | 30 ++++ packages/shiki/samples/vhdl.sample | 43 +++++ packages/shiki/samples/viml.sample | 12 ++ packages/shiki/samples/vue-html.sample | 15 ++ packages/shiki/samples/vue.sample | 45 +++++ packages/shiki/samples/wasm.sample | 65 +++++++ packages/shiki/samples/wenyan.sample | 25 +++ packages/shiki/samples/xml.sample | 122 +++++++++++++ packages/shiki/samples/xsl.sample | 65 +++++++ packages/shiki/samples/yaml.sample | 50 ++++++ packages/shiki/samples/zsh.sample | 20 +++ 103 files changed, 3362 insertions(+), 159 deletions(-) delete mode 100644 packages/shiki/samples/Marko.sample create mode 100644 packages/shiki/samples/apache.sample create mode 100644 packages/shiki/samples/apl.sample create mode 100644 packages/shiki/samples/bash.sample create mode 100644 packages/shiki/samples/bibtex.sample create mode 100644 packages/shiki/samples/clj.sample create mode 100644 packages/shiki/samples/dream-maker.sample create mode 100644 packages/shiki/samples/gherkin.sample create mode 100644 packages/shiki/samples/gnuplot.sample create mode 100644 packages/shiki/samples/graphql.sample create mode 100644 packages/shiki/samples/groovy.sample create mode 100644 packages/shiki/samples/hack.sample create mode 100644 packages/shiki/samples/haml.sample create mode 100644 packages/shiki/samples/handlebars.sample create mode 100644 packages/shiki/samples/haskell.sample create mode 100644 packages/shiki/samples/hlsl.sample create mode 100644 packages/shiki/samples/ini.sample create mode 100644 packages/shiki/samples/jinja-html.sample create mode 100644 packages/shiki/samples/json.sample create mode 100644 packages/shiki/samples/jsonc.sample create mode 100644 packages/shiki/samples/jsonl.sample create mode 100644 packages/shiki/samples/jsonnet.sample create mode 100644 packages/shiki/samples/jsx.sample create mode 100644 packages/shiki/samples/julia.sample create mode 100644 packages/shiki/samples/latex.sample create mode 100644 packages/shiki/samples/less.sample create mode 100644 packages/shiki/samples/lisp.sample create mode 100644 packages/shiki/samples/logo.sample create mode 100644 packages/shiki/samples/lua.sample create mode 100644 packages/shiki/samples/make.sample create mode 100644 packages/shiki/samples/markdown.sample create mode 100644 packages/shiki/samples/matlab.sample create mode 100644 packages/shiki/samples/mdx.sample create mode 100644 packages/shiki/samples/mermaid.sample create mode 100644 packages/shiki/samples/nginx.sample create mode 100644 packages/shiki/samples/nim.sample create mode 100644 packages/shiki/samples/nix.sample create mode 100644 packages/shiki/samples/objective-c.sample create mode 100644 packages/shiki/samples/objective-cpp.sample create mode 100644 packages/shiki/samples/ocaml.sample create mode 100644 packages/shiki/samples/pascal.sample create mode 100644 packages/shiki/samples/perl.sample create mode 100644 packages/shiki/samples/php.sample create mode 100644 packages/shiki/samples/plsql.sample create mode 100644 packages/shiki/samples/postcss.sample create mode 100644 packages/shiki/samples/powershell.sample create mode 100644 packages/shiki/samples/prolog.sample create mode 100644 packages/shiki/samples/pug.sample create mode 100644 packages/shiki/samples/puppet.sample create mode 100644 packages/shiki/samples/purescript.sample create mode 100644 packages/shiki/samples/r.sample create mode 100644 packages/shiki/samples/raku.sample create mode 100644 packages/shiki/samples/razor.sample create mode 100644 packages/shiki/samples/riscv.sample create mode 100644 packages/shiki/samples/rst.sample create mode 100644 packages/shiki/samples/rust.sample create mode 100644 packages/shiki/samples/sas.sample create mode 100644 packages/shiki/samples/sass.sample create mode 100644 packages/shiki/samples/scala.sample create mode 100644 packages/shiki/samples/scheme.sample create mode 100644 packages/shiki/samples/scss.sample create mode 100644 packages/shiki/samples/shaderlab.sample create mode 100644 packages/shiki/samples/shellscript.sample create mode 100644 packages/shiki/samples/smalltalk.sample create mode 100644 packages/shiki/samples/solidity.sample create mode 100644 packages/shiki/samples/sql.sample create mode 100644 packages/shiki/samples/ssh-config.sample create mode 100644 packages/shiki/samples/stylus.sample create mode 100644 packages/shiki/samples/svelte.sample create mode 100644 packages/shiki/samples/swift.sample create mode 100644 packages/shiki/samples/system-verilog.sample create mode 100644 packages/shiki/samples/tcl.sample create mode 100644 packages/shiki/samples/tex.sample create mode 100644 packages/shiki/samples/toml.sample create mode 100644 packages/shiki/samples/twig.sample create mode 100644 packages/shiki/samples/typescript.sample create mode 100644 packages/shiki/samples/vb.sample create mode 100644 packages/shiki/samples/verilog.sample create mode 100644 packages/shiki/samples/vhdl.sample create mode 100644 packages/shiki/samples/viml.sample create mode 100644 packages/shiki/samples/vue-html.sample create mode 100644 packages/shiki/samples/vue.sample create mode 100644 packages/shiki/samples/wasm.sample create mode 100644 packages/shiki/samples/wenyan.sample create mode 100644 packages/shiki/samples/xml.sample create mode 100644 packages/shiki/samples/xsl.sample create mode 100644 packages/shiki/samples/yaml.sample create mode 100644 packages/shiki/samples/zsh.sample diff --git a/packages/shiki/samples/Marko.sample b/packages/shiki/samples/Marko.sample deleted file mode 100644 index af35e02b4..000000000 --- a/packages/shiki/samples/Marko.sample +++ /dev/null @@ -1,13 +0,0 @@ - - <@then>Done - <@catch|err|> - - Took too long to fetch the data! - - - Promise failed with ${err.message}. - - - - -# from https://markojs.com/docs/core-tags/ \ No newline at end of file diff --git a/packages/shiki/samples/ada.sample b/packages/shiki/samples/ada.sample index fe7fff5b9..63dbb811a 100644 --- a/packages/shiki/samples/ada.sample +++ b/packages/shiki/samples/ada.sample @@ -1,13 +1,22 @@ -with Ada.Text_IO; use Ada.Text_IO; - -procedure Learn is - - subtype Alphabet is Character range 'A' .. 'Z'; +with + Ada.Text_IO, + Ada.Integer_Text_IO; +use Ada; +procedure fizz_buzz is begin + for i in 1..100 loop + if i mod 15 = 0 then + Text_IO.Put_Line("fizz buzz"); + elsif i mod 5 = 0 then + Text_IO.Put_Line("buzz"); + elsif i mod 3 = 0 then + Text_IO.Put_Line("fizz"); + else + Integer_Text_IO.put(i, Width => 0); + Text_IO.New_Line; + end if; + end loop; +end fizz_buzz; - Put_Line ("Learning Ada from " & Alphabet'First & " to " & Alphabet'Last); - -end Learn; - --- From https://learn.adacore.com/ \ No newline at end of file +-- From https://github.com/kylelk/ada-examples/blob/master/fizz_buzz.adb diff --git a/packages/shiki/samples/apache.sample b/packages/shiki/samples/apache.sample new file mode 100644 index 000000000..7d3391b8e --- /dev/null +++ b/packages/shiki/samples/apache.sample @@ -0,0 +1,39 @@ +# Apache httpd v2.4 minimal configuration +# see https://wiki.apache.org/httpd/Minimal_Config for documentation + +ServerRoot ${GITPOD_REPO_ROOT} + +PidFile ${APACHE_PID_FILE} +User ${APACHE_RUN_USER} +Group ${APACHE_RUN_GROUP} + +# Modules as installed/activated via apt-get +IncludeOptional /etc/apache2/mods-enabled/*.load +IncludeOptional /etc/apache2/mods-enabled/*.conf + +# Configure hostname and port for server +ServerName ${APACHE_SERVER_NAME} +Listen *:8080 + +# Configure Logging +LogFormat "%h %l %u %t \"%r\" %>s %b" common +CustomLog ${APACHE_LOG_DIR}/access.log common +ErrorLog ${APACHE_LOG_DIR}/error.log + +# Never change this block + + AllowOverride None + Require all denied + + +# Direcrory and files to be served +DirectoryIndex index.html +DocumentRoot "${GITPOD_REPO_ROOT}/www" + + Require all granted + + +# Include conf installed via apt-get +IncludeOptional /etc/apache2/conf-enabled/*.conf + +# https://github.com/gitpod-io/apache-example/blob/master/apache/apache.conf diff --git a/packages/shiki/samples/apex.sample b/packages/shiki/samples/apex.sample index 9171ed57a..e3db2371e 100644 --- a/packages/shiki/samples/apex.sample +++ b/packages/shiki/samples/apex.sample @@ -1,5 +1,19 @@ -String s1 = 'Salesforce and force.com'; -String s2 = s1.remove('force'); -System.debug( 's2'+ s2);// 'Sales and .com' +public class EmailManager { -// From https://www.guru99.com/apex-tutorial.html \ No newline at end of file + public static void sendMail(String address, String subject, String body) { + Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); + String[] toAddresses = new String[] {address}; + mail.setToAddresses(toAddresses); + mail.setSubject(subject); + mail.setPlainTextBody(body); + Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); + } + +} + +String address = 'YOUR_EMAIL_ADDRESS'; +String subject = 'Speaker Confirmation'; +String body = 'Thank you for speaking at the conference.'; +EmailManager.sendMail(address, subject, body); + +// From http://ccoenraets.github.io/salesforce-developer-workshop/Creating-an-Apex-Class.html diff --git a/packages/shiki/samples/apl.sample b/packages/shiki/samples/apl.sample new file mode 100644 index 000000000..c2ccae7e2 --- /dev/null +++ b/packages/shiki/samples/apl.sample @@ -0,0 +1,37 @@ +CND ← { + X ← ⍵ + a ← 0.31938153 ¯0.356563782 1.781477937 ¯1.821255978 1.330274429 + + l ← |X + k ← ÷1+0.2316419×l + w ← 1 - (÷((2×(○1))*0.5)) × (*-(l×l)÷2) × (a +.× (k*⍳5)) + + ((|0⌊×X)×(1-w))+(1-|0⌊×X)×w +} + +⍝ S - current price +⍝ X - strike price +⍝ T - expiry in years +⍝ r - riskless interest rate +⍝ v - volatility + +S ← 60 +X ← 65 +T ← 1 +r ← 0.1 +v ← 0.2 + +d1 ← { ((⍟S÷X)+(r+(v*2)÷2)×⍵)÷(v×⍵*0.5) } +d2 ← { (d1 ⍵) -v×⍵*0.5 } + +⍝ Call price +callPrice ← { (S×CND(d1 ⍵))-(X×*-r×⍵)×CND(d2 ⍵) } + +avg ← { (+/⍵) ÷ ⊃⍴ ⍵ } + +⎕←avg callPrice¨ (⍳ 100000) ÷ 10000 + +⍝ Put price (not tested) +⍝ putPrice ← { (X×*-r×⍵)×CND(-d2 ⍵)-S×CND(-d1 ⍵) } + +⍝ From https://github.com/melsman/apltail/blob/master/tests/blacksch.apl diff --git a/packages/shiki/samples/astro.sample b/packages/shiki/samples/astro.sample index af46f47a4..6d82efab3 100644 --- a/packages/shiki/samples/astro.sample +++ b/packages/shiki/samples/astro.sample @@ -1,16 +1,28 @@ --- -const name = "world" +// Your component script here! +import Banner from '../components/Banner.astro'; +import ReactPokemonComponent from '../components/ReactPokemonComponent.jsx'; +const myFavoritePokemon = [/* ... */]; +const { title } = Astro.props; --- + +{/* JS comment syntax is also valid! */} - - - - - Hello, {name} - - -
-

Hello, {name}

-
- - + +

Hello, world!

+ + +

{title}

+ + + + + +
    + {myFavoritePokemon.map((data) =>
  • {data.name}
  • )} +
+ + +

+ + diff --git a/packages/shiki/samples/bash.sample b/packages/shiki/samples/bash.sample new file mode 100644 index 000000000..9f948b529 --- /dev/null +++ b/packages/shiki/samples/bash.sample @@ -0,0 +1,28 @@ +#!/bin/bash +# weather.sh +# Copyright 2018 computer-geek64. All rights reserved. + +program=Weather +version=1.1 +year=2018 +developer=computer-geek64 + +case $1 in +-h | --help) + echo "$program $version" + echo "Copyright $year $developer. All rights reserved." + echo + echo "Usage: weather [options]" + echo "Option Long Option Description" + echo "-h --help Show the help screen" + echo "-l [location] --location [location] Specifies the location" + ;; +-l | --location) + curl https://wttr.in/$2 + ;; +*) + curl https://wttr.in + ;; +esac + +# From https://github.com/ruanyf/simple-bash-scripts/blob/master/scripts/weather.sh diff --git a/packages/shiki/samples/bat.sample b/packages/shiki/samples/bat.sample index 136cbf0d8..eac0fcd71 100644 --- a/packages/shiki/samples/bat.sample +++ b/packages/shiki/samples/bat.sample @@ -1,15 +1,21 @@ -@rem My First Batch file! - -@echo off - -echo Three - -echo Two - -echo One - -echo Hello World! - -pause +rem +rem Alternate form of if-elseif-else structure with goto for else +rem case. That way, you can group code together in a "more logical" +rem or "more natural" manner. +rem -@rem From https://o7planning.org/11531/batch-scripting-language-tutorial-for-beginners \ No newline at end of file +if .%1 == .1 goto 1 +if .%1 == .2 goto 2 +goto else +:1 +echo You selected 1 +goto endif +:2 +echo You selected 2 +goto endif +:else +echo else (neither 1 nor 2) +goto endif +:endif + +:: From https://github.com/Archive-projects/Batch-File-examples/blob/master/files/tf5.bat diff --git a/packages/shiki/samples/bibtex.sample b/packages/shiki/samples/bibtex.sample new file mode 100644 index 000000000..9031b0a3c --- /dev/null +++ b/packages/shiki/samples/bibtex.sample @@ -0,0 +1,28 @@ +% This file was created with JabRef 2.10. +% Encoding: UTF8 + +@Inproceedings{NN2006-Supporting, + Title = {{Supporting...}}, + Author = {N. N. and X. X.}, + Year = {2006}, + Month = {8,}, + + Owner = {xxx}, + Timestamp = {2010.01.01} +} + + +@Book{NN1997-Entwurf, + Title = {Entwurf...}, + Publisher = {Org}, + Year = {1997}, + Month = oct, + + Owner = {xx}, + Timestamp = {2006.06.12}, +} + + +@comment{jabref-meta: fileDirectory:Folder;} + +% From https://github.com/JabRef/jabref/blob/main/src/test/resources/testbib/bug1283.bib diff --git a/packages/shiki/samples/clj.sample b/packages/shiki/samples/clj.sample new file mode 100644 index 000000000..57cbf3c08 --- /dev/null +++ b/packages/shiki/samples/clj.sample @@ -0,0 +1,14 @@ +(let [my-vector [1 2 3 4] + my-map {:fred "ethel"} + my-list (list 4 3 2 1)] + (list + (conj my-vector 5) + (assoc my-map :ricky "lucy") + (conj my-list 5) + ;the originals are intact + my-vector + my-map + my-list)) +-> ([1 2 3 4 5] {:ricky "lucy", :fred "ethel"} (5 4 3 2 1) [1 2 3 4] {:fred "ethel"} (4 3 2 1)) + +;From https://clojure.org/about/functional_programming#_immutable_data_structures diff --git a/packages/shiki/samples/cobol.sample b/packages/shiki/samples/cobol.sample index f13c1cb43..12b8f32e3 100644 --- a/packages/shiki/samples/cobol.sample +++ b/packages/shiki/samples/cobol.sample @@ -1,12 +1,94 @@ -*> setup the identification division -IDENTIFICATION DIVISION. -*> setup the program id -PROGRAM-ID. HELLO. -*> setup the procedure division (like 'main' function) -PROCEDURE DIVISION. -*> print a string -DISPLAY 'WILLKOMMEN'. -*> end our program -STOP RUN. - -*> From https://medium.com/@yvanscher/7-cobol-examples-with-explanations-ae1784b4d576 \ No newline at end of file + ****************************************************************** + * Author: Bryan Flood + * Date: 25/10/2018 + * Purpose: Compute Fibonacci Numbers + * Tectonics: cobc + ****************************************************************** + IDENTIFICATION DIVISION. + PROGRAM-ID. FIB. + DATA DIVISION. + FILE SECTION. + WORKING-STORAGE SECTION. + 01 N0 BINARY-C-LONG VALUE 0. + 01 N1 BINARY-C-LONG VALUE 1. + 01 SWAP BINARY-C-LONG VALUE 1. + 01 RESULT PIC Z(20)9. + 01 I BINARY-C-LONG VALUE 0. + 01 I-MAX BINARY-C-LONG VALUE 0. + 01 LARGEST-N BINARY-C-LONG VALUE 92. + + PROCEDURE DIVISION. + *> THIS IS WHERE THE LABELS GET CALLED + PERFORM MAIN + PERFORM ENDFIB + GOBACK. + + *> THIS ACCEPTS INPUT AND DETERMINES THE OUTPUT USING A EVAL STMT + MAIN. + DISPLAY "ENTER N TO GENERATE THE FIBONACCI SEQUENCE" + ACCEPT I-MAX. + + EVALUATE TRUE + WHEN I-MAX > LARGEST-N + PERFORM INVALIDN + + WHEN I-MAX > 2 + PERFORM CASEGREATERTHAN2 + + WHEN I-MAX = 2 + PERFORM CASE2 + + WHEN I-MAX = 1 + PERFORM CASE1 + + WHEN I-MAX = 0 + PERFORM CASE0 + + WHEN OTHER + PERFORM INVALIDN + + END-EVALUATE. + + STOP RUN. + + + + *> THE CASE FOR WHEN N = 0 + CASE0. + MOVE N0 TO RESULT. + DISPLAY RESULT. + + *> THE CASE FOR WHEN N = 1 + CASE1. + PERFORM CASE0 + MOVE N1 TO RESULT. + DISPLAY RESULT. + + *> THE CASE FOR WHEN N = 2 + CASE2. + PERFORM CASE1 + MOVE N1 TO RESULT. + DISPLAY RESULT. + + *> THE CASE FOR WHEN N > 2 + CASEGREATERTHAN2. + PERFORM CASE1 + PERFORM VARYING I FROM 1 BY 1 UNTIL I = I-MAX + ADD N0 TO N1 GIVING SWAP + MOVE N1 TO N0 + MOVE SWAP TO N1 + MOVE SWAP TO RESULT + DISPLAY RESULT + END-PERFORM. + + *> PROVIDE ERROR FOR INVALID INPUT + INVALIDN. + DISPLAY 'INVALID N VALUE. THE PROGRAM WILL NOW END'. + + *> END THE PROGRAM WITH A MESSAGE + ENDFIB. + DISPLAY "THE PROGRAM HAS COMPLETED AND WILL NOW END". + + END PROGRAM FIB. + +*> From https://github.com/KnowledgePending/COBOL-Fibonacci-Sequence/blob/master/fib.cbl diff --git a/packages/shiki/samples/codeql.sample b/packages/shiki/samples/codeql.sample index fd2308572..288e3fe9f 100644 --- a/packages/shiki/samples/codeql.sample +++ b/packages/shiki/samples/codeql.sample @@ -1,5 +1,3 @@ -// a query - /** * @name LDAP query built from user-controlled sources * @description Building an LDAP query from user-controlled sources is vulnerable to insertion of @@ -7,8 +5,8 @@ * @kind path-problem * @problem.severity error * @id py/ldap-injection - * @tags experimental - * security + * @tags experimental + * security * external/cwe/cwe-090 */ @@ -101,4 +99,4 @@ class LDAPInjectionFlowConfig extends TaintTracking::Configuration { } } -// From https://github.com/github/codeql/pull/5443/files \ No newline at end of file +// From https://github.com/github/codeql/pull/5443/files diff --git a/packages/shiki/samples/css.sample b/packages/shiki/samples/css.sample index 6ad1e5b21..a68147d58 100644 --- a/packages/shiki/samples/css.sample +++ b/packages/shiki/samples/css.sample @@ -1,19 +1,46 @@ -.Aligner { - display: flex; - align-items: center; - justify-content: center; +html { + margin: 0; + background: black; + height: 100%; } -.Aligner-item { - max-width: 50%; +body { + margin: 0; + width: 100%; + height: inherit; } -.Aligner-item--top { - align-self: flex-start; +/* the three main rows going down the page */ + +body > div { + height: 25%; +} + +.thumb { + float: left; + width: 25%; + height: 100%; + object-fit: cover; +} + +.main { + display: none; +} + +.blowup { + display: block; + position: absolute; + object-fit: contain; + object-position: center; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 2000; } -.Aligner-item--bottom { - align-self: flex-end; +.darken { + opacity: 0.4; } -/* From https://philipwalton.github.io/solved-by-flexbox/demos/vertical-centering/ */ \ No newline at end of file +/* From https://github.com/mdn/css-examples/blob/main/object-fit-gallery/style.css */ diff --git a/packages/shiki/samples/cypher.sample b/packages/shiki/samples/cypher.sample index 961c19672..8a26ed3b7 100644 --- a/packages/shiki/samples/cypher.sample +++ b/packages/shiki/samples/cypher.sample @@ -1,7 +1,21 @@ -CREATE (matrix:Movie {title: 'The Matrix', released: 1997}) -CREATE (keanu:Person {name: 'Keanu Reeves', born: 1964}) -CREATE (tom)-[:ACTED_IN {roles: ['Forrest']}]->(forrestGump) -CREATE (tom)-[:ACTED_IN {roles: ['Zachry']}]->(cloudAtlas) -CREATE (robert)-[:DIRECTED]->(forrestGump) +UNWIND [ + { title: "Cypher Basics I", + created: datetime("2019-06-01T18:40:32.142+0100"), + datePublished: date("2019-06-01"), + readingTime: {minutes: 2, seconds: 15} }, + { title: "Cypher Basics II", + created: datetime("2019-06-02T10:23:32.122+0100"), + datePublished: date("2019-06-02"), + readingTime: {minutes: 2, seconds: 30} }, + { title: "Dates, Datetimes, and Durations in Neo4j", + created: datetime(), + datePublished: date(), + readingTime: {minutes: 3, seconds: 30} } +] AS articleProperties -// https://neo4j.com/docs/getting-started/cypher-intro/results/ +CREATE (article:Article {title: articleProperties.title}) +SET article.created = articleProperties.created, + article.datePublished = articleProperties.datePublished, + article.readingTime = duration(articleProperties.readingTime) + +// https://neo4j.com/developer/cypher/dates-datetimes-durations/ diff --git a/packages/shiki/samples/dream-maker.sample b/packages/shiki/samples/dream-maker.sample new file mode 100644 index 000000000..eeff42781 --- /dev/null +++ b/packages/shiki/samples/dream-maker.sample @@ -0,0 +1,24 @@ +/mob/Login() + var/count = 0 + + world << "Let's count until infinity!" + + // Infinite loop + while (TRUE) + count += 1 + + if (count == 3) + world << "three" + + // Skip the rest of this iteration + continue + + world << "#[count]" + + if (count == 5) + world << "OK, that's enough" + + // Exit this loop + break + +// From https://spacestation13.github.io/DMByExample/flow/loops.html diff --git a/packages/shiki/samples/elixir.sample b/packages/shiki/samples/elixir.sample index 88f5e823f..cadcdb50e 100644 --- a/packages/shiki/samples/elixir.sample +++ b/packages/shiki/samples/elixir.sample @@ -1,8 +1,26 @@ -# module_name.ex -defmodule ModuleName do - def hello do - IO.puts "Hello World" - end -end - -# From https://elixir-lang.org/crash-course.html#elixir \ No newline at end of file +# [] can be used, first match returned +1 = [a: 1, b: 2, a: 3][:a] + +# [] missing value is nil +nil = [a: 1, b: 2, a: 3][:c] + +# Keyword get also works +1 = Keyword.get([a: 1, b: 2, a: 3], :a) + +# missing value is nil +nil = Keyword.get([a: 1, b: 2, a: 3], :c) + +# an optional default value can be specified +# for missing keys +"missing" = Keyword.get([a: 1, b: 2, a: 3], :c, "missing") + +# Keyword.take returns a list of matching pairs +[a: 1, a: 3] = Keyword.take([a: 1, b: 2, a: 3], [:a]) + +[] = Keyword.take([a: 1, b: 2, a: 3], [:c]) + +# dot syntax does NOT work +# results in compile error +[a: 1, b: 2, a: 3].a + +# From https://elixir-examples.github.io/single-page diff --git a/packages/shiki/samples/gherkin.sample b/packages/shiki/samples/gherkin.sample new file mode 100644 index 000000000..c44885653 --- /dev/null +++ b/packages/shiki/samples/gherkin.sample @@ -0,0 +1,11 @@ +Scenario: Eat 5 out of 12 + Given there are 12 cucumbers + When I eat 5 cucumbers + Then I should have 7 cucumbers + +Scenario: Eat 5 out of 20 + Given there are 20 cucumbers + When I eat 5 cucumbers + Then I should have 15 cucumbers + +# From https://gist.github.com/dogoku/0c024c55ec124355f01472abc70550f5 diff --git a/packages/shiki/samples/gnuplot.sample b/packages/shiki/samples/gnuplot.sample new file mode 100644 index 000000000..865122670 --- /dev/null +++ b/packages/shiki/samples/gnuplot.sample @@ -0,0 +1,20 @@ +set title 'Hello, world' # plot title +set xlabel 'Time' # x-axis label +set ylabel 'Distance' # y-axis label + +# labels +set label "boiling point" at 10, 212 + +# key/legend +set key top right +set key box +set key left bottom +set key bmargin +set key 0.01,100 + +set nokey # no key + +# arrow +set arrow from 1,1 to 5,10 + +# From https://alvinalexander.com/technology/gnuplot-charts-graphs-examples/ diff --git a/packages/shiki/samples/graphql.sample b/packages/shiki/samples/graphql.sample new file mode 100644 index 000000000..f50dab215 --- /dev/null +++ b/packages/shiki/samples/graphql.sample @@ -0,0 +1,15 @@ +query($number_of_repos:Int!) { + viewer { + name + repositories(last: $number_of_repos) { + nodes { + name + } + } + } +} +variables { + "number_of_repos": 3 +} + +# From https://docs.github.com/en/graphql/guides/forming-calls-with-graphql diff --git a/packages/shiki/samples/groovy.sample b/packages/shiki/samples/groovy.sample new file mode 100644 index 000000000..a4d2c0d74 --- /dev/null +++ b/packages/shiki/samples/groovy.sample @@ -0,0 +1,18 @@ +import org.mortbay.jetty.Server +import org.mortbay.jetty.servlet.* +import groovy.servlet.* + +@Grab(group='org.mortbay.jetty', module='jetty-embedded', version='6.1.14') +def startJetty() { + def jetty = new Server(9090) + def context = new Context(jetty, '/', Context.SESSIONS) + context.setWelcomeFiles(["webserverIndex.groovy"] as String[]) + context.resourceBase = '.' + context.addServlet(GroovyServlet, '*.groovy') + jetty.start() +} + +println "Starting Jetty on port 9090, press Ctrl+C to stop." +startJetty() + +// From https://gist.github.com/saltnlight5/3756240 diff --git a/packages/shiki/samples/hack.sample b/packages/shiki/samples/hack.sample new file mode 100644 index 000000000..83d4c55b6 --- /dev/null +++ b/packages/shiki/samples/hack.sample @@ -0,0 +1,23 @@ +<<__EntryPoint>> +async function my_example(): Awaitable { + $user_ids = vec[1, 2, 3]; + + // Initiate all the database requests together, + // so we spend less time waiting. + $user_names = await Vec\map_async( + $user_ids, + async ($id) ==> await fetch_user_name($id), + ); + // Execution continues after requests complete. + + echo Str\join($user_names, ", "); +} + +async function fetch_user_name( + int $_, +): Awaitable { + // This could be a database request. + return ""; +} + +// From hacklang.org diff --git a/packages/shiki/samples/haml.sample b/packages/shiki/samples/haml.sample new file mode 100644 index 000000000..fa8689332 --- /dev/null +++ b/packages/shiki/samples/haml.sample @@ -0,0 +1,40 @@ +!!! 5 +%html + %head + %title Example HAML + /[if IE] + %link{ :rel => "stylesheet", :href => "/css/ie.css" } + %body + #container + %header + %h1 Our Awesome HTML5 Template + #main + Did we mention this was awesome? + + / Only this line will be wrapped in a comment + %blockquote + %p Roads? Where we're going we don't need roads + + / + Now the whole block will be commented out + %blockquote + %p Roads? Where we're going we don't need roads + + %p The line below won't appear in the HTML + -# The rest of this line is a comment + %p The line above won't appear in the HTML, nor will the lines underneath + -# + None of this text will appear in our + rendered output + + %p= Time.now + + %footer + %address + .hcard + .fn Ian Oxley + .adr + .locality Newcastle-upon-Tyne + .country-name England + +/ From https://gist.github.com/ianoxley/1147666 diff --git a/packages/shiki/samples/handlebars.sample b/packages/shiki/samples/handlebars.sample new file mode 100644 index 000000000..7a4be6375 --- /dev/null +++ b/packages/shiki/samples/handlebars.sample @@ -0,0 +1,17 @@ +

+

{{title}}

+ {{#with story}} +
{{{intro}}}
+
{{{body}}}
+ {{/with}} +
+
+ {{#each comments}} +
+

{{subject}}

+ {{{body}}} +
+ {{/each}} +
+ +{{! From https://handlebarsjs.com/guide/block-helpers.html#the-with-helper }} diff --git a/packages/shiki/samples/haskell.sample b/packages/shiki/samples/haskell.sample new file mode 100644 index 000000000..dd0c56906 --- /dev/null +++ b/packages/shiki/samples/haskell.sample @@ -0,0 +1,23 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE QuasiQuotes #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE MultiParamTypeClasses #-} + +import Yesod + +data WebApp = WebApp + +instance Yesod WebApp + +mkYesod "WebApp" [parseRoutes| + / HomeR GET +|] + +getHomeR = defaultLayout [whamlet| +
Hello, world! +|] + +main = warpEnv WebApp + +{-# From https://www.schoolofhaskell.com/user/eriks/Simple%20examples } diff --git a/packages/shiki/samples/hlsl.sample b/packages/shiki/samples/hlsl.sample new file mode 100644 index 000000000..7df27992d --- /dev/null +++ b/packages/shiki/samples/hlsl.sample @@ -0,0 +1,20 @@ +struct VS_OUTPUT +{ + float4 Position : SV_POSITION; + float4 Diffuse : COLOR0; + float2 TextureUV : TEXCOORD0; +}; + +VS_OUTPUT RenderSceneVS( float4 vPos : POSITION, + float3 vNormal : NORMAL, + float2 vTexCoord0 : TEXCOORD, + uniform int nNumLights, + uniform bool bTexture, + uniform bool bAnimate ) +{ + VS_OUTPUT Output; + ... + return Output; +} + +// From https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-function-syntax diff --git a/packages/shiki/samples/html.sample b/packages/shiki/samples/html.sample index 65d30dd87..1a3cf64fe 100644 --- a/packages/shiki/samples/html.sample +++ b/packages/shiki/samples/html.sample @@ -1,27 +1,52 @@ - -.Aligner-item { - max-width: 50%; -} + + + + +
+ +
+ + + + -
-
-
-
-
+
+ +
+ + + + - + diff --git a/packages/shiki/samples/http.sample b/packages/shiki/samples/http.sample index bed454377..0bada40ed 100644 --- a/packages/shiki/samples/http.sample +++ b/packages/shiki/samples/http.sample @@ -1,16 +1,18 @@ -POST /my-endpoint HTTP/1.1 -Host: api.example.com:8767 -Authorization: Bearer my-token-value -content-type: application/json +// Basic authentication +GET http://example.com +Authorization: Basic username password -{ - "name": "sample", - "time": "Wed, 21 Oct 2015 18:27:50 GMT" -} +### -GET /hello.txt HTTP/1.1 -User-Agent: curl/7.64.1 -Host: www.example.com -Accept-Language: en, mi +// Digest authentication +GET http://example.com +Authorization: Digest username password -# from various places and https://www.rfc-editor.org/rfc/rfc9110.html#name-example-message-exchange \ No newline at end of file +// The request body is provided in place +POST https://example.com:8080/api/html/post HTTP/1.1 +Content-Type: application/json +Cookie: key=first-value + +{ "key" : "value", "list": [1, 2, 3] } + +// From https://www.jetbrains.com/help/idea/exploring-http-syntax.html#use-multipart-form-data diff --git a/packages/shiki/samples/ini.sample b/packages/shiki/samples/ini.sample new file mode 100644 index 000000000..0a3aa8db3 --- /dev/null +++ b/packages/shiki/samples/ini.sample @@ -0,0 +1,12 @@ +; last modified 1 April 2001 by John Doe +[owner] +name = John Doe +organization = Acme Widgets Inc. + +[database] +; use IP address in case network name resolution is not working +server = 192.0.2.62` +port = 143 +file = "payroll.dat" + +; From https://en.wikipedia.org/wiki/INI_file diff --git a/packages/shiki/samples/java.sample b/packages/shiki/samples/java.sample index 547cfcc0a..b249d932f 100644 --- a/packages/shiki/samples/java.sample +++ b/packages/shiki/samples/java.sample @@ -1,10 +1,36 @@ -public class HelloWorld { +import java.awt.Rectangle; - public static void main(String[] args) { - // Prints "Hello, World" to the terminal window. - System.out.println("Hello, World"); - } +public class ObjectVarsAsParameters +{ public static void main(String[] args) + { go(); + } + + public static void go() + { Rectangle r1 = new Rectangle(0,0,5,5); + System.out.println("In method go. r1 " + r1 + "\n"); + // could have been + //System.out.prinltn("r1" + r1.toString()); + r1.setSize(10, 15); + System.out.println("In method go. r1 " + r1 + "\n"); + alterPointee(r1); + System.out.println("In method go. r1 " + r1 + "\n"); + + alterPointer(r1); + System.out.println("In method go. r1 " + r1 + "\n"); + } + + public static void alterPointee(Rectangle r) + { System.out.println("In method alterPointee. r " + r + "\n"); + r.setSize(20, 30); + System.out.println("In method alterPointee. r " + r + "\n"); + } + + public static void alterPointer(Rectangle r) + { System.out.println("In method alterPointer. r " + r + "\n"); + r = new Rectangle(5, 10, 30, 35); + System.out.println("In method alterPointer. r " + r + "\n"); + } } -// From https://introcs.cs.princeton.edu/java/11hello/HelloWorld.java.html \ No newline at end of file +// From https://www.cs.utexas.edu/~scottm/cs307/javacode/codeSamples/ObjectVarsAsParameters.java diff --git a/packages/shiki/samples/javascript.sample b/packages/shiki/samples/javascript.sample index 1e0434d37..3e2035b10 100644 --- a/packages/shiki/samples/javascript.sample +++ b/packages/shiki/samples/javascript.sample @@ -1,26 +1,29 @@ -// posts will be populated at build time by getStaticProps() -function Blog({ posts }) { - return ( -
    - {posts.map((post) => ( -
  • {post.title}
  • - ))} -
- ) +function resolveAfter2Seconds(x) { + return new Promise((resolve) => { + setTimeout(() => { + resolve(x); + }, 2000); + }); } -// This function gets called at build time on server-side. -export async function getStaticProps() { - const res = await fetch('https://.../posts') - const posts = await res.json() +// async function expression assigned to a variable +const add = async function (x) { + const a = await resolveAfter2Seconds(20); + const b = await resolveAfter2Seconds(30); + return x + a + b; +}; - return { - props: { - posts - } - } -} +add(10).then((v) => { + console.log(v); // prints 60 after 4 seconds. +}); -export default Blog +// async function expression used as an IIFE +(async function (x) { + const p1 = resolveAfter2Seconds(20); + const p2 = resolveAfter2Seconds(30); + return x + (await p1) + (await p2); +})(10).then((v) => { + console.log(v); // prints 60 after 2 seconds. +}); -// From https://nextjs.org/docs/basic-features/data-fetching +// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/async_function diff --git a/packages/shiki/samples/jinja-html.sample b/packages/shiki/samples/jinja-html.sample new file mode 100644 index 000000000..778eb157c --- /dev/null +++ b/packages/shiki/samples/jinja-html.sample @@ -0,0 +1,22 @@ +{# templates/results.html #} + + + + + + Results + + + +

{{ test_name }} Results

+
    + {% for student in students %} +
  • + {{ student.name }}: {{ student.score }}/{{ max_score }} +
  • + {% endfor %} +
+ + + +{# From https://realpython.com/primer-on-jinja-templating/#use-if-statements #} diff --git a/packages/shiki/samples/json.sample b/packages/shiki/samples/json.sample new file mode 100644 index 000000000..62415ef28 --- /dev/null +++ b/packages/shiki/samples/json.sample @@ -0,0 +1,38 @@ +{ + "squadName": "Super hero squad", + "homeTown": "Metro City", + "formed": 2016, + "secretBase": "Super tower", + "active": true, + "members": [ + { + "name": "Molecule Man", + "age": 29, + "secretIdentity": "Dan Jukes", + "powers": ["Radiation resistance", "Turning tiny", "Radiation blast"] + }, + { + "name": "Madame Uppercut", + "age": 39, + "secretIdentity": "Jane Wilson", + "powers": [ + "Million tonne punch", + "Damage resistance", + "Superhuman reflexes" + ] + }, + { + "name": "Eternal Flame", + "age": 1000000, + "secretIdentity": "Unknown", + "powers": [ + "Immortality", + "Heat Immunity", + "Inferno", + "Teleportation", + "Interdimensional travel" + ] + } + ], + "from": "https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON" +} diff --git a/packages/shiki/samples/json5.sample b/packages/shiki/samples/json5.sample index 67f9d4144..35ccc820b 100644 --- a/packages/shiki/samples/json5.sample +++ b/packages/shiki/samples/json5.sample @@ -38,4 +38,4 @@ }, } -https://github.com/mrmlnc/vscode-json5/blob/master/syntaxes/json5.json \ No newline at end of file +// From https://github.com/mrmlnc/vscode-json5/blob/master/syntaxes/json5.json diff --git a/packages/shiki/samples/jsonc.sample b/packages/shiki/samples/jsonc.sample new file mode 100644 index 000000000..043f64df9 --- /dev/null +++ b/packages/shiki/samples/jsonc.sample @@ -0,0 +1,34 @@ +// A jsonc example document +{ + owner:{ + name:`komkom` + dob: /* just some random dob */ `1975-01-25T12:00:00-02:00` + } + + database:{ // our live db + server:`192.168.1.1` + ports:[8001,8002,8003] + connectionMax:5000 + enabled:true + } + + servers:{ // a server + alpha:{ + ip: /* is soon invalid */ `10.0.0.1` + dc:`eqdc10` + } + + beta:{ + ip:`10.0.0.2` + dc:`eqdc10` + } + } + + clients:{ + data:[["gamma","delta"],[1,2]] + } + + hosts:[alpha,omega] +} + +// From https://github.com/komkom/jsonc diff --git a/packages/shiki/samples/jsonl.sample b/packages/shiki/samples/jsonl.sample new file mode 100644 index 000000000..43901f21b --- /dev/null +++ b/packages/shiki/samples/jsonl.sample @@ -0,0 +1,31 @@ +{"name": "Gilbert", "wins": [["straight", "7♣"], ["one pair", "10♥"]]} +{"name": "Alexa", "wins": [["two pair", "4♠"], ["two pair", "9♠"]]} +{"name": "May", "wins": []} +{"name": "Deloise", "wins": [["three of a kind", "5♣"]]} +{ + "name": "Gilbert", + "wins": [ + [ + "straight", + "7♣" + ], + [ + "one pair", + "10♥" + ] + ] +} +{ + "name": "Alexa", + "wins": [ + [ + "two pair", + "4♠" + ], + [ + "two pair", + "9♠" + ] + ] +} +// From https://jsonlines.org/examples/ diff --git a/packages/shiki/samples/jsonnet.sample b/packages/shiki/samples/jsonnet.sample new file mode 100644 index 000000000..cdcdd515b --- /dev/null +++ b/packages/shiki/samples/jsonnet.sample @@ -0,0 +1,33 @@ +/* A C-style comment. */ +# A Python-style comment. +{ + cocktails: { + // Ingredient quantities are in fl oz. + 'Tom Collins': { + ingredients: [ + { kind: "Farmer's Gin", qty: 1.5 }, + { kind: 'Lemon', qty: 1 }, + { kind: 'Simple Syrup', qty: 0.5 }, + { kind: 'Soda', qty: 2 }, + { kind: 'Angostura', qty: 'dash' }, + ], + garnish: 'Maraschino Cherry', + served: 'Tall', + description: ||| + The Tom Collins is essentially gin and + lemonade. The bitters add complexity. + |||, + }, + Manhattan: { + ingredients: [ + { kind: 'Rye', qty: 2.5 }, + { kind: 'Sweet Red Vermouth', qty: 1 }, + { kind: 'Angostura', qty: 'dash' }, + ], + garnish: 'Maraschino Cherry', + served: 'Straight Up', + description: @'A clear \ red drink.', + }, + }, +} +# From https://jsonnet.org/learning/tutorial.html diff --git a/packages/shiki/samples/jsx.sample b/packages/shiki/samples/jsx.sample new file mode 100644 index 000000000..1f420e014 --- /dev/null +++ b/packages/shiki/samples/jsx.sample @@ -0,0 +1,30 @@ +function Item({ name, isPacked }) { + if (isPacked) { + return null; + } + return
  • {name}
  • ; +} + +export default function PackingList() { + return ( +
    +

    Sally Ride's Packing List

    +
      + + + +
    +
    + ); +} + +// From https://react.dev/learn/conditional-rendering diff --git a/packages/shiki/samples/julia.sample b/packages/shiki/samples/julia.sample new file mode 100644 index 000000000..7d009e897 --- /dev/null +++ b/packages/shiki/samples/julia.sample @@ -0,0 +1,16 @@ +function mandelbrot(a) + z = 0 + for i=1:50 + z = z^2 + a + end + return z +end + +for y=1.0:-0.05:-1.0 + for x=-2.0:0.0315:0.5 + abs(mandelbrot(complex(x, y))) < 2 ? print("*") : print(" ") + end + println() +end + +# From: https://rosettacode.org/wiki/Mandelbrot_set#Julia diff --git a/packages/shiki/samples/latex.sample b/packages/shiki/samples/latex.sample new file mode 100644 index 000000000..d3890d804 --- /dev/null +++ b/packages/shiki/samples/latex.sample @@ -0,0 +1,31 @@ +% This is a simple sample document. For more complicated documents take a look in the exercise tab. Note that everything that comes after a % symbol is treated as comment and ignored when the code is compiled. + +\documentclass{article} % \documentclass{} is the first command in any LaTeX code. It is used to define what kind of document you are creating such as an article or a book, and begins the document preamble + +\usepackage{amsmath} % \usepackage is a command that allows you to add functionality to your LaTeX code + +\title{Simple Sample} % Sets article title +\author{My Name} % Sets authors name +\date{\today} % Sets date for date compiled + +% The preamble ends with the command \begin{document} +\begin{document} % All begin commands must be paired with an end command somewhere + \maketitle % creates title using information in preamble (title, author, date) + + \section{Hello World!} % creates a section + + \textbf{Hello World!} Today I am learning \LaTeX. %notice how the command will end at the first non-alphabet charecter such as the . after \LaTeX + \LaTeX{} is a great program for writing math. I can write in line math such as $a^2+b^2=c^2$ %$ tells LaTexX to compile as math + . I can also give equations their own space: + \begin{equation} % Creates an equation environment and is compiled as math + \gamma^2+\theta^2=\omega^2 + \end{equation} + If I do not leave any blank lines \LaTeX{} will continue this text without making it into a new paragraph. Notice how there was no indentation in the text after equation (1). + Also notice how even though I hit enter after that sentence and here $\downarrow$ + \LaTeX{} formats the sentence without any break. Also look how it doesn't matter how many spaces I put between my words. + + For a new paragraph I can leave a blank space in my code. + +\end{document} % This is the end of the document + +% From https://guides.nyu.edu/LaTeX/sample-document diff --git a/packages/shiki/samples/less.sample b/packages/shiki/samples/less.sample new file mode 100644 index 000000000..bb456b788 --- /dev/null +++ b/packages/shiki/samples/less.sample @@ -0,0 +1,31 @@ +.button { + &-ok { + background-image: url("ok.png"); + } + &-cancel { + background-image: url("cancel.png"); + } + + &-custom { + background-image: url("custom.png"); + } +} +.link { + & + & { + color: red; + } + + & & { + color: green; + } + + && { + color: blue; + } + + &, &ish { + color: cyan; + } +} + +// From https://lesscss.org/features/#parent-selectors-feature diff --git a/packages/shiki/samples/lisp.sample b/packages/shiki/samples/lisp.sample new file mode 100644 index 000000000..eaa4242ff --- /dev/null +++ b/packages/shiki/samples/lisp.sample @@ -0,0 +1,25 @@ +;;; testing.lisp +;;; by Philip Fong +;;; +;;; Introductory comments are preceded by ";;;" +;;; Function headers are preceded by ";;" +;;; Inline comments are introduced by ";" +;;; + +;; +;; Triple the value of a number +;; + +(defun triple (X) + "Compute three times X." ; Inline comments can + (* 3 X)) ; be placed here. + +;; +;; Negate the sign of a number +;; + +(defun negate (X) + "Negate the value of X." ; This is a documentation string. + (- X)) + +;;; From https://www2.cs.sfu.ca/CourseCentral/310/pwfong/Lisp/1/tutorial1.html diff --git a/packages/shiki/samples/logo.sample b/packages/shiki/samples/logo.sample new file mode 100644 index 000000000..949e777c5 --- /dev/null +++ b/packages/shiki/samples/logo.sample @@ -0,0 +1,21 @@ +print word "apple "sauce +; applesauce + +print word "3 "4 +; 34 + +print 12 + word "3 "4 +; 46 + +to factorial :number +if :number = 1 [output 1] +output :number * factorial :number - 1 +end + +print factorial 3 +; 6 + +print factorial 5 +; 120 + +; From https://el.media.mit.edu/logo-foundation/what_is_logo/logo_programming.html diff --git a/packages/shiki/samples/lua.sample b/packages/shiki/samples/lua.sample new file mode 100644 index 000000000..9ca8ec2cf --- /dev/null +++ b/packages/shiki/samples/lua.sample @@ -0,0 +1,18 @@ +ball = { + xpos = 60, + ypos = 60, + + -- without the colon syntax, must mention self argument explicitly + move = function(self, newx, newy) + self.xpos = newx + self.ypos = newy + end +} + +-- using the colon, ball is passed as self automatically +ball:move(100, 120) + +-- using the dot, must pass self explicitly +ball.move(ball, 100, 120) + +-- From https://pico-8.fandom.com/wiki/Lua diff --git a/packages/shiki/samples/make.sample b/packages/shiki/samples/make.sample new file mode 100644 index 000000000..e0893da14 --- /dev/null +++ b/packages/shiki/samples/make.sample @@ -0,0 +1,26 @@ +edit : main.o kbd.o command.o display.o \ + insert.o search.o files.o utils.o + cc -o edit main.o kbd.o command.o display.o \ + insert.o search.o files.o utils.o + +main.o : main.c defs.h + cc -c main.c +kbd.o : kbd.c defs.h command.h + cc -c kbd.c +command.o : command.c defs.h command.h + cc -c command.c +display.o : display.c defs.h buffer.h + cc -c display.c +insert.o : insert.c defs.h buffer.h + cc -c insert.c +search.o : search.c defs.h buffer.h + cc -c search.c +files.o : files.c defs.h buffer.h command.h + cc -c files.c +utils.o : utils.c defs.h + cc -c utils.c +clean : + rm edit main.o kbd.o command.o display.o \ + insert.o search.o files.o utils.o + +# From https://www.gnu.org/software/make/manual/html_node/Simple-Makefile.html diff --git a/packages/shiki/samples/markdown.sample b/packages/shiki/samples/markdown.sample new file mode 100644 index 000000000..644a2aae5 --- /dev/null +++ b/packages/shiki/samples/markdown.sample @@ -0,0 +1,161 @@ +An h1 header +============ + +Paragraphs are separated by a blank line. + +2nd paragraph. *Italic*, **bold**, and `monospace`. Itemized lists +look like: + + * this one + * that one + * the other one + +Note that --- not considering the asterisk --- the actual text +content starts at 4-columns in. + +> Block quotes are +> written like so. +> +> They can span multiple paragraphs, +> if you like. + +Use 3 dashes for an em-dash. Use 2 dashes for ranges (ex., "it's all +in chapters 12--14"). Three dots ... will be converted to an ellipsis. +Unicode is supported. ☺ + + + +An h2 header +------------ + +Here's a numbered list: + + 1. first item + 2. second item + 3. third item + +Note again how the actual text starts at 4 columns in (4 characters +from the left side). Here's a code sample: + + # Let me re-iterate ... + for i in 1 .. 10 { do-something(i) } + +As you probably guessed, indented 4 spaces. By the way, instead of +indenting the block, you can use delimited blocks, if you like: + +~~~ +define foobar() { + print "Welcome to flavor country!"; +} +~~~ + +(which makes copying & pasting easier). You can optionally mark the +delimited block for Pandoc to syntax highlight it: + +~~~python +import time +# Quick, count to ten! +for i in range(10): + # (but not *too* quick) + time.sleep(0.5) + print(i) +~~~ + + + +### An h3 header ### + +Now a nested list: + + 1. First, get these ingredients: + + * carrots + * celery + * lentils + + 2. Boil some water. + + 3. Dump everything in the pot and follow + this algorithm: + + find wooden spoon + uncover pot + stir + cover pot + balance wooden spoon precariously on pot handle + wait 10 minutes + goto first step (or shut off burner when done) + + Do not bump wooden spoon or it will fall. + +Notice again how text always lines up on 4-space indents (including +that last line which continues item 3 above). + +Here's a link to [a website](http://foo.bar), to a [local +doc](local-doc.html), and to a [section heading in the current +doc](#an-h2-header). Here's a footnote [^1]. + +[^1]: Some footnote text. + +Tables can look like this: + +Name Size Material Color +------------- ----- ------------ ------------ +All Business 9 leather brown +Roundabout 10 hemp canvas natural +Cinderella 11 glass transparent + +Table: Shoes sizes, materials, and colors. + +(The above is the caption for the table.) Pandoc also supports +multi-line tables: + +-------- ----------------------- +Keyword Text +-------- ----------------------- +red Sunsets, apples, and + other red or reddish + things. + +green Leaves, grass, frogs + and other things it's + not easy being. +-------- ----------------------- + +A horizontal rule follows. + +*** + +Here's a definition list: + +apples + : Good for making applesauce. + +oranges + : Citrus! + +tomatoes + : There's no "e" in tomatoe. + +Again, text is indented 4 spaces. (Put a blank line between each +term and its definition to spread things out more.) + +Here's a "line block" (note how whitespace is honored): + +| Line one +| Line too +| Line tree + +and images can be specified like so: + +![example image](example-image.jpg "An exemplary image") + +Inline math equation: $\omega = d\phi / dt$. Display +math should get its own line like so: + +$$I = \int \rho R^{2} dV$$ + +And note that you can backslash-escape any punctuation characters +which you wish to be displayed literally, ex.: \`foo\`, \*bar\*, etc. + + diff --git a/packages/shiki/samples/marko.sample b/packages/shiki/samples/marko.sample index af35e02b4..f006f2ae1 100644 --- a/packages/shiki/samples/marko.sample +++ b/packages/shiki/samples/marko.sample @@ -10,4 +10,4 @@ -# from https://markojs.com/docs/core-tags/ \ No newline at end of file +# from https://markojs.com/docs/core-tags/ diff --git a/packages/shiki/samples/matlab.sample b/packages/shiki/samples/matlab.sample new file mode 100644 index 000000000..dfcb7c2a8 --- /dev/null +++ b/packages/shiki/samples/matlab.sample @@ -0,0 +1,22 @@ + + +clear +number = input('Give an integer: '); +remainder2 = rem(number,2); +remainder3 = rem(number,3); + +if remainder2==0 & remainder3==0 + 'Your number is divisible by both 2 and 3' +else + if remainder2==0 + 'Your number is divisble by 2 but not by 3' + else + if remainder3==0 + 'Your number is divisible by 3 but not by 2' + else + 'Your number is not divisible by either 2 or 3' + end + end +end + +% From https://www.math.colostate.edu/~yzhou/course/matlab_doc/matlab_programming_intro.html diff --git a/packages/shiki/samples/mdx.sample b/packages/shiki/samples/mdx.sample new file mode 100644 index 000000000..7dffc420a --- /dev/null +++ b/packages/shiki/samples/mdx.sample @@ -0,0 +1,13 @@ + + +You can also use objects with components, such as the `thisOne` component on +the `myComponents` object: + +} +/> + +{/* From https://mdxjs.com/docs/what-is-mdx/#mdx-syntax */} diff --git a/packages/shiki/samples/mermaid.sample b/packages/shiki/samples/mermaid.sample new file mode 100644 index 000000000..f83923c94 --- /dev/null +++ b/packages/shiki/samples/mermaid.sample @@ -0,0 +1,23 @@ +graph TB + sq[Square shape] --> ci((Circle shape)) + + subgraph A + od>Odd shape]-- Two line
    edge comment --> ro + di{Diamond with
    line break} -.-> ro(Rounded
    square
    shape) + di==>ro2(Rounded square shape) + end + + %% Notice that no text in shape are added here instead that is appended further down + e --> od3>Really long text with linebreak
    in an Odd shape] + + %% Comments after double percent signs + e((Inner / circle
    and some odd
    special characters)) --> f(,.?!+-*ز) + + cyr[Cyrillic]-->cyr2((Circle shape Начало)); + + classDef green fill:#9f6,stroke:#333,stroke-width:2px; + classDef orange fill:#f96,stroke:#333,stroke-width:4px; + class sq,e green + class di orange + +%% From https://mermaid.js.org/syntax/examples.html diff --git a/packages/shiki/samples/nginx.sample b/packages/shiki/samples/nginx.sample new file mode 100644 index 000000000..49b778a85 --- /dev/null +++ b/packages/shiki/samples/nginx.sample @@ -0,0 +1,72 @@ +user www www; ## Default: nobody +worker_processes 5; ## Default: 1 +error_log logs/error.log; +pid logs/nginx.pid; +worker_rlimit_nofile 8192; + +events { + worker_connections 4096; ## Default: 1024 +} + +http { + include conf/mime.types; + include /etc/nginx/proxy.conf; + include /etc/nginx/fastcgi.conf; + index index.html index.htm index.php; + + default_type application/octet-stream; + log_format main '$remote_addr - $remote_user [$time_local] $status ' + '"$request" $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + access_log logs/access.log main; + sendfile on; + tcp_nopush on; + server_names_hash_bucket_size 128; # this seems to be required for some vhosts + + server { # php/fastcgi + listen 80; + server_name domain1.com www.domain1.com; + access_log logs/domain1.access.log main; + root html; + + location ~ \.php$ { + fastcgi_pass 127.0.0.1:1025; + } + } + + server { # simple reverse-proxy + listen 80; + server_name domain2.com www.domain2.com; + access_log logs/domain2.access.log main; + + # serve static files + location ~ ^/(images|javascript|js|css|flash|media|static)/ { + root /var/www/virtual/big.server.com/htdocs; + expires 30d; + } + + # pass requests for dynamic content to rails/turbogears/zope, et al + location / { + proxy_pass http://127.0.0.1:8080; + } + } + + upstream big_server_com { + server 127.0.0.3:8000 weight=5; + server 127.0.0.3:8001 weight=5; + server 192.168.0.1:8000; + server 192.168.0.1:8001; + } + + server { # simple load balancing + listen 80; + server_name big.server.com; + access_log logs/big.server.access.log main; + + location / { + proxy_pass http://big_server_com; + } + } +} + +# From https://www.nginx.com/resources/wiki/start/topics/examples/full/ diff --git a/packages/shiki/samples/nim.sample b/packages/shiki/samples/nim.sample new file mode 100644 index 000000000..fa1f50d8b --- /dev/null +++ b/packages/shiki/samples/nim.sample @@ -0,0 +1,49 @@ +type + Animal* = object + name*, species*: string + age: int + +proc sleep*(a: var Animal) = + a.age += 1 + +proc dead*(a: Animal): bool = + result = a.age > 20 + +var carl: Animal +carl = Animal(name : "Carl", + species : "L. glama", + age : 12) + +let joe = Animal(name : "Joe", + species : "H. sapiens", + age : 23) + +assert(not carl.dead) +for i in 0..10: + carl.sleep() +assert carl.deadtype + Animal* = object + name*, species*: string + age: int + +proc sleep*(a: var Animal) = + a.age += 1 + +proc dead*(a: Animal): bool = + result = a.age > 20 + +var carl: Animal +carl = Animal(name : "Carl", + species : "L. glama", + age : 12) + +let joe = Animal(name : "Joe", + species : "H. sapiens", + age : 23) + +assert(not carl.dead) +for i in 0..10: + carl.sleep() +assert carl.dead + +# From https://nim-by-example.github.io/types/objects/ diff --git a/packages/shiki/samples/nix.sample b/packages/shiki/samples/nix.sample new file mode 100644 index 000000000..1d0ebe301 --- /dev/null +++ b/packages/shiki/samples/nix.sample @@ -0,0 +1,44 @@ +{ + # dependencies + stdenv, fetchurl, nix-gitignore, buildGoModule, + + # args + localFiles ? false +}: + +buildGoModule rec { + + pname = "hello"; + version = "1.0"; + + src = ( + if localFiles then + nix-gitignore.gitignoreSource [ "result" ] ./. + else + fetchurl { + url = "https://example.com"; + sha256 = stdenv.lib.fakeSha256; + } + ); + + modSha256 = "1ggp6xhhlixihjx37v5j9gd3sa1gymqrglf9c3j1pwfnym1k99y3"; + + subPackages = [ "." ]; + + passthru = { + executable = "main"; + }; + + meta = with stdenv.lib; { + description = "Hello world example in Go"; + longDescription = '' + Long description for Hello world example in Go. + ''; + homepage = https://blog.golang.org/using-go-modules; + license = licenses.asl20; + maintainers = []; + platforms = platforms.all; + }; +} + +# From https://github.com/vlktomas/nix-examples/tree/master/desktop/Go/hello diff --git a/packages/shiki/samples/objective-c.sample b/packages/shiki/samples/objective-c.sample new file mode 100644 index 000000000..c90e3d305 --- /dev/null +++ b/packages/shiki/samples/objective-c.sample @@ -0,0 +1,13 @@ +@interface classname : superclassname { + // instance variables +} ++ classMethod1; ++ (return_type)classMethod2; ++ (return_type)classMethod3:(param1_type)param1_varName; + +- (return_type)instanceMethod1With1Parameter:(param1_type)param1_varName; +- (return_type)instanceMethod2With2Parameters:(param1_type)param1_varName + param2_callName:(param2_type)param2_varName; +@end + +// From https://en.wikipedia.org/wiki/Objective-C diff --git a/packages/shiki/samples/objective-cpp.sample b/packages/shiki/samples/objective-cpp.sample new file mode 100644 index 000000000..24ef62af9 --- /dev/null +++ b/packages/shiki/samples/objective-cpp.sample @@ -0,0 +1,33 @@ +#include +#include +typedef int (^IntBlock)(); + +IntBlock MakeCounter(int start, int increment) { + __block int i = start; + + return Block_copy( ^ { + int ret = i; + i += increment; + return ret; + }); + +} + +int main(void) { + IntBlock mycounter = MakeCounter(5, 2); + printf("First call: %d\n", mycounter()); + printf("Second call: %d\n", mycounter()); + printf("Third call: %d\n", mycounter()); + + /* because it was copied, it must also be released */ + Block_release(mycounter); + + return 0; +} +/* Output: + First call: 5 + Second call: 7 + Third call: 9 +*/ + +// From https://en.wikipedia.org/wiki/Objective-C diff --git a/packages/shiki/samples/ocaml.sample b/packages/shiki/samples/ocaml.sample new file mode 100644 index 000000000..5b624e73e --- /dev/null +++ b/packages/shiki/samples/ocaml.sample @@ -0,0 +1,23 @@ + +utop # type person = { name: string ; age: int ; human : bool };; +type person = { name : string; age : int; human : bool; } + +utop # let david = { name = "david" ; age = 32 ; human = false };; +val david : person = {name = "david"; age = 32; human = false} + +utop # let mary = { david with name = "mary" };; +val mary : person = {name = "mary"; age = 32; human = false} + +utop # let toggle_human (p : person) = { p with human = not p.human };; +val toggle_human : person -> person = + +utop # let () = + let david' = toggle_human david in + if david'.human then + print_endline "david is human" + else + print_endline "david is not human" +;; +david is human + +(** From https://o1-labs.github.io/ocamlbyexample/basics-records.html *) diff --git a/packages/shiki/samples/pascal.sample b/packages/shiki/samples/pascal.sample new file mode 100644 index 000000000..3d16eacc0 --- /dev/null +++ b/packages/shiki/samples/pascal.sample @@ -0,0 +1,109 @@ +{***************************************************************************** + * A Pascal quicksort. + *****************************************************************************} +PROGRAM Sort(input, output); + CONST + { Max array size. } + MaxElts = 50; + TYPE + { Type of the element array. } + IntArrType = ARRAY [1..MaxElts] OF Integer; + + VAR + { Indexes, exchange temp, array size. } + i, j, tmp, size: integer; + + { Array of ints } + arr: IntArrType; + + { Read in the integers. } + PROCEDURE ReadArr(VAR size: Integer; VAR a: IntArrType); + BEGIN + size := 1; + WHILE NOT eof DO BEGIN + readln(a[size]); + IF NOT eof THEN + size := size + 1 + END + END; + + { Use quicksort to sort the array of integers. } + PROCEDURE Quicksort(size: Integer; VAR arr: IntArrType); + { This does the actual work of the quicksort. It takes the + parameters which define the range of the array to work on, + and references the array as a global. } + PROCEDURE QuicksortRecur(start, stop: integer); + VAR + m: integer; + + { The location separating the high and low parts. } + splitpt: integer; + + { The quicksort split algorithm. Takes the range, and + returns the split point. } + FUNCTION Split(start, stop: integer): integer; + VAR + left, right: integer; { Scan pointers. } + pivot: integer; { Pivot value. } + + { Interchange the parameters. } + PROCEDURE swap(VAR a, b: integer); + VAR + t: integer; + BEGIN + t := a; + a := b; + b := t + END; + + BEGIN { Split } + { Set up the pointers for the hight and low sections, and + get the pivot value. } + pivot := arr[start]; + left := start + 1; + right := stop; + + { Look for pairs out of place and swap 'em. } + WHILE left <= right DO BEGIN + WHILE (left <= stop) AND (arr[left] < pivot) DO + left := left + 1; + WHILE (right > start) AND (arr[right] >= pivot) DO + right := right - 1; + IF left < right THEN + swap(arr[left], arr[right]); + END; + + { Put the pivot between the halves. } + swap(arr[start], arr[right]); + + { This is how you return function values in pascal. + Yeccch. } + Split := right + END; + + BEGIN { QuicksortRecur } + { If there's anything to do... } + IF start < stop THEN BEGIN + splitpt := Split(start, stop); + QuicksortRecur(start, splitpt-1); + QuicksortRecur(splitpt+1, stop); + END + END; + + BEGIN { Quicksort } + QuicksortRecur(1, size) + END; + + BEGIN + { Read } + ReadArr(size, arr); + + { Sort the contents. } + Quicksort(size, arr); + + { Print. } + FOR i := 1 TO size DO + writeln(arr[i]) + END. + +{ From http://sandbox.mc.edu/~bennet/cs404/doc/qsort_pas.html } diff --git a/packages/shiki/samples/perl.sample b/packages/shiki/samples/perl.sample new file mode 100644 index 000000000..43ab18d71 --- /dev/null +++ b/packages/shiki/samples/perl.sample @@ -0,0 +1,24 @@ +#!/usr/bin/perl +use strict; +use warnings; + +# first, create your message +use Email::MIME; +my $message = Email::MIME->create( + header_str => [ + From => 'you@example.com', + To => 'friend@example.com', + Subject => 'Happy birthday!', + ], + attributes => { + encoding => 'quoted-printable', + charset => 'ISO-8859-1', + }, + body_str => "Happy birthday to you!\n", +); + +# send the message +use Email::Sender::Simple qw(sendmail); +sendmail($message); + +# From https://learn.perl.org/examples/email.html diff --git a/packages/shiki/samples/php.sample b/packages/shiki/samples/php.sample new file mode 100644 index 000000000..b9af3eb91 --- /dev/null +++ b/packages/shiki/samples/php.sample @@ -0,0 +1,29 @@ +command('inspire')->hourly(); + } + + /** + * Register the commands for the application. + */ + protected function commands(): void + { + $this->load(__DIR__.'/Commands'); + + require base_path('routes/console.php'); + } +} + +// From https://github.com/laravel/laravel/blob/10.x/app/Console/Kernel.php diff --git a/packages/shiki/samples/plsql.sample b/packages/shiki/samples/plsql.sample new file mode 100644 index 000000000..f03d7a6a7 --- /dev/null +++ b/packages/shiki/samples/plsql.sample @@ -0,0 +1,20 @@ +-- available online in file 'examp1' +DECLARE + qty_on_hand NUMBER(5); +BEGIN + SELECT quantity INTO qty_on_hand FROM inventory + WHERE product = 'TENNIS RACKET' + FOR UPDATE OF quantity; + IF qty_on_hand > 0 THEN -- check quantity + UPDATE inventory SET quantity = quantity - 1 + WHERE product = 'TENNIS RACKET'; + INSERT INTO purchase_record + VALUES ('Tennis racket purchased', SYSDATE); + ELSE + INSERT INTO purchase_record + VALUES ('Out of tennis rackets', SYSDATE); + END IF; + COMMIT; +END; + +-- From https://docs.oracle.com/cd/B10500_01/appdev.920/a96624/01_oview.htm#7106 diff --git a/packages/shiki/samples/postcss.sample b/packages/shiki/samples/postcss.sample new file mode 100644 index 000000000..0a26ec9cd --- /dev/null +++ b/packages/shiki/samples/postcss.sample @@ -0,0 +1,19 @@ +{ + "plugins": [ + "postcss-flexbugs-fixes", + [ + "postcss-preset-env", + { + "autoprefixer": { + "flexbox": "no-2009" + }, + "stage": 3, + "features": { + "custom-properties": false + } + } + ] + ] +} + +// From https://nextjs.org/docs/pages/building-your-application/configuring/post-css diff --git a/packages/shiki/samples/powershell.sample b/packages/shiki/samples/powershell.sample new file mode 100644 index 000000000..65fe3b79d --- /dev/null +++ b/packages/shiki/samples/powershell.sample @@ -0,0 +1,22 @@ +## Define the service name in a variable +$ServiceName = 'EventLog' + +## Read the service from Windows to return a service object +$ServiceInfo = Get-Service -Name $ServiceName + +## If the server is not running (ne) +if ($ServiceInfo.Status -ne 'Running') { + ## Write to the console that the service is not running + Write-Host 'Service is not started, starting service' + ## Start the service + Start-Service -Name $ServiceName + ## Update the $ServiceInfo object to reflect the new state + $ServiceInfo.Refresh() + ## Write to the console the Status property which indicates the state of the service + Write-Host $ServiceInfo.Status +} else { ## If the Status is anything but Running + ## Write to the console the service is already running + Write-Host 'The service is already running.' +} + +## From https://adamtheautomator.com/powershell-script-examples/ diff --git a/packages/shiki/samples/prolog.sample b/packages/shiki/samples/prolog.sample new file mode 100644 index 000000000..2cc0bf68c --- /dev/null +++ b/packages/shiki/samples/prolog.sample @@ -0,0 +1,179 @@ +#!/usr/bin/swipl +% vim: ft=prolog textwidth=80 tabstop=4 softtabstop=4 shiftwidth=4 expandtab + +map_size(78, 23). +map_upper_bound(XMax, YMax) :- + map_size(XSize, YSize), + XMax is XSize - 1, + YMax is YSize - 1. + +in_map(X, Y) :- + X >= 0, + Y >= 0, + map_size(XSize, YSize), + X < XSize, + Y < YSize. + +tile(wall, X, Y) :- \+ in_map(X, Y). +tile(floor, X, Y) :- in_map(X, Y). +% tile(wall, 0, _). +% tile(wall, _, 0). +% tile(wall, X, _) :- map_upper_bound(X, _). +% tile(wall, _, Y) :- map_upper_bound(_, Y). + +:- dynamic(player/2, messages/1). + +player(2,3). +messages(["", ""]). +message_lines(2). + +msg(Message) :- + messages(Tail), + retractall(messages(_)), + assertz(messages([Message|Tail])). + +%%%%%%%%%%%%%%%% +% drawing code % +%%%%%%%%%%%%%%%% + +draw_char(_X, Y) :- + tty_size(YSize, _), + % map_size(_, YSize), + Y >= YSize. +draw_char(X, Y) :- + tty_size(_, XSize), + % map_size(XSize, _), + X >= XSize, + NY is Y + 1, + %nl, + draw_char(0, NY). +draw_char(X, Y) :- + ( X = 0 + ->tty_goto(X, Y) + ; true + ), + + message_lines(YMsgs), + ( Y < YMsgs + -> write(' ') + ; display_offset(XOff, YOff), + XMap is X + XOff, + YMap is Y + YOff, + get_character(XMap, YMap, C), + format('~s', [C]) + ), + NX is X + 1, + draw_char(NX, Y). + +display_offset(X, Y) :- + player(XPos, YPos), + tty_size(YSize, XSize), + message_lines(YMsgs), + X is XPos - floor(XSize / 2), + Y is YPos - floor((YSize - YMsgs) / 2). + +display_msgs(Line) :- message_lines(Line). +display_msgs(Line) :- + message_lines(LineCount), + MsgId is LineCount - Line, + messages(Messages), + nth1(MsgId, Messages, Message), + tty_goto(0, Line), + format('~s', [Message]), + NextLine is Line + 1, + display_msgs(NextLine). + +draw :- + once(draw_char(0, 0)), + map_size(_, YSize), + display_msgs(0), + tty_goto(0, YSize). + +% character displayed for a position on map +get_character(X, Y, "@") :- player(X, Y). +get_character(X, Y, C) :- + tile(Tile, X, Y), + tile_display(Tile, C). + +tile_display(wall, "#"). +tile_display(floor, "."). + +tile_passable(floor). + +% % get line of a map to display as a string into aggregator, starting from XCur +% % as rightmost character +% get_line(Y, XCur, Trail, Agg) :- +% ( XCur < 0 +% -> Trail = Agg +% ; XPrev is XCur - 1, +% get_character(XCur, Y, C), +% get_line(Y, XPrev, [C|Trail], Agg) +% ). + +% get_screen(YCur, Trail, Agg) :- +% ( YCur < 0 +% -> Trail = Agg +% ; YPrev is YCur - 1, +% map_size(XSize, _), +% XLast is XSize - 1, +% get_line(YCur, XLast, [], Line), +% get_screen(YPrev, [Line|Trail], Agg) +% ). + +% get_screen(Lines) :- +% map_size(_, YSize), +% YLast is YSize - 1, +% get_screen(YLast, [], Lines). + +% % draw a list of lines on screen +% draw_lines([]). +% draw_lines([Line|Rest]) :- +% name(LineAtom, Line), +% write(LineAtom), +% nl, +% draw_lines(Rest). + +% % draw current map +% draw :- get_screen(Lines), draw_lines(Lines). + +%%%%%%%%%%%%%%%%%%%% +% interaction code % +%%%%%%%%%%%%%%%%%%%% + +move_player(X, Y) :- + player(XCur, YCur), + XNew is XCur + X, + YNew is YCur + Y, + ( tile(Tile, XNew, YNew), + tile_passable(Tile) + -> retractall(player(_, _)), + asserta(player(XNew, YNew)) + ; print('Bump!'), nl + ). + +act("\n"). +act("\r"). + +act("h") :- msg("left"), move_player(-1, 0). +act("j") :- msg("down"), move_player( 0, 1). +act("k") :- msg("up"), move_player( 0, -1). +act("l") :- msg("right"), move_player( 1, 0). + +act("y") :- move_player(-1, -1). +act("u") :- move_player( 1, -1). +act("b") :- move_player(-1, 1). +act("n") :- move_player( 1, 1). + +mainloop :- + draw, + get_single_char(C), + ( act([C]) + -> true + ; format(codes(Msg), 'unknown character code: ~d', [C]), + msg(Msg) + ), + mainloop. + +main :- mainloop. + +% From https://github.com/Anniepoo/prolog-examples/blob/master/roguelike.pl diff --git a/packages/shiki/samples/pug.sample b/packages/shiki/samples/pug.sample new file mode 100644 index 000000000..6e6c6b574 --- /dev/null +++ b/packages/shiki/samples/pug.sample @@ -0,0 +1,18 @@ +doctype html +html(lang="en") + head + title= pageTitle + script(type='text/javascript'). + if (foo) bar(1 + 5); + body + h1 Pug - node template engine + #container.col + if youAreUsingPug + p You are amazing + else + p Get on it! + p. + Pug is a terse and simple templating language with a + strong focus on performance and powerful features. + +//- From https://github.com/pugjs/pug diff --git a/packages/shiki/samples/puppet.sample b/packages/shiki/samples/puppet.sample new file mode 100644 index 000000000..69f2e010f --- /dev/null +++ b/packages/shiki/samples/puppet.sample @@ -0,0 +1,19 @@ +class ntp::service { + + if ! ($ntp::service_ensure in [ 'running', 'stopped' ]) { + fail('service_ensure parameter must be running or stopped') + } + + if $ntp::service_manage == true { + service { 'ntp': + ensure => $ntp::service_ensure, + enable => $ntp::service_enable, + name => $ntp::service_name, + provider => $ntp::service_provider, + hasstatus => true, + hasrestart => true, + } + } +} + +# From https://www.puppet.com/docs/puppet/8/bgtm.html diff --git a/packages/shiki/samples/purescript.sample b/packages/shiki/samples/purescript.sample new file mode 100644 index 000000000..b6a21a155 --- /dev/null +++ b/packages/shiki/samples/purescript.sample @@ -0,0 +1,81 @@ +module Main where + +import Data.Either (Either(..)) +import Data.Eq (class Eq) +import Data.Function.Uncurried (Fn2, mkFn2, runFn2) +import Data.List (List(..), filter, (:)) +import Data.Maybe (Maybe(..)) +import Data.String.Regex (Regex, parseFlags, regex, replace) +import Effect (Effect) +import Effect.Console (log, logShow) +import Partial.Unsafe (unsafePartial) +import Prelude (Unit, discard, map, mod, show, (+), (==), ($), (/=), (<>)) + +type Dict key value = key → Maybe value + +emptyDict :: ∀ k v. Dict k v +emptyDict _ = Nothing + +insertDict :: ∀ k v. (Eq k) => k → v → Dict k v → Dict k v +insertDict key value dict = + \key' → if key == key' + then (Just value) + else dict key' + + +-- | Take a look at src/Main.js to see how we curry arguments +-- | in Javascript +foreign import myAdd :: Int → Int → Int + +-- | When performance is critical then use Data.Function.Uncurried +myAddFast :: Fn2 Int Int Int +myAddFast = mkFn2 \x y → x + y + +add10 :: Int -> Int +add10 = myAdd 10 + +modulo :: Int -> Int -> Int +modulo dvr dvd = dvd `mod` dvr + +isOdd :: Int -> Int +isOdd = modulo 2 + +getAllOdds :: List Int -> List Int +getAllOdds = filter (\x -> isOdd x /= 0) + +regexString :: Regex +regexString = + unsafePartial + case (regex "[aeiou]" (parseFlags "ig")) of + Right r -> r + +censor :: String -> String +censor = replace regexString "*" + +censorAll :: Array String -> Array String +censorAll = map censor + +main :: Effect Unit +main = do + log "Build curried functions" + log "\nAdvantage 1: Partially applying functions" + log $ "myAdd: " <> (show $ myAdd 2 2) + log "\nAdvantage 2: function types" + -- notice key' == key ('a' == 'a'), so return Just 1 + logShow $ (insertDict 'a' (1::Int) emptyDict) 'a' + -- search for 'a' in Dict and return its value + logShow $ insertDict 'b' 2 (insertDict 'a' (1::Int) emptyDict) 'a' + -- the 'x' key is not in Dict, so fall back to Nothing + logShow $ insertDict 'b' 2 (insertDict 'a' (1::Int) emptyDict) 'x' + log "\nCurrying Examples: add10, isOdd, isOdd21, getAllOdds" + logShow $ add10 2 + logShow $ isOdd 2 + logShow $ isOdd 21 + logShow $ getAllOdds (1 : 2 : 3 : 4 : Nil) + log "\nBuild up predicate functions" + log $ censor "hello world" + logShow $ censorAll ["hello", "world"] + log "\nUse Data.Function.Uncurried when performance is critical" + logShow $ runFn2 myAddFast 10 10 + +-- From https://github.com/adkelley/javascript-to-purescript/blob/master/tut17/src/Main.purs diff --git a/packages/shiki/samples/r.sample b/packages/shiki/samples/r.sample new file mode 100644 index 000000000..e10ab6daf --- /dev/null +++ b/packages/shiki/samples/r.sample @@ -0,0 +1,21 @@ +Year.Release <- game$Year.Release +counts <- data.frame(table(Year.Release)) +p <- game %>% + select(Year.Release, Global.Sales) %>% + group_by(Year.Release) %>% + summarise(Total.Sales = sum(Global.Sales)) +q <- cbind.data.frame(p, counts[2]) # Add counts to data frame +names(q)[3] <- "count" +q$count <- as.numeric(q$count) + +ggplot(q, aes(x = Year.Release, y = Total.Sales, label = q$count)) + + geom_col(fill = "green") + + geom_point(y = q$count * 500000, size = 3, shape = 21, fill = "Yellow" ) + + geom_text(y = (q$count + 50) * 500000) + # Position of the text: count of games each year + theme(axis.text.x = element_text(angle = 90), + panel.background = element_rect(fill = "purple"), + panel.grid.major = element_blank(), + panel.grid.minor = element_blank()) + + scale_x_discrete("Year.Release", labels = as.character(Year.Release), breaks = Year.Release) + +# From https://gexijin.github.io/learnR/the-game-sales-dataset.html#analysis-of-sales diff --git a/packages/shiki/samples/raku.sample b/packages/shiki/samples/raku.sample new file mode 100644 index 000000000..7c915252e --- /dev/null +++ b/packages/shiki/samples/raku.sample @@ -0,0 +1,37 @@ +use v6; + +# start by printing out the header. +say "Tournament Results:\n"; + +my $file = open 'scores.txt'; # get filehandle and... +my @names = $file.get.words; # ... get players. + +my %matches; +my %sets; + +for $file.lines -> $line { + next unless $line; # ignore any empty lines + + my ($pairing, $result) = $line.split(' | '); + my ($p1, $p2) = $pairing.words; + my ($r1, $r2) = $result.split(':'); + + %sets{$p1} += $r1; + %sets{$p2} += $r2; + + if $r1 > $r2 { + %matches{$p1}++; + } else { + %matches{$p2}++; + } +} + +my @sorted = @names.sort({ %sets{$_} }).sort({ %matches{$_} }).reverse; + +for @sorted -> $n { + my $match-noun = %matches{$n} == 1 ?? 'match' !! 'matches'; + my $set-noun = %sets{$n} == 1 ?? 'set' !! 'sets'; + say "$n has won %matches{$n} $match-noun and %sets{$n} $set-noun"; +} + +# From https://docs.raku.org/language/101-basics diff --git a/packages/shiki/samples/razor.sample b/packages/shiki/samples/razor.sample new file mode 100644 index 000000000..c5d42c722 --- /dev/null +++ b/packages/shiki/samples/razor.sample @@ -0,0 +1,25 @@ +@{ + string message = "foreignObject example with Scalable Vector Graphics (SVG)"; +} + + + + +

    @message

    +
    +
    + + + +@{ var i = 0; } +@do +{ + var person = people[i]; +

    Name: @person.Name

    +

    Age: @person.Age

    + + i++; +} while (i < people.Length); + + diff --git a/packages/shiki/samples/riscv.sample b/packages/shiki/samples/riscv.sample new file mode 100644 index 000000000..45f9741b6 --- /dev/null +++ b/packages/shiki/samples/riscv.sample @@ -0,0 +1,30 @@ +# +# Risc-V Assembler program to print "Hello World!" +# to stdout. +# +# a0-a2 - parameters to linux function services +# a7 - linux function number +# + +.global _start # Provide program starting address to linker + +# Setup the parameters to print hello world +# and then call Linux to do it. + +_start: addi a0, x0, 1 # 1 = StdOut + la a1, helloworld # load address of helloworld + addi a2, x0, 13 # length of our string + addi a7, x0, 64 # linux write system call + ecall # Call linux to output the string + +# Setup the parameters to exit the program +# and then call Linux to do it. + + addi a0, x0, 0 # Use 0 return code + addi a7, x0, 93 # Service command code 93 terminates + ecall # Call linux to terminate the program + +.data +helloworld: .ascii "Hello World!\n" + +# From https://smist08.wordpress.com/2019/09/07/risc-v-assembly-language-hello-world/ diff --git a/packages/shiki/samples/rst.sample b/packages/shiki/samples/rst.sample new file mode 100644 index 000000000..183bdf55e --- /dev/null +++ b/packages/shiki/samples/rst.sample @@ -0,0 +1,27 @@ +* This is a bulleted list. +* It has two items, the second + item uses two lines. + +1. This is a numbered list. +2. It has two items too. + +#. This is a numbered list. +#. It has two items too. + +This is a normal text paragraph. The next paragraph is a code sample:: + + It is not processed in any way, except + that the indentation is removed. + + It can span multiple lines. + +This is a normal text paragraph again. + +Lorem ipsum [#]_ dolor sit amet ... [#]_ + +.. rubric:: Footnotes + +.. [#] Text of the first footnote. +.. [#] Text of the second footnote. + +.. From https://devguide.python.org/documentation/markup/ diff --git a/packages/shiki/samples/rust.sample b/packages/shiki/samples/rust.sample new file mode 100644 index 000000000..bbc3f4f72 --- /dev/null +++ b/packages/shiki/samples/rust.sample @@ -0,0 +1,39 @@ +// Unlike C/C++, there's no restriction on the order of function definitions +fn main() { + // We can use this function here, and define it somewhere later + fizzbuzz_to(100); +} + +// Function that returns a boolean value +fn is_divisible_by(lhs: u32, rhs: u32) -> bool { + // Corner case, early return + if rhs == 0 { + return false; + } + + // This is an expression, the `return` keyword is not necessary here + lhs % rhs == 0 +} + +// Functions that "don't" return a value, actually return the unit type `()` +fn fizzbuzz(n: u32) -> () { + if is_divisible_by(n, 15) { + println!("fizzbuzz"); + } else if is_divisible_by(n, 3) { + println!("fizz"); + } else if is_divisible_by(n, 5) { + println!("buzz"); + } else { + println!("{}", n); + } +} + +// When a function returns `()`, the return type can be omitted from the +// signature +fn fizzbuzz_to(n: u32) { + for n in 1..=n { + fizzbuzz(n); + } +} + +// From https://doc.rust-lang.org/rust-by-example/fn.html diff --git a/packages/shiki/samples/sas.sample b/packages/shiki/samples/sas.sample new file mode 100644 index 000000000..2a4e63418 --- /dev/null +++ b/packages/shiki/samples/sas.sample @@ -0,0 +1,17 @@ +DATA TEMP; +INPUT ID $ NAME $ SALARY DEPARTMENT $; +comm = SALARY*0.25; +LABEL ID = 'Employee ID' comm = 'COMMISION'; +DATALINES; +1 Rick 623.3 IT +2 Dan 515.2 Operations +3 Michelle 611 IT +4 Ryan 729 HR +5 Gary 843.25 Finance +6 Nina 578 IT +7 Simon 632.8 Operations +8 Guru 722.5 Finance +; +RUN; + +* From https://www.tutorialspoint.com/sas/sas_program_structure.htm diff --git a/packages/shiki/samples/sass.sample b/packages/shiki/samples/sass.sample new file mode 100644 index 000000000..2794b51b4 --- /dev/null +++ b/packages/shiki/samples/sass.sample @@ -0,0 +1,27 @@ +/* This CSS will print because %message-shared is extended. */ +%message-shared + border: 1px solid #ccc + padding: 10px + color: #333 + +// This CSS won't print because %equal-heights is never extended. +%equal-heights + display: flex + flex-wrap: wrap + +.message + @extend %message-shared + +.success + @extend %message-shared + border-color: green + +.error + @extend %message-shared + border-color: red + +.warning + @extend %message-shared + border-color: yellow + +// From https://sass-lang.com/guide/ diff --git a/packages/shiki/samples/scala.sample b/packages/shiki/samples/scala.sample new file mode 100644 index 000000000..42a961961 --- /dev/null +++ b/packages/shiki/samples/scala.sample @@ -0,0 +1,14 @@ +class Date(y: Int, m: Int, d: Int) extends Ord: + // previous decls here + + def <(that: Any): Boolean = that match + case d: Date => + (year < d.year) || + (year == d.year && (month < d.month || + (month == d.month && day < d.day))) + + case _ => sys.error("cannot compare " + that + " and a Date") + end < +end Date + +// From https://docs.scala-lang.org/tutorials/scala-for-java-programmers.html diff --git a/packages/shiki/samples/scheme.sample b/packages/shiki/samples/scheme.sample new file mode 100644 index 000000000..33a654474 --- /dev/null +++ b/packages/shiki/samples/scheme.sample @@ -0,0 +1,26 @@ +(define WINDOW-WIDTH 150) +(define WINDOW-HEIGHT 180) + +; A world is a number. +; Its display is a blue disk of that size. +; show-world : world -> image +(define (show-world diameter) + (circle diameter "solid" "blue")) +"Examples of show-world:" +(show-world 1) "should be a blue dot" +(show-world 20) "should be" (circle 20 "solid" "blue") + +; The next world is one larger. +; next-world : world -> world +(define (next-world diameter) + (+ 1 diameter)) +"Examples of next-world:" +(next-world 7) "should be" 8 + +"Now let's start the animation!" + +(big-bang WINDOW-WIDTH WINDOW-HEIGHT 1 1) +(on-update-event show-world) +(on-tick-event next-world) + +; From https://home.adelphi.edu/sbloch/class/archive/160/spring2005/examples/ diff --git a/packages/shiki/samples/scss.sample b/packages/shiki/samples/scss.sample new file mode 100644 index 000000000..4c17f36af --- /dev/null +++ b/packages/shiki/samples/scss.sample @@ -0,0 +1,17 @@ +nav { + ul { + margin: 0; + padding: 0; + list-style: none; + } + + li { display: inline-block; } + + a { + display: block; + padding: 6px 12px; + text-decoration: none; + } +} + +// From https://sass-lang.com/guide/ diff --git a/packages/shiki/samples/shaderlab.sample b/packages/shiki/samples/shaderlab.sample new file mode 100644 index 000000000..19691b1ac --- /dev/null +++ b/packages/shiki/samples/shaderlab.sample @@ -0,0 +1,60 @@ +Shader "Unlit/NewUnlitShader" +{ + Properties + { + _MainTex ("Texture", 2D) = "white" {} + } + SubShader + { + Tags { "RenderType"="Opaque" } + LOD 100 + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + // make fog work + #pragma multi_compile_fog + + #include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float2 uv : TEXCOORD0; + UNITY_FOG_COORDS(1) + float4 vertex : SV_POSITION; + }; + + sampler2D _MainTex; + float4 _MainTex_ST; + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.uv = TRANSFORM_TEX(v.uv, _MainTex); + UNITY_TRANSFER_FOG(o,o.vertex); + return o; + } + + fixed4 frag (v2f i) : SV_Target + { + // sample the texture + fixed4 col = tex2D(_MainTex, i.uv); + // apply fog + UNITY_APPLY_FOG(i.fogCoord, col); + return col; + } + ENDCG + } + } +} + +// From https://docs.unity3d.com/Manual/SL-VertexFragmentShaderExamples.html diff --git a/packages/shiki/samples/shellscript.sample b/packages/shiki/samples/shellscript.sample new file mode 100644 index 000000000..9f948b529 --- /dev/null +++ b/packages/shiki/samples/shellscript.sample @@ -0,0 +1,28 @@ +#!/bin/bash +# weather.sh +# Copyright 2018 computer-geek64. All rights reserved. + +program=Weather +version=1.1 +year=2018 +developer=computer-geek64 + +case $1 in +-h | --help) + echo "$program $version" + echo "Copyright $year $developer. All rights reserved." + echo + echo "Usage: weather [options]" + echo "Option Long Option Description" + echo "-h --help Show the help screen" + echo "-l [location] --location [location] Specifies the location" + ;; +-l | --location) + curl https://wttr.in/$2 + ;; +*) + curl https://wttr.in + ;; +esac + +# From https://github.com/ruanyf/simple-bash-scripts/blob/master/scripts/weather.sh diff --git a/packages/shiki/samples/smalltalk.sample b/packages/shiki/samples/smalltalk.sample new file mode 100644 index 000000000..72d5dbd8e --- /dev/null +++ b/packages/shiki/samples/smalltalk.sample @@ -0,0 +1,11 @@ +exampleWithNumber: x + | y | + true & false not & (nil isNil) ifFalse: [self halt]. + y := self size + super size. + #($a #a 'a' 1 1.0) + do: [ :each | + Transcript show: (each class name); + show: ' ']. + ^x < y + +"From https://en.wikipedia.org/wiki/Smalltalk" diff --git a/packages/shiki/samples/solidity.sample b/packages/shiki/samples/solidity.sample new file mode 100644 index 000000000..dd9e058d3 --- /dev/null +++ b/packages/shiki/samples/solidity.sample @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +contract Array { + // Several ways to initialize an array + uint[] public arr; + uint[] public arr2 = [1, 2, 3]; + // Fixed sized array, all elements initialize to 0 + uint[10] public myFixedSizeArr; + + function get(uint i) public view returns (uint) { + return arr[i]; + } + + // Solidity can return the entire array. + // But this function should be avoided for + // arrays that can grow indefinitely in length. + function getArr() public view returns (uint[] memory) { + return arr; + } + + function push(uint i) public { + // Append to array + // This will increase the array length by 1. + arr.push(i); + } + + function pop() public { + // Remove last element from array + // This will decrease the array length by 1 + arr.pop(); + } + + function getLength() public view returns (uint) { + return arr.length; + } + + function remove(uint index) public { + // Delete does not change the array length. + // It resets the value at index to it's default value, + // in this case 0 + delete arr[index]; + } + + function examples() external { + // create array in memory, only fixed size can be created + uint[] memory a = new uint[](5); + } +} + +// From https://solidity-by-example.org/array/ diff --git a/packages/shiki/samples/sql.sample b/packages/shiki/samples/sql.sample new file mode 100644 index 000000000..c4c6bd144 --- /dev/null +++ b/packages/shiki/samples/sql.sample @@ -0,0 +1,17 @@ +USE AdventureWorks2022; +GO +IF OBJECT_ID('dbo.NewProducts', 'U') IS NOT NULL + DROP TABLE dbo.NewProducts; +GO +ALTER DATABASE AdventureWorks2022 SET RECOVERY BULK_LOGGED; +GO + +SELECT * INTO dbo.NewProducts +FROM Production.Product +WHERE ListPrice > $25 +AND ListPrice < $100; +GO +ALTER DATABASE AdventureWorks2022 SET RECOVERY FULL; +GO + +-- From https://learn.microsoft.com/en-us/sql/t-sql/queries/select-examples-transact-sql diff --git a/packages/shiki/samples/ssh-config.sample b/packages/shiki/samples/ssh-config.sample new file mode 100644 index 000000000..b84867f00 --- /dev/null +++ b/packages/shiki/samples/ssh-config.sample @@ -0,0 +1,47 @@ +### default for all ## +Host * + ForwardAgent no + ForwardX11 no + ForwardX11Trusted yes + User nixcraft + Port 22 + Protocol 2 + ServerAliveInterval 60 + ServerAliveCountMax 30 + +## override as per host ## +Host server1 + HostName server1.cyberciti.biz + User nixcraft + Port 4242 + IdentityFile /nfs/shared/users/nixcraft/keys/server1/id_rsa + +## Home nas server ## +Host nas01 + HostName 192.168.1.100 + User root + IdentityFile ~/.ssh/nas01.key + +## Login AWS Cloud ## +Host aws.apache + HostName 1.2.3.4 + User wwwdata + IdentityFile ~/.ssh/aws.apache.key + +## Login to internal lan server at 192.168.0.251 via our public uk office ssh based gateway using ## +## $ ssh uk.gw.lan ## +Host uk.gw.lan uk.lan + HostName 192.168.0.251 + User nixcraft + ProxyCommand ssh nixcraft@gateway.uk.cyberciti.biz nc %h %p 2> /dev/null + +## Our Us Proxy Server ## +## Forward all local port 3128 traffic to port 3128 on the remote vps1.cyberciti.biz server ## +## $ ssh -f -N proxyus ## +Host proxyus + HostName vps1.cyberciti.biz + User breakfree + IdentityFile ~/.ssh/vps1.cyberciti.biz.key + LocalForward 3128 127.0.0.1:3128 + +## From https://www.cyberciti.biz/faq/create-ssh-config-file-on-linux-unix/ diff --git a/packages/shiki/samples/stylus.sample b/packages/shiki/samples/stylus.sample new file mode 100644 index 000000000..675a5a716 --- /dev/null +++ b/packages/shiki/samples/stylus.sample @@ -0,0 +1,33 @@ +vendor(prop, args) + -webkit-{prop} args + -moz-{prop} args + {prop} args + +border-radius() + vendor('border-radius', arguments) + +box-shadow() + vendor('box-shadow', arguments) + +button + border-radius 1px 2px / 3px 4px + +border-radius() { + -webkit-border-radius: arguments; + -moz-border-radius: arguments; + border-radius: arguments; +} + +body a { + font: 12px/1.4 "Lucida Grande", Arial, sans-serif; + background: black; + color: #ccc; +} + +form input { + padding: 5px; + border: 1px solid; + border-radius: 5px; +} + +// From https://stylus-lang.com/docs/css-style.html#example diff --git a/packages/shiki/samples/svelte.sample b/packages/shiki/samples/svelte.sample new file mode 100644 index 000000000..59ce14c0e --- /dev/null +++ b/packages/shiki/samples/svelte.sample @@ -0,0 +1,28 @@ + + + + + + + + +{#if files} +

    Selected files:

    + {#each Array.from(files) as file} +

    {file.name} ({file.size} bytes)

    + {/each} +{/if} + +// From https://svelte.dev/examples/file-inputs diff --git a/packages/shiki/samples/swift.sample b/packages/shiki/samples/swift.sample new file mode 100644 index 000000000..754acb247 --- /dev/null +++ b/packages/shiki/samples/swift.sample @@ -0,0 +1,20 @@ +class Residence { + var rooms: [Room] = [] + var numberOfRooms: Int { + return rooms.count + } + subscript(i: Int) -> Room { + get { + return rooms[i] + } + set { + rooms[i] = newValue + } + } + func printNumberOfRooms() { + print("The number of rooms is \(numberOfRooms)") + } + var address: Address? +} + +// From https://docs.swift.org/swift-book/documentation/the-swift-programming-language/optionalchaining#Defining-Model-Classes-for-Optional-Chaining diff --git a/packages/shiki/samples/system-verilog.sample b/packages/shiki/samples/system-verilog.sample new file mode 100644 index 000000000..d0c069d50 --- /dev/null +++ b/packages/shiki/samples/system-verilog.sample @@ -0,0 +1,30 @@ +// File : tb_top.sv +module tb_top (); + + reg clk; + reg resetn; + reg d; + wire q; + + // Instantiate the design + d_ff d_ff0 ( .clk (clk), + .resetn (resetn), + .d (d), + .q (q)); + + // Create a clock + always #10 clk <= ~clk; + + initial begin + resetn <= 0; + d <= 0; + + #10 resetn <= 1; + #5 d <= 1; + #8 d <= 0; + #2 d <= 1; + #10 d <= 0; + end +endmodule + +// From https://www.chipverify.com/tutorials/systemverilog diff --git a/packages/shiki/samples/tcl.sample b/packages/shiki/samples/tcl.sample new file mode 100644 index 000000000..035740680 --- /dev/null +++ b/packages/shiki/samples/tcl.sample @@ -0,0 +1,51 @@ +proc set'contains {set el} {expr {[lsearch -exact $set $el]>=0}} + +e.g. {set'contains {A B C} A} -> 1 +e.g. {set'contains {A B C} D} -> 0 + +proc set'add {_set args} { + upvar 1 $_set set + foreach el $args { + if {![set'contains $set $el]} {lappend set $el} + } + set set +} + +set example {1 2 3} +e.g. {set'add example 4} -> {1 2 3 4} +e.g. {set'add example 4} -> {1 2 3 4} + +proc set'remove {_set args} { + upvar 1 $_set set + foreach el $args { + set pos [lsearch -exact $set $el] + set set [lreplace $set $pos $pos] + } + set set +} + +e.g. {set'remove example 3} -> {1 2 4} + +proc set'intersection {a b} { + foreach el $a {set arr($el) ""} + set res {} + foreach el $b {if {[info exists arr($el)]} {lappend res $el}} + set res + +e.g. {set'intersection {1 2 3 4} {2 4 6 8}} -> {2 4} + +proc set'union {a b} { + foreach el $a {set arr($el) ""} + foreach el $b {set arr($el) ""} + lsort [array names arr] +} + +e.g. {set'union {1 3 5 7} {2 4 6 8}} -> {1 2 3 4 5 6 7 8} + +proc set'difference {a b} { + eval set'remove a $b +} + +e.g. {set'difference {1 2 3 4 5} {2 4 6}} -> {1 3 5} + +# https://en.wikibooks.org/wiki/Tcl_Programming/Examples diff --git a/packages/shiki/samples/tex.sample b/packages/shiki/samples/tex.sample new file mode 100644 index 000000000..8cab48953 --- /dev/null +++ b/packages/shiki/samples/tex.sample @@ -0,0 +1,29 @@ +\documentclass{article} + +\usepackage{expl3} + +\ExplSyntaxOn + \cs_new_eq:NN \calc \fp_eval:n +\ExplSyntaxOff + +\def\valueA{7} +\def\valueB{19} +\def\valueC{41} +\def\valueD{31} +\def\valueE{25} +\def\valueF{17} +\def\valueG{7} +\def\valueH{3} + +\begin{document} + +\noindent I have the list +\[ +\valueA,\valueB,\valueC,\valueD,\valueE,\valueF,\valueG,\valueH +\] +in which the largest element is $\calc{max(\valueA,\valueB,\valueC,\valueD,\valueE,\valueF,\valueG,\valueH)}$ (but that is of no importance to me).\\[\baselineskip] +How can I get \LaTeX{} to extract the position number of the largest element in a list? (In the example above, the answer is of course `$3$'.) + +\end{document} + +% From https://tex.stackexchange.com/questions/231558/position-of-largest-element-in-a-list diff --git a/packages/shiki/samples/toml.sample b/packages/shiki/samples/toml.sample new file mode 100644 index 000000000..ca64f1900 --- /dev/null +++ b/packages/shiki/samples/toml.sample @@ -0,0 +1,25 @@ +# This is a TOML document + +title = "TOML Example" + +[owner] +name = "Tom Preston-Werner" +dob = 1979-05-27T07:32:00-08:00 + +[database] +enabled = true +ports = [ 8000, 8001, 8002 ] +data = [ ["delta", "phi"], [3.14] ] +temp_targets = { cpu = 79.5, case = 72.0 } + +[servers] + +[servers.alpha] +ip = "10.0.0.1" +role = "frontend" + +[servers.beta] +ip = "10.0.0.2" +role = "backend" + +# From https://toml.io/en/ diff --git a/packages/shiki/samples/twig.sample b/packages/shiki/samples/twig.sample new file mode 100644 index 000000000..fbde3c653 --- /dev/null +++ b/packages/shiki/samples/twig.sample @@ -0,0 +1,18 @@ + + + + My Webpage + + + + +

    My Webpage

    + {{ a_variable }} + + + +{# From https://twig.symfony.com/doc/3.x/templates.html #} diff --git a/packages/shiki/samples/typescript.sample b/packages/shiki/samples/typescript.sample new file mode 100644 index 000000000..0376eccc8 --- /dev/null +++ b/packages/shiki/samples/typescript.sample @@ -0,0 +1,24 @@ +enum LogLevel { + ERROR, + WARN, + INFO, + DEBUG, +} + +/** + * This is equivalent to: + * type LogLevelStrings = 'ERROR' | 'WARN' | 'INFO' | 'DEBUG'; + */ +type LogLevelStrings = keyof typeof LogLevel; + +function printImportant(key: LogLevelStrings, message: string) { + const num = LogLevel[key]; + if (num <= LogLevel.WARN) { + console.log("Log level key is:", key); + console.log("Log level value is:", num); + console.log("Log level message is:", message); + } +} +printImportant("ERROR", "This is a message"); + +// From https://www.typescriptlang.org/docs/handbook/enums.html diff --git a/packages/shiki/samples/vb.sample b/packages/shiki/samples/vb.sample new file mode 100644 index 000000000..bd6c4e431 --- /dev/null +++ b/packages/shiki/samples/vb.sample @@ -0,0 +1,38 @@ +Imports System +Imports System.Drawing +Imports System.Windows.Forms + +Public Class HelloWindows + + Inherits Form + + Private lblHelloWindows As Label + + Public Shared Sub Main( ) + Application.Run(New HelloWindows( )) + End Sub + + Public Sub New( ) + + lblHelloWindows = New Label( ) + With lblHelloWindows + .Location = New Point(37, 31) + .Size = New Size(392, 64) + .Font = New Font("Arial", 36) + .Text = "Hello, Windows!" + .TabIndex = 0 + .TextAlign = ContentAlignment.TopCenter + End With + + Me.Text = "Programming Visual Basic .NET" + AutoScaleBaseSize = New Size(5, 13) + FormBorderStyle = FormBorderStyle.FixedSingle + ClientSize = New Size(466, 127) + + Controls.Add(lblHelloWindows) + + End Sub + +End Class + +' From https://www.oreilly.com/library/view/programming-visual-basic/0596000936/ch01s03.html diff --git a/packages/shiki/samples/verilog.sample b/packages/shiki/samples/verilog.sample new file mode 100644 index 000000000..d0c069d50 --- /dev/null +++ b/packages/shiki/samples/verilog.sample @@ -0,0 +1,30 @@ +// File : tb_top.sv +module tb_top (); + + reg clk; + reg resetn; + reg d; + wire q; + + // Instantiate the design + d_ff d_ff0 ( .clk (clk), + .resetn (resetn), + .d (d), + .q (q)); + + // Create a clock + always #10 clk <= ~clk; + + initial begin + resetn <= 0; + d <= 0; + + #10 resetn <= 1; + #5 d <= 1; + #8 d <= 0; + #2 d <= 1; + #10 d <= 0; + end +endmodule + +// From https://www.chipverify.com/tutorials/systemverilog diff --git a/packages/shiki/samples/vhdl.sample b/packages/shiki/samples/vhdl.sample new file mode 100644 index 000000000..56f3ce0f7 --- /dev/null +++ b/packages/shiki/samples/vhdl.sample @@ -0,0 +1,43 @@ +-- dual_port_RAM_visualTest.vhd + +-- created by : Meher Krishna Patel +-- date : 26-Dec-16 + +-- Functionality: + -- store and retrieve data from dual port RAM + +-- ports: + -- Write Enable (we) : SW[16] + -- Address (addr_wr) : SW[15-14] + -- Address (addr_rd) : SW[13-12] + -- din : SW[2:0] + -- dout : LEDR + +use ieee.numeric_std.all;library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity dual_port_RAM_visualTest is + generic ( + ADDR_WIDTH : integer := 2; + DATA_WIDTH : integer := 3 + ); + + port( + CLOCK_50: in std_logic; + SW : in std_logic_vector(16 downto 0); + LEDR : out std_logic_vector(DATA_WIDTH-1 downto 0) + ); +end dual_port_RAM_visualTest; + +architecture arch of dual_port_RAM_visualTest is +begin + dual_port_RAM_test: entity work.dual_port_RAM + port map (clk=>CLOCK_50, we=>SW(16), + addr_wr => SW(15 downto 14), + addr_rd => SW(13 downto 12), + din => SW(2 downto 0), + dout =>LEDR); +end arch; + +-- From https://vhdlguide.readthedocs.io/en/latest/vhdl/dex.html diff --git a/packages/shiki/samples/viml.sample b/packages/shiki/samples/viml.sample new file mode 100644 index 000000000..b036c2889 --- /dev/null +++ b/packages/shiki/samples/viml.sample @@ -0,0 +1,12 @@ +" This is the Hello World program in Vim script. +echo "Hello, world!" + +" This is a simple while loop in Vim script. +let i = 1 +while i < 5 + echo "count is" i + let i += 1 +endwhile +unlet i + +" From https://en.wikipedia.org/wiki/Vim_%28text_editor%29#Vim_script diff --git a/packages/shiki/samples/vue-html.sample b/packages/shiki/samples/vue-html.sample new file mode 100644 index 000000000..c1b43e42f --- /dev/null +++ b/packages/shiki/samples/vue-html.sample @@ -0,0 +1,15 @@ + +
    + + + + + +
    + {{ item }} + +
    +
    +
    + +// From https://vuejs.org/examples/#list-transition diff --git a/packages/shiki/samples/vue.sample b/packages/shiki/samples/vue.sample new file mode 100644 index 000000000..5515f80c2 --- /dev/null +++ b/packages/shiki/samples/vue.sample @@ -0,0 +1,45 @@ + + + + + + +// From https://vuejs.org/examples/#tree diff --git a/packages/shiki/samples/wasm.sample b/packages/shiki/samples/wasm.sample new file mode 100644 index 000000000..3009d4f82 --- /dev/null +++ b/packages/shiki/samples/wasm.sample @@ -0,0 +1,65 @@ +(module + ;; add the $even_check function to the top of the module + (func $even_check (param $n i32) (result i32) + local.get $n + i32.const 2 + i32.rem_u ;; if you take the remainder of a division by 2 + i32.const 0 ;; even numbers will have a remainder 0 + i32.eq ;; $n % 2 == 0 + ) + ;; add the $eq_2 function after $even_check + (func $eq_2 (param $n i32) (result i32) + local.get $n + i32.const 2 + i32.eq ;; returns 1 if $n == 2 + ) + + ;; add $multiple_check after $eq_2 + (func $multiple_check (param $n i32) (param $m i32) (result i32) + local.get $n + local.get $m + i32.rem_u ;; get the remainder of $n / $m + i32.const 0 ;; I want to know if the remainder is 0 + i32.eq ;; that will tell us if $n is a multiple of $m + ) + + ;; add the is_prime exported function after $multiple_check + (func (export "is_prime") (param $n i32) (result i32) + (local $i i32) + (if (i32.eq (local.get $n) (i32.const 1)) ;; 1 is not prime + (then + i32.const 0 + return + )) + (if (call $eq_2 (local.get $n)) ;; check to see if $n is 2 + (then + i32.const 1 ;; 2 is prime + return + ) + ) + (block $not_prime + (call $even_check (local.get $n)) + br_if $not_prime ;; even numbers are not prime (except 2) + + (local.set $i (i32.const 1)) + (loop $prime_test_loop + + (local.tee $i (i32.add (local.get $i) (i32.const 2) ) ) ;; $i += 2 + local.get $n ;; stack = [$n, $i] + + i32.ge_u ;; $i >= $n + if ;; if $i >= $n, $n is prime + i32.const 1 + return + end + (call $multiple_check (local.get $n) (local.get $i)) + br_if $not_prime ;; if $n is a multiple of $i this is not prime + br $prime_test_loop ;; branch back to top of loop + ) ;; end of $prime_test_loop loop + ) ;; end of $not_prime block + +i32.const 0 ;; return false + ) +) ;; end of module + +;; From https://github.com/battlelinegames/ArtOfWasm/blob/main/Chapter3/is_prime.wat diff --git a/packages/shiki/samples/wenyan.sample b/packages/shiki/samples/wenyan.sample new file mode 100644 index 000000000..7eae3bcfd --- /dev/null +++ b/packages/shiki/samples/wenyan.sample @@ -0,0 +1,25 @@ +吾有一術。名之曰「埃氏篩」。欲行是術。必先得一數。曰「甲」。乃行是術曰。 + 吾有一列。名之曰「掩」。為是「甲」遍。充「掩」以陽也。 + 除「甲」以二。名之曰「甲半」。 + + 有數二。名之曰「戊」。恆為是。若「戊」不小於「甲半」者乃止也。 + 有數二。名之曰「戌」。恆為是。若「戌」不小於「甲半」者乃止也。 + + 乘「戊」以「戌」。名之曰「合」 + 若「合」不大於「甲」者。 + 昔之「掩」之「合」者。今陰是矣。 + 若非乃止也。 + 加一以「戌」。昔之「戌」者。今其是矣云云。 + 加一以「戊」。昔之「戊」者。今其是矣云云。 + + 吾有一列。名之曰「諸素」。 + 昔之「戊」者。今二是矣。恆為是。若「戊」等於「掩」之長者乃止也。 + 夫「掩」之「戊」。名之曰「素耶」。 + 若「素耶」者充「諸素」以「戊」也。 + 加一以「戊」。昔之「戊」者。今其是矣云云。 + 乃得「諸素」。 +是謂「埃氏篩」之術也。 + +施「埃氏篩」於一百。書之。 + +// From https://wy-lang.org/ diff --git a/packages/shiki/samples/xml.sample b/packages/shiki/samples/xml.sample new file mode 100644 index 000000000..14b68b15a --- /dev/null +++ b/packages/shiki/samples/xml.sample @@ -0,0 +1,122 @@ + + + + Gambardella, Matthew + XML Developer's Guide + Computer + 44.95 + 2000-10-01 + An in-depth look at creating applications + with XML. + + + Ralls, Kim + Midnight Rain + Fantasy + 5.95 + 2000-12-16 + A former architect battles corporate zombies, + an evil sorceress, and her own childhood to become queen + of the world. + + + Corets, Eva + Maeve Ascendant + Fantasy + 5.95 + 2000-11-17 + After the collapse of a nanotechnology + society in England, the young survivors lay the + foundation for a new society. + + + Corets, Eva + Oberon's Legacy + Fantasy + 5.95 + 2001-03-10 + In post-apocalypse England, the mysterious + agent known only as Oberon helps to create a new life + for the inhabitants of London. Sequel to Maeve + Ascendant. + + + Corets, Eva + The Sundered Grail + Fantasy + 5.95 + 2001-09-10 + The two daughters of Maeve, half-sisters, + battle one another for control of England. Sequel to + Oberon's Legacy. + + + Randall, Cynthia + Lover Birds + Romance + 4.95 + 2000-09-02 + When Carla meets Paul at an ornithology + conference, tempers fly as feathers get ruffled. + + + Thurman, Paula + Splish Splash + Romance + 4.95 + 2000-11-02 + A deep sea diver finds true love twenty + thousand leagues beneath the sea. + + + Knorr, Stefan + Creepy Crawlies + Horror + 4.95 + 2000-12-06 + An anthology of horror stories about roaches, + centipedes, scorpions and other insects. + + + Kress, Peter + Paradox Lost + Science Fiction + 6.95 + 2000-11-02 + After an inadvertant trip through a Heisenberg + Uncertainty Device, James Salway discovers the problems + of being quantum. + + + O'Brien, Tim + Microsoft .NET: The Programming Bible + Computer + 36.95 + 2000-12-09 + Microsoft's .NET initiative is explored in + detail in this deep programmer's reference. + + + O'Brien, Tim + MSXML3: A Comprehensive Guide + Computer + 36.95 + 2000-12-01 + The Microsoft MSXML3 parser is covered in + detail, with attention to XML DOM interfaces, XSLT processing, + SAX and more. + + + Galos, Mike + Visual Studio 7: A Comprehensive Guide + Computer + 49.95 + 2001-04-16 + Microsoft Visual Studio 7 is explored in depth, + looking at how Visual Basic, Visual C++, C#, and ASP+ are + integrated into a comprehensive development + environment. + + + + diff --git a/packages/shiki/samples/xsl.sample b/packages/shiki/samples/xsl.sample new file mode 100644 index 000000000..ec36743ae --- /dev/null +++ b/packages/shiki/samples/xsl.sample @@ -0,0 +1,65 @@ + + + + + + + + + + + + <xsl:value-of select="/myNS:Article/myNS:Title"/> + + + + + + + +

    + + +
    + + Authors:
    + +

    + +

    + +

    + + + + +
    + + + -- + + + :: + + +
    +
    + + + + + + + + + + + + +
    + + diff --git a/packages/shiki/samples/yaml.sample b/packages/shiki/samples/yaml.sample new file mode 100644 index 000000000..7e1709ee6 --- /dev/null +++ b/packages/shiki/samples/yaml.sample @@ -0,0 +1,50 @@ +name: Check dist/ + +on: + push: + branches: + - main + paths-ignore: + - '**.md' + pull_request: + paths-ignore: + - '**.md' + +jobs: + check-dist: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set Node.js 16.x + uses: actions/setup-node@v3 + with: + node-version: 16.x + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Rebuild the dist/ directory + run: | + npm run build:compile + npm run build:package + + - name: Compare the expected and actual dist/ directories + run: | + if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then + echo "Detected uncommitted changes after build. See status below:" + git diff + exit 1 + fi + id: diff + + # If index.js was different than expected, upload the expected version as an artifact + - uses: actions/upload-artifact@v3 + if: ${{ failure() && steps.diff.conclusion == 'failure' }} + with: + name: dist + path: dist/ + +# From https://github.com/actions/add-to-project/blob/main/.github/workflows/check-dist.yml diff --git a/packages/shiki/samples/zsh.sample b/packages/shiki/samples/zsh.sample new file mode 100644 index 000000000..a82e1a6cf --- /dev/null +++ b/packages/shiki/samples/zsh.sample @@ -0,0 +1,20 @@ +#!/bin/zsh + +# Add commonly used folders to $PATH +export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" + +# Specify default editor. Possible values: vim, nano, ed etc. +export EDITOR=vim + +# File search functions +function f() { find . -iname "*$1*" ${@:2} } +function r() { grep "$1" ${@:2} -R . } + +# Create a folder and move into it in one command +function mkcd() { mkdir -p "$@" && cd "$_"; } + +# Example aliases +alias cppcompile='c++ -std=c++11 -stdlib=libc++' +alias g='git' + +# From https://sourabhbajaj.com/mac-setup/iTerm/zsh.html From f632880d60108be9ee0b30bf9e7dc414460a169a Mon Sep 17 00:00:00 2001 From: Kevin Batdorf Date: Wed, 16 Aug 2023 00:31:59 -0400 Subject: [PATCH 2/2] Fix marko comment --- packages/shiki/samples/marko.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shiki/samples/marko.sample b/packages/shiki/samples/marko.sample index f006f2ae1..e4ce98a25 100644 --- a/packages/shiki/samples/marko.sample +++ b/packages/shiki/samples/marko.sample @@ -10,4 +10,4 @@ -# from https://markojs.com/docs/core-tags/ +