Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,7 @@ $RECYCLE.BIN/
.DS_Store

*.exe
*.html
*.html

output/
packages/
Binary file added .paket/paket.bootstrapper.exe
Binary file not shown.
38 changes: 38 additions & 0 deletions .paket/paket.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Enable the restore command to run before builds -->
<RestorePackages Condition=" '$(RestorePackages)' == '' ">true</RestorePackages>
<!-- Download Paket.exe if it does not already exist -->
<DownloadPaket Condition=" '$(DownloadPaket)' == '' ">true</DownloadPaket>
<PaketToolsPath>$(MSBuildThisFileDirectory)</PaketToolsPath>
<PaketRootPath>$(MSBuildThisFileDirectory)..\</PaketRootPath>
</PropertyGroup>
<PropertyGroup>
<!-- Paket command -->
<PaketExePath Condition=" '$(PaketExePath)' == '' ">$(PaketToolsPath)paket.exe</PaketExePath>
<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' ">$(PaketToolsPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
<PaketCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketExePath)"</PaketCommand>
<PaketCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(PaketExePath)</PaketCommand>
<PaketBootStrapperCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>
<PaketBootStrapperCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(PaketBootStrapperExePath)</PaketBootStrapperCommand>
<!-- Commands -->
<PaketReferences Condition="!Exists('$(MSBuildProjectFullPath).paket.references')">$(MSBuildProjectDirectory)\paket.references</PaketReferences>
<PaketReferences Condition="Exists('$(MSBuildProjectFullPath).paket.references')">$(MSBuildProjectFullPath).paket.references</PaketReferences>
<RestoreCommand>$(PaketCommand) restore --references-files "$(PaketReferences)"</RestoreCommand>
<DownloadPaketCommand>$(PaketBootStrapperCommand)</DownloadPaketCommand>
<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">RestorePackages; $(BuildDependsOn);</BuildDependsOn>
</PropertyGroup>
<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate paket.exe -->
<Error Condition="'$(DownloadPaket)' != 'true' AND !Exists('$(PaketExePath)')" Text="Unable to locate '$(PaketExePath)'" />
<MsBuild Targets="DownloadPaket" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadPaket=$(DownloadPaket)" />
</Target>
<Target Name="DownloadPaket">
<Exec Command="$(DownloadPaketCommand)" Condition=" '$(DownloadPaket)' == 'true' AND !Exists('$(PaketExePath)')" />
</Target>
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(RestoreCommand)" WorkingDirectory="$(PaketRootPath)" Condition="Exists('$(PaketReferences)')" />
</Target>
</Project>
6 changes: 5 additions & 1 deletion LSystem/2-First-L-System.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ let processTurtle turtle program =
// 'B' -> "-A+B+A-"

let processLsystem iterations =
let rec proc iter (current: string) =
let rec proc iter (current: string) =
// Implement this
current
proc 0 "A"

// Verify it works with this :D
let test1 = processLsystem 1 = "+B-A-B+"
let test2 = processLsystem 2 = "+-A+B+A--+B-A-B+--A+B+A-+"

Expand All @@ -76,8 +78,10 @@ let defaultAngle = 60.0
// - turns -60 degrees

let convertToTurtle (lSystemString: string) =
// The values below are just so that this file compiles, complete a valid implemntation of this function
[DrawForward(defaultLength);Turn(defaultAngle)]

// Verify that the function convertToTurtle works as expected
let test3 =
let commands = processLsystem 1 |>convertToTurtle
commands =
Expand Down
8 changes: 6 additions & 2 deletions LSystem/3-Generalized-L-system.fsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

module Domain

type Point = { x : int; y : int }

type Color = { r:byte; g:byte; b:byte; }
Expand Down Expand Up @@ -168,4 +169,7 @@ let dragon = {
| '+' -> Some <| [Turn 90.0]
| '-' -> Some <| [Turn -90.0]
| _ -> None
}
}

// a default turtle location
let turtle = { x = 0.0; y = 0.0; angle = 0.0; c = red }
7 changes: 6 additions & 1 deletion LSystem/4.Ferns.fsx → LSystem/4-Ferns.fsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// woo ferns!
module Domain
// woo ferns!

