Skip to content

Commit

Permalink
add some examples; move some examples
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Jun 30, 2021
1 parent 683d62b commit 4ad408a
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 8 deletions.
6 changes: 6 additions & 0 deletions crystal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@

## Ideas for slides


What are these ? and ! mean at the end of the functions and sometimes end of various statements?
What does !something.empty? and why don't you write ¡empty! anyway? That would at least make sense...


The need to recompile the whole thing before I run it and the fact that compilation is slow makes life of a (web) developer hard.
The Jinja Template system of Johannes that does not need to be compiled makes at least the HTML development much faster.

Expand All @@ -39,6 +44,7 @@ What is "flag?" ? I saw it in the source code of Kemal, but I don't see it defi

GitHub Actions configurators: https://crystal-lang.github.io/install-crystal/configurator.html


Yak Shaving

https://forum.crystal-lang.org/ has around 500 users.
Expand Down
10 changes: 5 additions & 5 deletions crystal/directories.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
{id: list-directory}
{i: Dir}

![](examples/list_dir.cr)
![](examples/filesystem/list_dir.cr)

## List directory tree
{id: directory-tree}
{i: Dir}
{i: glob}
![](examples/traverse_tree.cr)
![](examples/filesystem/traverse_tree.cr)

## Get Current workding directory (cwd, pwd)
{id: current-working-directory}

![](examples/cwd.cr)
![](examples/filesystem/cwd.cr)

## Temporary directory
{id: temporary-directory}
Expand All @@ -27,9 +27,9 @@
{i: rm_rf}
{i: cd}

![](examples/tempdir.cr)
![](examples/filesystem/tempdir.cr)

## Tempdir function
{id: tempdir}

![](examples/tempdir_function.cr)
![](examples/filesystem/tempdir_function.cr)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions crystal/examples/regexes/gsub.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
puts "The cat is here".gsub("cat", "dog")
puts "The cat is here".gsub("cat") {"dog"}

puts "The cat is here".gsub("cat") {|match| match.reverse }
puts "The cat is here".gsub(/c../) {|match| match.reverse }
3 changes: 3 additions & 0 deletions crystal/examples/strings/split_characters.cr
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
text = "black cat"
puts text.split("")
puts text.split("").sort


puts text.chars
1 change: 1 addition & 0 deletions crystal/examples/strings/split_characters.out
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
["b", "l", "a", "c", "k", " ", "c", "a", "t"]
[" ", "a", "a", "b", "c", "c", "k", "l", "t"]
['b', 'l', 'a', 'c', 'k', ' ', 'c', 'a', 't']
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "yaml"

data = File.open("examples/crystal.yml") do |file|
data = File.open("examples/yaml/crystal.yml") do |file|
YAML.parse(file)
end
puts data
Expand Down
7 changes: 7 additions & 0 deletions crystal/other.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,10 @@ require "some_name" # Find it somewhere (standard library, src directory

![](examples/int64_zero.cr)

## Resources
{id: resources}

* [Crystal Programming](https://www.youtube.com/watch?v=DxFP-Wjqtsc) by Derek Banas from 2018
* [LuckyCast](https://luckycasts.com/)


5 changes: 5 additions & 0 deletions crystal/regexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@
![](examples/regexes/substitute.cr)
![](examples/regexes/substitute.out)

## gsub
{id: gsub}

![](examples/regexes/gsub.cr)

2 changes: 2 additions & 0 deletions crystal/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@

## Split characters
{id: split-characters}
{i: split}
{i: chars}

![](examples/strings/split_characters.cr)
![](examples/strings/split_characters.out)
Expand Down
4 changes: 2 additions & 2 deletions crystal/yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

* [YAML](https://crystal-lang.org/api/YAML.html)

![](examples/crystal.yml)
![](examples/use_yaml.cr)
![](examples/yaml/crystal.yml)
![](examples/yaml/use_yaml.cr)



0 comments on commit 4ad408a

Please sign in to comment.