diff --git a/authors-guide.md b/authors-guide.md index f5de511..54c1b26 100644 --- a/authors-guide.md +++ b/authors-guide.md @@ -163,7 +163,7 @@ If the answer to either question is no, you might have some code that is a "clev ## What If My Recipe is Inefficient/Too Big/Too Slow? -If it solves a problem to which the alternative is to _not_ solve the problem, share it. Let the reader decide if they want to use it. Sometimes we want tight efficient code, other times we want a robust featureset. If the code has abysmal performance characteristics, be sure to warn the reader in the Discussion. +If it solves a problem to which the alternative is to _not_ solve the problem, share it. Let the reader decide if they want to use it. Sometimes we want tight efficient code, other times we want a robust feature set. If the code has abysmal performance characteristics, be sure to warn the reader in the Discussion. ## Can I Edit An Existing Recipe? diff --git a/chapters/ajax/ajax_request_without_jquery.md b/chapters/ajax/ajax_request_without_jquery.md index d95713c..917cdfa 100644 --- a/chapters/ajax/ajax_request_without_jquery.md +++ b/chapters/ajax/ajax_request_without_jquery.md @@ -46,7 +46,7 @@ loadDataFromServer = -> req = new XMLHttpRequest() req.addEventListener 'readystatechange', -> - if req.readyState is 4 # ReadyState Compelte + if req.readyState is 4 # ReadyState Complete successResultCodes = [200, 304] if req.status in successResultCodes data = eval '(' + req.responseText + ')' @@ -69,13 +69,13 @@ We define our loadDataFromServer callback beginning on line 2. We create a XMLHttpRequest request object (line 3) and add a *readystatechange* event handler. This fires whenever the request's readyState changes. -In the event handler we check to see if the readyState = 4, indicating the request has completed. Then, we check the request status value. Both 200 or 304 represent a succsessful request. Anything else represents an error condition. +In the event handler we check to see if the readyState = 4, indicating the request has completed. Then, we check the request status value. Both 200 or 304 represent a successful request. Anything else represents an error condition. If the request was indeed successful, we eval the JSON returned from the server and assign it to a data variable. At this point, we can use the returned data in any way we need to. The last thing we need to do is actually make our request. -Line 13 opens a 'GET' request to retreive the data.json file. +Line 13 opens a 'GET' request to retrieve the data.json file. Line 14 sends our request to the server. diff --git a/chapters/arrays/filtering-arrays.md b/chapters/arrays/filtering-arrays.md index 1d2c7e3..2476aea 100644 --- a/chapters/arrays/filtering-arrays.md +++ b/chapters/arrays/filtering-arrays.md @@ -18,7 +18,7 @@ array.filter (x) -> x > 5 # => [6,7,8,9,10] {% endhighlight %} -In pre-EC5 implementations, extend the Array prototype to add a filter function which will take a callback and perform a comprension over itself, collecting all elements for which the callback is true. Be sure to check if the function is already implemented before overwriting it: +In pre-EC5 implementations, extend the Array prototype to add a filter function which will take a callback and perform a comprehension over itself, collecting all elements for which the callback is true. Be sure to check if the function is already implemented before overwriting it: {% highlight coffeescript %} # Extending Array's prototype diff --git a/chapters/arrays/reducing-arrays.md b/chapters/arrays/reducing-arrays.md index c790967..37d5e98 100644 --- a/chapters/arrays/reducing-arrays.md +++ b/chapters/arrays/reducing-arrays.md @@ -9,7 +9,7 @@ You have an array of objects and want to reduce them to a value, similar to Ruby ## Solution -You can simply use Array's `reduce()` and `reduceRight()` methods along with an anonoymous function, keeping the code clean and readable. The reduction may be something simple such as using the `+` operator with numbers or strings. +You can simply use Array's `reduce()` and `reduceRight()` methods along with an anonymous function, keeping the code clean and readable. The reduction may be something simple such as using the `+` operator with numbers or strings. {% highlight coffeescript %} [1,2,3,4].reduce (x,y) -> x + y diff --git a/chapters/arrays/testing-every-element.md b/chapters/arrays/testing-every-element.md index 12b78a1..773a107 100644 --- a/chapters/arrays/testing-every-element.md +++ b/chapters/arrays/testing-every-element.md @@ -18,7 +18,7 @@ evens.every (x)-> x % 2 == 0 # => true {% endhighlight %} -Array.every was addded to Mozilla's Javascript 1.6 and made standard with EcmaScript 5. If you to support browsers that do not implement EC5 then check out [`_.all` from underscore.js][underscore]. +Array.every was added to Mozilla's Javascript 1.6 and made standard with ECMAScript 5. If you to support browsers that do not implement EC5 then check out [`_.all` from underscore.js][underscore]. For a real world example, pretend you have a multiple select list that looks like: diff --git a/chapters/arrays/where-for-arrays-of-objects.md b/chapters/arrays/where-for-arrays-of-objects.md index 51eba6d..99cb556 100644 --- a/chapters/arrays/where-for-arrays-of-objects.md +++ b/chapters/arrays/where-for-arrays-of-objects.md @@ -77,4 +77,4 @@ cats.where name:"bubbles", (a, b) -> "#{ a }".toLowerCase() is "#{ b }".toLowerC # now it's case insensitive {% endhighlight %} -it's more a method to deal with collection and it could be rename as "find" but popular libraires like underscore or lodash name it "where". +it's more a method to deal with collection and it could be rename as "find" but popular libraries like underscore or lodash name it "where". diff --git a/chapters/dates_and_times/date-of-thanksgiving.md b/chapters/dates_and_times/date-of-thanksgiving.md index 5438244..a26b36c 100644 --- a/chapters/dates_and_times/date-of-thanksgiving.md +++ b/chapters/dates_and_times/date-of-thanksgiving.md @@ -5,7 +5,7 @@ chapter: Dates and Times --- ## Problem -You need to calculate when is Thanksgivinig in given year. +You need to calculate when Thanksgiving is in a given year. ## Solution diff --git a/chapters/dates_and_times/days-between-two-dates.md b/chapters/dates_and_times/days-between-two-dates.md index 0f5c789..11f6894 100644 --- a/chapters/dates_and_times/days-between-two-dates.md +++ b/chapters/dates_and_times/days-between-two-dates.md @@ -9,7 +9,7 @@ You need to find how much seconds minutes, hours, days, months or years has pass ## Solution -Use JavaScript's Date function getTime(). Which provides how much time in miliseconds has passed since 01/01/1970: +Use JavaScript's Date function getTime(). Which provides how much time in milliseconds has passed since 01/01/1970: {% highlight coffeescript %} DAY = 1000 * 60 * 60 * 24 @@ -22,12 +22,12 @@ days_passed = Math.round((d2.getTime() - d1.getTime()) / DAY) ## Discussion -Using miliseconds makes the life easier to avoid overflow mistakes with Dates. So we first calculate how much miliseconds has a day. -Then, given two distincit dates, just get the diference in miliseconds betwen two dates and then divide by how much miliseconds has a +Using milliseconds makes the life easier to avoid overflow mistakes with Dates. So we first calculate how much milliseconds has a day. +Then, given two distinct dates, just get the difference in milliseconds between two dates and then divide by how much milliseconds has a day. It will get you the days between two distinct dates. -If you'd like to calculate the hours between two dates objects you can do that just by dividing the diference in miliseconds by the -convertion of miliseconds to hours. The same goes to minutes and seconds. +If you'd like to calculate the hours between two date objects, you can do that just by dividing the difference in milliseconds by the +conversion of milliseconds to hours. The same goes for minutes and seconds. {% highlight coffeescript %} HOUR = 1000 * 60 * 60 diff --git a/chapters/dates_and_times/moon-phase-for-date.md b/chapters/dates_and_times/moon-phase-for-date.md index 2c63e61..c97d444 100644 --- a/chapters/dates_and_times/moon-phase-for-date.md +++ b/chapters/dates_and_times/moon-phase-for-date.md @@ -9,7 +9,7 @@ You want to find the current phase of the moon. ## Solution -The following code provides a method to calcualate the phase of the moon for a given date. +The following code provides a method to calculate the phase of the moon for a given date. {% highlight coffeescript %} # moonPhase.coffee diff --git a/chapters/design_patterns/adapter.md b/chapters/design_patterns/adapter.md index 7e2af73..bcf4544 100644 --- a/chapters/design_patterns/adapter.md +++ b/chapters/design_patterns/adapter.md @@ -19,7 +19,7 @@ In such a situation, the [Adapter Pattern](//en.wikipedia.org/wiki/Adapter_patte class AwesomeGrid constructor: (@datasource)-> @sort_order = 'ASC' - @sorter = new NullSorter # in this place we use NullObject pattern (another usefull pattern) + @sorter = new NullSorter # in this place we use NullObject pattern (another useful pattern) setCustomSorter: (@customSorter) -> @sorter = customSorter sort: () -> diff --git a/chapters/design_patterns/observer.md b/chapters/design_patterns/observer.md index f796b78..48047bb 100644 --- a/chapters/design_patterns/observer.md +++ b/chapters/design_patterns/observer.md @@ -42,6 +42,6 @@ postOffice.notifyNewItemReleased "Mens Health" ## Discussion Here you have an observer object (PostOffice) and observable objects (MagazineSubscriber, NewspaperSubscriber). -To be notified about an event of publishing new periodical observable object should make subscribtion on PostOffice. -Every of subscribed objects is stored internaly in the PostOffice array of subscribtions. +To be notified about an event of publishing new periodical observable object should make subscription on PostOffice. +Every of subscribed objects is stored internally in the PostOffice array of subscriptions. Every subscriber is notified on new concrete periodical is published. diff --git a/chapters/design_patterns/singleton.md b/chapters/design_patterns/singleton.md index 6aff70c..aef94dc 100644 --- a/chapters/design_patterns/singleton.md +++ b/chapters/design_patterns/singleton.md @@ -49,7 +49,7 @@ Singleton.PrivateClass # => undefined ## Discussion -See in the above example how all instances are outputting from the same instance of the Singleton class. You can also see that the PrivateClass and instance variable are not accessible outside the Singleton class. In essance the Singleton class provides a static method get which returns only one instance of PrivateClass and only one. It also hides the PrivateClass from the world so that you can not create your own. +See in the above example how all instances are outputting from the same instance of the Singleton class. You can also see that the PrivateClass and instance variable are not accessible outside the Singleton class. In essence the Singleton class provides a static method get which returns only one instance of PrivateClass and only one. It also hides the PrivateClass from the world so that you can not create your own. The idea of hiding or making private the inner workings is preference. Especially since by default CoffeeScript wraps the compiled code inside it's own IIFE (closure) allowing you to define classes without worry that it might be accessible from outside the file. In this example, note that I am using the idiomatic module export feature to emphasize the publicly accessible portion of the module. (See this discussion for further explanation on [exporting to the global namespace][1]). diff --git a/chapters/functions/debounce.md b/chapters/functions/debounce.md index 2a3b714..19d99a6 100644 --- a/chapters/functions/debounce.md +++ b/chapters/functions/debounce.md @@ -34,7 +34,7 @@ mouseMoveHandler: (e) -> someOtherHandler: (e) -> @debounce((e) -> - # Do something here, but only once 250 milliseconds after initial execuction. + # Do something here, but only once 250 milliseconds after initial execution. 250, true) {% endhighlight %} diff --git a/chapters/functions/parentheses.md b/chapters/functions/parentheses.md index 3988247..457cd04 100644 --- a/chapters/functions/parentheses.md +++ b/chapters/functions/parentheses.md @@ -34,7 +34,7 @@ if (condition) { Like Ruby, CoffeeScript allows you to drop parentheses to method calls. Unlike Ruby, however, CoffeeScript treats a bare function name as the pointer to the function. The practical upshot of this is that if you give no arguments to a method, CoffeeScript cannot tell if you want to call the function or use it as a reference. -Is this good or bad? It's just different. It creates an unexpected syntax case -- parentheses aren't _always_ optional -- but in exchange it gives you the ability to pass and receive functions fluently by name, something that's a bit klunky in Ruby. +Is this good or bad? It's just different. It creates an unexpected syntax case -- parentheses aren't _always_ optional -- but in exchange it gives you the ability to pass and receive functions fluently by name, something that's a bit clunky in Ruby. This usage of the do-notation is a neat approach for CoffeeScript with parenphobia. Some people simply prefer to write out the parentheses in the function call, though. diff --git a/chapters/math/fast-fibonacci.md b/chapters/math/fast-fibonacci.md index 024773f..a6a54c4 100644 --- a/chapters/math/fast-fibonacci.md +++ b/chapters/math/fast-fibonacci.md @@ -34,7 +34,7 @@ This CoffeeScript Javascript Fast Fibonacci code is based on the python code from Robin Houston's blog. See below links. -A few things I want to introduce in time are implementions of +A few things I want to introduce in time are implementations of Newtonian, Burnikel / Ziegler, and Binet's algorithms on top of a Big Number framework. diff --git a/chapters/math/fast-inv-square.md b/chapters/math/fast-inv-square.md index 0aadaae..328df01 100644 --- a/chapters/math/fast-inv-square.md +++ b/chapters/math/fast-inv-square.md @@ -17,16 +17,16 @@ In this CoffeeScript variant I supply the original classic, and newer optimal sized magic number. Another feature included is the ability to alter the level of precision. -This is done by controling the number of iterations for performing [Newton's +This is done by controlling the number of iterations for performing [Newton's method][3]. -Depending on the machine and level of percision this algorithm may still +Depending on the machine and level of precision this algorithm may still provide performance increases over the classic. To run this, compile the script with coffee: coffee -c script.coffee -Then copy & paste the compiled js code in to the JavaSript console of your +Then copy & paste the compiled js code in to the JavaScript console of your browser. Note: You will need a browser which supports [typed-arrays][4]. @@ -63,16 +63,16 @@ In this CoffeeScript variant I supply the original classic, and newer optimal sized magic number. Another feature included is the ability to alter the level of precision. -This is done by controling the number of iterations for performing Newton's +This is done by controlling the number of iterations for performing Newton's method[3]. -Depending on the machine and level of percision this algorithm may still +Depending on the machine and level of precision this algorithm may still provide performance increases over the classic. To run this, compile the script with coffee: coffee -c .coffee -Then copy & paste the compiled js code in to the JavaSript console of your +Then copy & paste the compiled js code in to the JavaScript console of your browser. Note: You will need a browser which supports typed-arrays[4]. diff --git a/chapters/math/generating-random-numbers.md b/chapters/math/generating-random-numbers.md index afb1c5c..e795652 100644 --- a/chapters/math/generating-random-numbers.md +++ b/chapters/math/generating-random-numbers.md @@ -36,6 +36,6 @@ range = Math.random() * (max - min) + min This is a straight lift from JavaScript. -Note that JavaScripts's Math.random() does not allow you to seed the random number generator to force certain values. See [Generating Predictable Random Numbers](/chapters/math/generating-predictable-random-numbers) for that. +Note that JavaScript's Math.random() does not allow you to seed the random number generator to force certain values. See [Generating Predictable Random Numbers](/chapters/math/generating-predictable-random-numbers) for that. To generate a number from 0 up to (but not including) n, multiply by n. To generate a number from 1 to n (inclusive), multiply by n and add 1. diff --git a/chapters/strings/capitalizing-words.md b/chapters/strings/capitalizing-words.md index 5df2e96..17854d6 100644 --- a/chapters/strings/capitalizing-words.md +++ b/chapters/strings/capitalizing-words.md @@ -25,7 +25,7 @@ Or do the same thing using a list comprehension: ## Discussion -Split, map, join is a common scripting pattern dating back to perl. This function may benefit from being placed directly onto the String class by [Extending Classes](/chapters/objects/extending-classes). +Split, map, join is a common scripting pattern dating back to Perl. This function may benefit from being placed directly onto the String class by [Extending Classes](/chapters/objects/extending-classes). Be aware that two wrinkles can appear in the split, map, join pattern. The first is that the split text works best when it is constant. If the source string has multiple spaces in it, the split will need to take this into account to prevent getting extra, empty words. One way to do this is with a regular expression to split on runs of whitespace instead of a single space: diff --git a/wanted-recipes.md b/wanted-recipes.md index 5adc15d..4a38f1e 100644 --- a/wanted-recipes.md +++ b/wanted-recipes.md @@ -6,7 +6,7 @@ title: Wanted Recipes Here's a list of recipes we think we need. Pick one, implement it, and remove it from the page. Alternately, add a quick note here for a recipe you'd like to see so someone else can add it. -In the notes below, "JS" means the recipe is just a simple passthrough to an existing JavaScript method. +In the notes below, "JS" means the recipe is just a simple pass-through to an existing JavaScript method. ## Syntax @@ -14,7 +14,7 @@ In the notes below, "JS" means the recipe is just a simple passthrough to an exi ## Strings -* HTML methods # JS .sup(), .sub(), .blink(), .link(url), etc. May not exist in your JS impl! +* HTML methods # JS .sup(), .sub(), .blink(), .link(url), etc. May not exist in your JS implementation! * substr {% highlight coffeescript %} str.substr(x,y) === str[x..x+y-1] === str[x...x+y] @@ -48,7 +48,7 @@ evens.every even * Logarithms # Math.log * Finding the base-n log # Math.log(num) / Math.log(base) * Exponents # Math.exp -* Check if a creditcard is valid (checksum, Luhn algorithm) +* Check if a credit card is valid (checksum, Luhn algorithm) ## Functions