type Point = { x : int; y : int }

Expand Down Expand Up @@ -113,4 +114,8 @@ let ferns = {
}


// a default turtle location
let turtle = { x = 0.0; y = 0.0; angle = 0.0; c = red }



2 changes: 1 addition & 1 deletion LSystem/LSystem_Fs.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<None Include="1-GettingStarted.fsx" />
<None Include="2-First-L-System.fsx" />
<None Include="3-Generalized-L-system.fsx" />
<None Include="4.Ferns.fsx" />
<None Include="4-Ferns.fsx" />
<None Include="SDL.fsx" />
<None Include="svg.fsx" />
</ItemGroup>
Expand Down
7 changes: 6 additions & 1 deletion LSystem/SDL.fsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#r @"..\Lib\SDL2FS.dll"
#load "1-GettingStarted.fsx"

// TODO: We will be changing this to load the other
// fsx files as the workshop progresses.
#load "1-GettingStarted.fsx"


open System
open Domain
Expand Down Expand Up @@ -89,3 +93,4 @@ let add lines = agent.Post <| Add lines
// draw some crap to the screen
randomPOOP 20
|> replace

2 changes: 2 additions & 0 deletions LSystem/svg.fsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// TODO: We will be changing this to load the other
// fsx files as the workshop progresses.
#load "1-GettingStarted.fsx"

open System
Expand Down
14 changes: 14 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@echo off
cls

.paket\paket.bootstrapper.exe
if errorlevel 1 (
exit /b %errorlevel%
)

.paket\paket.exe restore -v
if errorlevel 1 (
exit /b %errorlevel%
)

packages\FAKE\tools\FAKE.exe build.fsx %*
137 changes: 137 additions & 0 deletions build.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#I @"packages/FsReveal/fsreveal/"
#I @"packages/FAKE/tools/"
#I @"packages/Suave/lib/net40"

#r "FakeLib.dll"
#r "Suave.dll"

#load "fsreveal.fsx"

// Git configuration (used for publishing documentation in gh-pages branch)
// The profile where the project is posted
let gitOwner = "myGitUser"
let gitHome = "https://github.com/" + gitOwner
// The name of the project on GitHub
let gitProjectName = "MyProject"

open FsReveal
open Fake
open Fake.Git
open System.IO
open System.Diagnostics
open Suave
open Suave.Web
open Suave.Http
open Suave.Http.Files

let outDir = __SOURCE_DIRECTORY__ @@ "output"
let slidesDir = __SOURCE_DIRECTORY__ @@ "slides"

Target "Clean" (fun _ ->
CleanDirs [outDir]
)

let fsiEvaluator =
let evaluator = FSharp.Literate.FsiEvaluator()
evaluator.EvaluationFailed.Add(fun err ->
traceImportant <| sprintf "Evaluating F# snippet failed:\n%s\nThe snippet evaluated:\n%s" err.StdErr err.Text )
evaluator

let copyStylesheet() =
try
CopyFile (outDir @@ "css" @@ "custom.css") (slidesDir @@ "custom.css")
with
| exn -> traceImportant <| sprintf "Could not copy stylesheet: %s" exn.Message

let copyPics() =
try
CopyDir (outDir @@ "images") (slidesDir @@ "images") (fun f -> true)
with
| exn -> traceImportant <| sprintf "Could not copy picture: %s" exn.Message

let generateFor (file:FileInfo) =
try
copyPics()
let rec tryGenerate trials =
try
FsReveal.GenerateFromFile(file.FullName, outDir, fsiEvaluator = fsiEvaluator)
with
| exn when trials > 0 -> tryGenerate (trials - 1)
| exn ->
traceImportant <| sprintf "Could not generate slides for: %s" file.FullName
traceImportant exn.Message

tryGenerate 3

copyStylesheet()
with
| :? FileNotFoundException as exn ->
traceImportant <| sprintf "Could not copy file: %s" exn.FileName

let handleWatcherEvents (e:FileSystemEventArgs) =
let fi = fileInfo e.FullPath
traceImportant <| sprintf "%s was changed." fi.Name
match fi.Attributes.HasFlag FileAttributes.Hidden || fi.Attributes.HasFlag FileAttributes.Directory with
| true -> ()
| _ -> generateFor fi

