Skip to content

Commit

Permalink
feat: add additional sample code
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBatdorf committed Aug 16, 2023
1 parent 1875936 commit 11b6fdf
Show file tree
Hide file tree
Showing 103 changed files with 3,362 additions and 159 deletions.
13 changes: 0 additions & 13 deletions packages/shiki/samples/Marko.sample

This file was deleted.

29 changes: 19 additions & 10 deletions packages/shiki/samples/ada.sample
Original file line number Diff line number Diff line change
@@ -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/
-- From https://github.com/kylelk/ada-examples/blob/master/fizz_buzz.adb
39 changes: 39 additions & 0 deletions packages/shiki/samples/apache.sample
Original file line number Diff line number Diff line change
@@ -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
<Directory />
AllowOverride None
Require all denied
</Directory>

# Direcrory and files to be served
DirectoryIndex index.html
DocumentRoot "${GITPOD_REPO_ROOT}/www"
<Directory "${GITPOD_REPO_ROOT}/www">
Require all granted
</Directory>

# Include conf installed via apt-get
IncludeOptional /etc/apache2/conf-enabled/*.conf

# https://github.com/gitpod-io/apache-example/blob/master/apache/apache.conf
22 changes: 18 additions & 4 deletions packages/shiki/samples/apex.sample
Original file line number Diff line number Diff line change
@@ -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
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
37 changes: 37 additions & 0 deletions packages/shiki/samples/apl.sample
Original file line number Diff line number Diff line change
@@ -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
38 changes: 25 additions & 13 deletions packages/shiki/samples/astro.sample
Original file line number Diff line number Diff line change
@@ -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;
---
<!-- HTML comments supported! -->
{/* JS comment syntax is also valid! */}

<!DOCTYPE html>
<html>
<head>
<!-- This... is an Astro comment. -->
<title>Hello, {name}</title>
</head>
<body>
<main>
<h1>Hello, {name}</h1>
</main>
</body>
</html>
<Banner />
<h1>Hello, world!</h1>

<!-- Use props and other variables from the component script: -->
<p>{title}</p>

<!-- Include other UI framework components with a `client:` directive to hydrate: -->
<ReactPokemonComponent client:visible />

<!-- Mix HTML with JavaScript expressions, similar to JSX: -->
<ul>
{myFavoritePokemon.map((data) => <li>{data.name}</li>)}
</ul>

<!-- Use a template directive to build class names from multiple strings or even objects! -->
<p class:list={["add", "dynamic", {classNames: true}]} />

<!-- From https://docs.astro.build/en/core-concepts/astro-components/ -->
28 changes: 28 additions & 0 deletions packages/shiki/samples/bash.sample
Original file line number Diff line number Diff line change
@@ -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
34 changes: 20 additions & 14 deletions packages/shiki/samples/bat.sample
Original file line number Diff line number Diff line change
@@ -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
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
28 changes: 28 additions & 0 deletions packages/shiki/samples/bibtex.sample
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions packages/shiki/samples/clj.sample
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 11b6fdf

Please sign in to comment.