From a0f55a3cfebb4e8ce83033f6756df05fa93615d8 Mon Sep 17 00:00:00 2001 From: Sami Pussinen Date: Thu, 10 Dec 2015 08:47:18 +0200 Subject: [PATCH 01/11] Fixed a minor typo in the chaining page. --- chapters/classes_and_objects/chaining.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chapters/classes_and_objects/chaining.md b/chapters/classes_and_objects/chaining.md index be19212..d8d099e 100644 --- a/chapters/classes_and_objects/chaining.md +++ b/chapters/classes_and_objects/chaining.md @@ -66,9 +66,9 @@ class TeaCup cream: false addChainedAttributeAccessor(this, 'properties', attr) for attr of @properties -earlgrey = new TeaCup().size('small').type('Earl Grey').sugar('false') +earlgrey = new TeaCup().size('small').type('Earl Grey').sugar(false) -earlgrey.properties # => { size: 'small', type: 'Earl Grey', sugar: false } +earlgrey.properties # => { size: 'small', type: 'Earl Grey', sugar: false, cream: false } earlgrey.sugar true From 7fa9559f4af96f68e00d956c60267d6fa49b5dac Mon Sep 17 00:00:00 2001 From: Sami Pussinen Date: Thu, 10 Dec 2015 08:48:17 +0200 Subject: [PATCH 02/11] Added myself to the authors page. --- authors.md | 1 + 1 file changed, 1 insertion(+) diff --git a/authors.md b/authors.md index 3b3b236..3d152cd 100644 --- a/authors.md +++ b/authors.md @@ -34,6 +34,7 @@ The following people are totally rad and awesome because they have contributed r * Mike Moore *mike@blowmage.com* * Peter Hellberg *peter@c7.se* * Jamie Gaskins *jgaskins@gmail.com* +* Sami Pussinen *me@samipussinen.com* * ...You! What are you waiting for? Check out the [contributing]({{ site.baseurl }}/contributing) section and get cracking! # Designers From 202bdfdd61c26f34120eae12699b25532fcd0f59 Mon Sep 17 00:00:00 2001 From: Data-Meister Date: Thu, 21 Jan 2016 18:01:17 +0000 Subject: [PATCH 03/11] Add a recipe to count occurrences of a given string within a message --- chapters/strings/finding-substrings.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/chapters/strings/finding-substrings.md b/chapters/strings/finding-substrings.md index a33af8c..5a070d2 100644 --- a/chapters/strings/finding-substrings.md +++ b/chapters/strings/finding-substrings.md @@ -24,8 +24,14 @@ message.indexOf "This", 5 message.lastIndexOf "This" # => 49 -{% endhighlight %} -## Discussion +# Count occurrences of a given string + + substrCount = (str, subStr) -> + re = new RegExp( subStr ,"g" ) + ( str.match(re) or [] ).length -Still need recipe to count occurrences of a given string within a message. +substrCount message, " a " +# => 3 + +{% endhighlight %} From d6da838694e611a73822cdaf667ec5b9530260f3 Mon Sep 17 00:00:00 2001 From: Data-Meister Date: Thu, 28 Jan 2016 17:56:24 +0000 Subject: [PATCH 04/11] Faster, simpler way to count occurrences of a given string --- chapters/strings/finding-substrings.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/chapters/strings/finding-substrings.md b/chapters/strings/finding-substrings.md index 5a070d2..ee81e89 100644 --- a/chapters/strings/finding-substrings.md +++ b/chapters/strings/finding-substrings.md @@ -24,14 +24,8 @@ message.indexOf "This", 5 message.lastIndexOf "This" # => 49 - # Count occurrences of a given string - - substrCount = (str, subStr) -> - re = new RegExp( subStr ,"g" ) - ( str.match(re) or [] ).length - -substrCount message, " a " +message.split(" a ").length - 1 # => 3 {% endhighlight %} From fdb756a70280aad027f8213677d067282eb6007c Mon Sep 17 00:00:00 2001 From: Data-Meister Date: Thu, 28 Jan 2016 21:52:23 +0000 Subject: [PATCH 05/11] Add new chapter: replacing sub-strings --- chapters/strings/replacing-sub-strings.md | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 chapters/strings/replacing-sub-strings.md diff --git a/chapters/strings/replacing-sub-strings.md b/chapters/strings/replacing-sub-strings.md new file mode 100644 index 0000000..add9945 --- /dev/null +++ b/chapters/strings/replacing-sub-strings.md @@ -0,0 +1,29 @@ +--- +layout: recipe +title: Replacing Sub-Strings Within a String +chapter: Strings +--- +## Problem + +You want to replace a sub-string with a new sub-string. + +## Solution + +Split the string using the sub-string you want to remove as a delimiter. Then re-join using the new sub-string as the delimiter. + +{% highlight coffeescript %} +"Orange is the new Black".split("Orange").join("Pink") +# => "Pink is the new Black" + +"I am so sad. I cannot believe how sad I am today!".split("sad").join("happy") +# => "I am so happy. I cannot believe how happy I am today!" + +"I am not a crook.".split("not ").join("") +# => "I am a crook." +{% endhighlight %} + +## Discussion + +You can also use regexes. If you're matching an exact string, this way is simpler and 10x faster. + +If you use regexes, remember that you must escape certain characters. From 9b10230f4b5c76486b201b90802fa0141e4001e3 Mon Sep 17 00:00:00 2001 From: tijwelch Date: Tue, 6 Sep 2016 06:12:18 -0500 Subject: [PATCH 06/11] Fix typo in syntax chapter --- chapters/syntax/code_reuse_on_client_and_server.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/syntax/code_reuse_on_client_and_server.md b/chapters/syntax/code_reuse_on_client_and_server.md index f7a1aca..92e706b 100644 --- a/chapters/syntax/code_reuse_on_client_and_server.md +++ b/chapters/syntax/code_reuse_on_client_and_server.md @@ -57,7 +57,7 @@ undefined {% endhighlight %} -In our web page, we can include our module using by including it as a script. +In our web page, we can include our module by including it as a script. {% highlight html %} From e3fbf9fa83336611571500c42361fb7b4194ef7f Mon Sep 17 00:00:00 2001 From: Mike Moore Date: Wed, 11 Jan 2017 09:09:34 -0700 Subject: [PATCH 07/11] Update development dependencies The versions of gems specified in the Gemfile.lock require ruby 1.9.3. Update them to the latest and greatest gems. --- Gemfile | 4 +- Gemfile.lock | 178 +++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 131 insertions(+), 51 deletions(-) diff --git a/Gemfile b/Gemfile index b4d66ba..b700031 100644 --- a/Gemfile +++ b/Gemfile @@ -4,6 +4,6 @@ group :development do gem "github-pages" gem "tzinfo-data" - gem "foreman", "~> 0.63" - gem "serve", "~> 1.5" + gem "foreman" + gem "serve" end diff --git a/Gemfile.lock b/Gemfile.lock index d8185b6..682c357 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,56 +2,125 @@ GEM remote: https://rubygems.org/ specs: RedCloth (4.2.9) - activesupport (3.2.14) + activesupport (3.2.22.5) i18n (~> 0.6, >= 0.6.4) multi_json (~> 1.0) - classifier (1.3.3) - fast-stemmer (>= 1.0.0) + addressable (2.4.0) + blankslate (2.1.2.4) + classifier-reborn (2.1.0) + fast-stemmer (~> 1.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) colorator (0.1) - commander (4.1.5) - highline (~> 1.6.11) - directory_watcher (1.4.1) - dotenv (0.8.0) + ethon (0.10.1) + ffi (>= 1.3.0) + execjs (2.7.0) + faraday (0.10.1) + multipart-post (>= 1.2, < 3) fast-stemmer (1.0.2) - foreman (0.63.0) - dotenv (>= 0.7) - thor (>= 0.13.6) - github-pages (1) + ffi (1.9.14) + foreman (0.82.0) + thor (~> 0.19.1) + gemoji (2.1.0) + github-pages (39) RedCloth (= 4.2.9) - jekyll (= 1.1.2) - kramdown (= 1.0.2) - liquid (= 2.5.1) - maruku (= 0.6.1) - rdiscount (= 1.6.8) - redcarpet (= 2.2.2) - highline (1.6.19) - i18n (0.6.5) - jekyll (1.1.2) - classifier (~> 1.3) + github-pages-health-check (~> 0.2) + jekyll (= 2.4.0) + jekyll-coffeescript (= 1.0.1) + jekyll-feed (= 0.3.1) + jekyll-mentions (= 0.2.1) + jekyll-redirect-from (= 0.8.0) + jekyll-sass-converter (= 1.3.0) + jekyll-sitemap (= 0.8.1) + jemoji (= 0.5.0) + kramdown (= 1.5.0) + liquid (= 2.6.2) + maruku (= 0.7.0) + mercenary (~> 0.3) + pygments.rb (= 0.6.3) + rdiscount (= 2.1.7) + redcarpet (= 3.3.2) + terminal-table (~> 1.4) + github-pages-health-check (0.3.2) + net-dns (~> 0.6) + public_suffix (~> 1.4) + typhoeus (~> 0.7) + html-pipeline (1.9.0) + activesupport (>= 2) + nokogiri (~> 1.4) + i18n (0.7.0) + jekyll (2.4.0) + classifier-reborn (~> 2.0) colorator (~> 0.1) - commander (~> 4.1.3) - directory_watcher (~> 1.4.1) - kramdown (~> 1.0.2) - liquid (~> 2.5.1) - maruku (~> 0.5) - pygments.rb (~> 0.5.0) - redcarpet (~> 2.2.2) - safe_yaml (~> 0.7.0) - kramdown (1.0.2) - liquid (2.5.1) - maruku (0.6.1) - syntax (>= 1.0.0) - multi_json (1.7.9) - posix-spawn (0.3.6) - pygments.rb (0.5.2) + jekyll-coffeescript (~> 1.0) + jekyll-gist (~> 1.0) + jekyll-paginate (~> 1.0) + jekyll-sass-converter (~> 1.0) + jekyll-watch (~> 1.1) + kramdown (~> 1.3) + liquid (~> 2.6.1) + mercenary (~> 0.3.3) + pygments.rb (~> 0.6.0) + redcarpet (~> 3.1) + safe_yaml (~> 1.0) + toml (~> 0.1.0) + jekyll-coffeescript (1.0.1) + coffee-script (~> 2.2) + jekyll-feed (0.3.1) + jekyll-gist (1.4.0) + octokit (~> 4.2) + jekyll-mentions (0.2.1) + html-pipeline (~> 1.9.0) + jekyll (~> 2.0) + jekyll-paginate (1.1.0) + jekyll-redirect-from (0.8.0) + jekyll (>= 2.0) + jekyll-sass-converter (1.3.0) + sass (~> 3.2) + jekyll-sitemap (0.8.1) + jekyll-watch (1.5.0) + listen (~> 3.0, < 3.1) + jemoji (0.5.0) + gemoji (~> 2.0) + html-pipeline (~> 1.9) + jekyll (>= 2.0) + kramdown (1.5.0) + liquid (2.6.2) + listen (3.0.8) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + maruku (0.7.0) + mercenary (0.3.6) + mini_portile2 (2.1.0) + multi_json (1.12.1) + multipart-post (2.0.0) + net-dns (0.8.0) + nokogiri (1.7.0.1) + mini_portile2 (~> 2.1.0) + octokit (4.6.2) + sawyer (~> 0.8.0, >= 0.5.3) + parslet (1.5.0) + blankslate (~> 2.0) + posix-spawn (0.3.12) + public_suffix (1.5.3) + pygments.rb (0.6.3) posix-spawn (~> 0.3.6) - yajl-ruby (~> 1.1.0) - rack (1.5.2) - rack-test (0.6.2) + yajl-ruby (~> 1.2.0) + rack (1.5.5) + rack-test (0.6.3) rack (>= 1.0) - rdiscount (1.6.8) - redcarpet (2.2.2) - safe_yaml (0.7.1) + rb-fsevent (0.9.8) + rb-inotify (0.9.7) + ffi (>= 0.5.0) + rdiscount (2.1.7) + redcarpet (3.3.2) + safe_yaml (1.0.4) + sass (3.4.23) + sawyer (0.8.1) + addressable (>= 2.3.5, < 2.6) + faraday (~> 0.8, < 1.0) serve (1.5.2) activesupport (~> 3.2.12) i18n @@ -59,19 +128,30 @@ GEM rack-test (~> 0.6.2) tilt (~> 1.3.3) tzinfo - syntax (1.0.0) - thor (0.18.1) + terminal-table (1.7.3) + unicode-display_width (~> 1.1.1) + thor (0.19.4) + thread_safe (0.3.5) tilt (1.3.7) - tzinfo (1.0.1) - tzinfo-data (1.2013.4) + toml (0.1.2) + parslet (~> 1.5.0) + typhoeus (0.8.0) + ethon (>= 0.8.0) + tzinfo (1.2.2) + thread_safe (~> 0.1) + tzinfo-data (1.2016.10) tzinfo (>= 1.0.0) - yajl-ruby (1.1.0) + unicode-display_width (1.1.2) + yajl-ruby (1.2.1) PLATFORMS ruby DEPENDENCIES - foreman (~> 0.63) + foreman github-pages - serve (~> 1.5) + serve tzinfo-data + +BUNDLED WITH + 1.13.7 From 482af694b205f9213c2c89c1497f9989cd986aaa Mon Sep 17 00:00:00 2001 From: Mike Moore Date: Wed, 11 Jan 2017 09:11:05 -0700 Subject: [PATCH 08/11] Use new Jekyll configuration for code highlighting This removes the following warning: Deprecation: The 'pygments' configuration option has been renamed to 'highlighter'. Please update your config file accordingly. The allowed values are 'rouge', 'pygments' or null. --- _config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index 6214b0c..20fa234 100644 --- a/_config.yml +++ b/_config.yml @@ -1,6 +1,6 @@ baseurl: '' safe: true -pygments: true +highlighter: pygments lsi: false markdown: redcarpet exclude: From 50515c7deeefe5ac55d390740d0961f953ac9d7f Mon Sep 17 00:00:00 2001 From: Mike Moore Date: Wed, 11 Jan 2017 09:30:37 -0700 Subject: [PATCH 09/11] Replace page data with site data --- _data/chapters.yml | 16 ++++++++++++++++ _layouts/chapter.html | 22 +--------------------- _layouts/default.html | 22 +--------------------- _layouts/recipe.html | 22 +--------------------- chapters/index.html | 20 ++------------------ 5 files changed, 21 insertions(+), 81 deletions(-) create mode 100644 _data/chapters.yml diff --git a/_data/chapters.yml b/_data/chapters.yml new file mode 100644 index 0000000..9c47918 --- /dev/null +++ b/_data/chapters.yml @@ -0,0 +1,16 @@ +--- +- Syntax +- Classes and Objects +- Strings +- Arrays +- Dates and Times +- Math +- Functions +- Metaprogramming +- jQuery +- Ajax +- Regular Expressions +- Networking +- Design Patterns +- Databases +- Testing diff --git a/_layouts/chapter.html b/_layouts/chapter.html index 3023ec9..3daeeed 100644 --- a/_layouts/chapter.html +++ b/_layouts/chapter.html @@ -1,22 +1,3 @@ ---- -chapters: -- Syntax -- Classes and Objects -- Strings -- Arrays -- Dates and Times -- Math -- Functions -- Metaprogramming -- jQuery -- Ajax -- Regular Expressions -- Networking -- Design Patterns -- Databases -- Testing ---- - @@ -72,7 +53,7 @@
ó