let startWebServer () =
let serverConfig =
{ defaultConfig with
homeFolder = Some (FullName outDir)
}
let app =
Writers.setHeader "Cache-Control" "no-cache, no-store, must-revalidate"
>>= Writers.setHeader "Pragma" "no-cache"
>>= Writers.setHeader "Expires" "0"
>>= browseHome
startWebServerAsync serverConfig app |> snd |> Async.Start
Process.Start "http://localhost:8083/index.html" |> ignore

Target "GenerateSlides" (fun _ ->
!! (slidesDir @@ "*.md")
++ (slidesDir @@ "*.fsx")
|> Seq.map fileInfo
|> Seq.iter generateFor
)

Target "KeepRunning" (fun _ ->
use watcher = new FileSystemWatcher(FullName slidesDir,"*.*")
watcher.EnableRaisingEvents <- true
watcher.IncludeSubdirectories <- true
watcher.Changed.Add(handleWatcherEvents)
watcher.Created.Add(handleWatcherEvents)
watcher.Renamed.Add(handleWatcherEvents)

startWebServer ()

traceImportant "Waiting for slide edits. Press any key to stop."

System.Console.ReadKey() |> ignore

watcher.EnableRaisingEvents <- false
watcher.Dispose()
)

Target "ReleaseSlides" (fun _ ->
if gitOwner = "myGitUser" || gitProjectName = "MyProject" then
failwith "You need to specify the gitOwner and gitProjectName in build.fsx"
let tempDocsDir = __SOURCE_DIRECTORY__ @@ "temp/gh-pages"
CleanDir tempDocsDir
Repository.cloneSingleBranch "" (gitHome + "/" + gitProjectName + ".git") "gh-pages" tempDocsDir

fullclean tempDocsDir
CopyRecursive outDir tempDocsDir true |> tracefn "%A"
StageAll tempDocsDir
Git.Commit.Commit tempDocsDir "Update generated slides"
Branches.push tempDocsDir
)

"Clean"
==> "GenerateSlides"
==> "KeepRunning"

"GenerateSlides"
==> "ReleaseSlides"

RunTargetOrDefault "KeepRunning"
33 changes: 33 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
if test "$OS" = "Windows_NT"
then
# use .Net

.paket/paket.bootstrapper.exe
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi

.paket/paket.exe restore -v
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi

packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
else
# use mono
mono .paket/paket.bootstrapper.exe
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi

mono .paket/paket.exe restore -v
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi
mono packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
fi
5 changes: 5 additions & 0 deletions paket.dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source https://nuget.org/api/v2

nuget FsReveal
nuget FAKE
nuget Suave
17 changes: 17 additions & 0 deletions paket.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
NUGET
remote: https://nuget.org/api/v2
specs:
FAKE (3.27.2)
FSharp.Compiler.Service (0.0.87)
FSharp.Core (3.1.2.1)
FSharp.Formatting (2.8.0)
FSharp.Compiler.Service (>= 0.0.86)
FSharpVSPowerTools.Core (>= 1.7.0)
FSharpVSPowerTools.Core (1.7.0)
FSharp.Compiler.Service (>= 0.0.87)
FsPickler (1.0.16)
FsReveal (0.7.2)
FSharp.Formatting (>= 2.7.5)
Suave (0.26.1)
FSharp.Core (>= 3.1.2.1)
FsPickler (>= 1.0.7)
32 changes: 32 additions & 0 deletions slides/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.reveal section img {
border: none;
margin: 0px;
}

table.pre, pre.fssnip, pre{
background-color: #fff;
color:#4C1485;
border: none;
}

span.i {
color:#258585;
}

span.f {
color:#852525;
}

span.s {
color:#258525;
}

.reveal h1 {
margin: 0 0 20px 0;
color: #4C1485;
background: rgba(253, 246, 227, 0.65);
}

.reveal blockquote {
background: rgba(253, 246, 227, 0.65);
}
Binary file added slides/images/bla.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/images/dragon.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/images/fk.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/images/herding-cats.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/images/roundcrisis.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/images/wd-logo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading