diff --git a/bash.html.markdown b/bash.html.markdown
index 57fb5c55..dc7d32b6 100644
--- a/bash.html.markdown
+++ b/bash.html.markdown
@@ -8,6 +8,7 @@ contributors:
- ["Denis Arh", "https://github.com/darh"]
- ["akirahirose", "https://twitter.com/akirahirose"]
- ["Anton Strömkvist", "http://lutic.org/"]
+ - ["Rahil Momin", "https://github.com/iamrahil"]
filename: LearnBash.sh
---
@@ -140,6 +141,12 @@ do
echo "$VARIABLE"
done
+# Or write it the "traditional for loop" way:
+for ((a=1; a <= 3; a++))
+do
+ echo $a
+done
+
# They can also be used to act on files..
# This will run the command 'cat' on file1 and file2
for VARIABLE in file1 file2
diff --git a/c.html.markdown b/c.html.markdown
index 79b7aec7..cbb6d289 100644
--- a/c.html.markdown
+++ b/c.html.markdown
@@ -4,6 +4,7 @@ filename: learnc.c
contributors:
- ["Adam Bard", "http://adambard.com/"]
- ["Árpád Goretity", "http://twitter.com/H2CO3_iOS"]
+ - ["Jakub Trzebiatowski", "http://cbs.stgn.pl"]
---
@@ -175,6 +176,9 @@ int main() {
i2 * i1; // => 2
i1 / i2; // => 0 (0.5, but truncated towards 0)
+ // You need to cast at least one integer to float to get a floating-point result
+ (float)i1 / i2 // => 0.5f
+ i1 / (double)i2 // => 0.5 // Same with double
f1 / f2; // => 0.5, plus or minus epsilon
// Floating-point numbers and calculations are not exact
@@ -194,9 +198,11 @@ int main() {
2 >= 2; // => 1
// C is not Python - comparisons don't chain.
- // WRONG:
- //int between_0_and_2 = 0 < a < 2;
- // Correct:
+ // Warning: The line below will compile, but it means `(0 < a) < 2`.
+ // This expression is always true, because (0 < a) could be either 1 or 0.
+ // In this case it's 1, because (0 < 1).
+ int between_0_and_2 = 0 < a < 2;
+ // Instead use:
int between_0_and_2 = 0 < a && a < 2;
// Logic works on ints
diff --git a/coffeescript.html.markdown b/coffeescript.html.markdown
index d96eed39..6af692b9 100644
--- a/coffeescript.html.markdown
+++ b/coffeescript.html.markdown
@@ -11,7 +11,7 @@ As one of the succeeders of JavaScript, CoffeeScript tries its best to output re
See also [the CoffeeScript website](http://coffeescript.org/), which has a complete tutorial on CoffeeScript.
-``` coffeescript
+```coffeescript
# CoffeeScript is a hipster language.
# It goes with the trends of many modern languages.
# So comments are like Ruby and Python, they use number symbols.
diff --git a/common-lisp.html.markdown b/common-lisp.html.markdown
index 8de81549..08134e35 100644
--- a/common-lisp.html.markdown
+++ b/common-lisp.html.markdown
@@ -17,7 +17,7 @@ Another popular and recent book is
-```scheme
+```common_lisp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 0. Syntax
diff --git a/compojure.html.markdown b/compojure.html.markdown
index 56f43cb7..96555273 100644
--- a/compojure.html.markdown
+++ b/compojure.html.markdown
@@ -23,20 +23,22 @@ in Clojure with minimal effort:
(run-server myapp {:port 5000}))
```
-Create a project with [Leiningen](http://leiningen.org/):
+**Step 1:** Create a project with [Leiningen](http://leiningen.org/):
```
lein new myapp
```
-Add your dependencies:
+**Step 2:** Put the above code in `src/myapp/core.clj`
+
+**Step 3:** Add some dependencies to `project.clj`:
```
[compojure "1.1.8"]
[http-kit "2.1.16"]
```
-And run:
+**Step 4:** Run:
```
lein run -m myapp.core
@@ -81,18 +83,26 @@ The body may be a function, which must accept the request as a parameter:
(GET "/" [] (fn [req] "Do something with req")))
```
-Route patterns may include named parameters,
+Or, you can just use the request directly:
+
+```clojure
+(defroutes myapp
+ (GET "/" req "Do something with req"))
+```
+
+Route patterns may include named parameters:
```clojure
(defroutes myapp
(GET "/hello/:name" [name] (str "Hello " name)))
```
-You can match entire paths with *
+You can adjust what each parameter matches by supplying a regex:
```clojure
(defroutes myapp
- (GET "/file/*.*" [*] (str *)))
+ (GET ["/file/:name.:ext" :name #".*", :ext #".*"] [name ext]
+ (str "File: " name ext))
```
Handlers may utilize query parameters:
@@ -100,10 +110,10 @@ Handlers may utilize query parameters:
```clojure
(defroutes myapp
(GET "/posts" []
- (fn [req]
- (let [title (get (:params req) "title")
- author (get (:params req) "title")]
- " Do something with title and author"))))
+ (fn [req]
+ (let [title (get (:params req) "title")
+ author (get (:params req) "title")]
+ " Do something with title and author"))))
```
Or, for POST and PUT requests, form parameters
@@ -111,10 +121,10 @@ Or, for POST and PUT requests, form parameters
```clojure
(defroutes myapp
(POST "/posts" []
- (fn [req]
- (let [title (get (:params req) "title")
- author (get (:params req) "title")]
- "Do something with title and author"))))
+ (fn [req]
+ (let [title (get (:params req) "title")
+ author (get (:params req) "title")]
+ "Do something with title and author"))))
```
@@ -123,16 +133,16 @@ Or, for POST and PUT requests, form parameters
The return value of a route block determines at least the response body
passed on to the HTTP client, or at least the next middleware in the
ring stack. Most commonly, this is a string, as in the above examples.
-But, you may also return a [response body](https://github.com/mmcgrana/ring/blob/master/SPEC):
+But, you may also return a [response map](https://github.com/mmcgrana/ring/blob/master/SPEC):
```clojure
(defroutes myapp
(GET "/" []
- {:status 200 :body "Hello World"})
+ {:status 200 :body "Hello World"})
(GET "/is-403" []
- {:status 403 :body ""})
+ {:status 403 :body ""})
(GET "/is-json" []
- {:status 200 :headers {"Content-Type" "application/json"} :body "{}"}))
+ {:status 200 :headers {"Content-Type" "application/json"} :body "{}"}))
```
### Static Files
@@ -164,7 +174,7 @@ To use templating with Compojure, you'll need a template library. Here are a few
(defroutes myapp
(GET "/hello/:name" [name]
- (render-string "Hello {{name}}" {:name name})))
+ (render-string "Hello {{name}}" {:name name})))
```
You can easily read in templates from your resources directory. Here's a helper function
@@ -177,7 +187,7 @@ You can easily read in templates from your resources directory. Here's a helper
(defroutes myapp
(GET "/hello/:name" [name]
- (render-string (read-template "templates/hello.html") {:name name})))
+ (render-string (read-template "templates/hello.html") {:name name})))
```
#### [Selmer](https://github.com/yogthos/Selmer)
@@ -189,7 +199,7 @@ You can easily read in templates from your resources directory. Here's a helper
(defroutes myapp
(GET "/hello/:name" [name]
- (render-file "templates/hello.html" {:name name})))
+ (render-file "templates/hello.html" {:name name})))
```
#### [Hiccup](https://github.com/weavejester/hiccup)
@@ -201,11 +211,11 @@ You can easily read in templates from your resources directory. Here's a helper
(defroutes myapp
(GET "/hello/:name" [name]
- (hiccup/html
- [:html
- [:body
- [:h1 {:class "title"}
- (str "Hello " name)]]])))
+ (hiccup/html
+ [:html
+ [:body
+ [:h1 {:class "title"}
+ (str "Hello " name)]]])))
```
#### [Markdown](https://github.com/yogthos/markdown-clj)
@@ -217,9 +227,11 @@ You can easily read in templates from your resources directory. Here's a helper
(defroutes myapp
(GET "/hello/:name" [name]
- (md-to-html-string "## Hello, world")))
+ (md-to-html-string "## Hello, world")))
```
Further reading:
-[Clojure for the Brave and True](http://www.braveclojure.com/)
+* [Official Compojure Documentation](https://github.com/weavejester/compojure/wiki)
+
+* [Clojure for the Brave and True](http://www.braveclojure.com/)
diff --git a/es-es/markdown-es.html.markdown b/es-es/markdown-es.html.markdown
index 3865126c..d90e3eb5 100644
--- a/es-es/markdown-es.html.markdown
+++ b/es-es/markdown-es.html.markdown
@@ -14,7 +14,7 @@ fácilmente a HTML (y, actualmente, otros formatos también).
¡Denme todo la retroalimentación que quieran! / ¡Sientanse en la libertad de hacer forks o pull requests!
-```
+```markdown