summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGeoff Liu <cangming.liu@gmail.com>2014-11-27 00:42:20 -0700
committerGeoff Liu <cangming.liu@gmail.com>2014-11-27 00:42:20 -0700
commite1610bf1a93550740072832cff1c647b0869a993 (patch)
tree2d933f5062f8318a841ca4a763692c71d03a9eb3
parent448aee0ed7b68d1ad029d78f3ac157eeba8c3555 (diff)
parent1d7f26f2f4ce6d8ff1eeb6055d635b3fd63bbbcf (diff)
Merge remote-tracking branch 'upstream/master'
-rw-r--r--c.html.markdown2
-rw-r--r--git.html.markdown64
-rw-r--r--haskell.html.markdown19
-rw-r--r--pt-br/ruby-pt.html.markdown12
4 files changed, 81 insertions, 16 deletions
diff --git a/c.html.markdown b/c.html.markdown
index 874197d3..f44da38e 100644
--- a/c.html.markdown
+++ b/c.html.markdown
@@ -629,7 +629,7 @@ typedef void (*my_fnp_type)(char *);
## Further Reading
Best to find yourself a copy of [K&R, aka "The C Programming Language"](https://en.wikipedia.org/wiki/The_C_Programming_Language)
-It is *the* book about C, written by the creators of C. Be careful, though - it's ancient and it contains some
+It is *the* book about C, written by Dennis Ritchie, the creator of C, and Brian Kernighan. Be careful, though - it's ancient and it contains some
inaccuracies (well, ideas that are not considered good anymore) or now-changed practices.
Another good resource is [Learn C the hard way](http://c.learncodethehardway.org/book/).
diff --git a/git.html.markdown b/git.html.markdown
index 618d1906..04350dd5 100644
--- a/git.html.markdown
+++ b/git.html.markdown
@@ -3,6 +3,8 @@ category: tool
tool: git
contributors:
- ["Jake Prather", "http://github.com/JakeHP"]
+ - ["Leo Rudberg" , "http://github.com/LOZORD"]
+ - ["Betsy Lorton" , "http://github.com/schbetsy"]
filename: LearnGit.txt
---
@@ -334,6 +336,66 @@ $ git push -u origin master
$ git push
```
+### stash
+
+Stashing takes the dirty state of your working directory and saves it on a stack of unfinished changes that you can reapply at any time.
+
+Let's say you've been doing some work in your git repo, but you want to pull from the remote.
+Since you have dirty (uncommited) changes to some files, you are not able to run `git pull`.
+Instead, you can run `git stash` to save your changes onto a stack!
+
+```bash
+$ git stash
+Saved working directory and index state \
+ "WIP on master: 049d078 added the index file"
+ HEAD is now at 049d078 added the index file
+ (To restore them type "git stash apply")
+```
+
+Now you can pull!
+
+```bash
+git pull
+```
+`...changes apply...`
+
+Now check that everything is OK
+
+```bash
+$ git status
+# On branch master
+nothing to commit, working directory clean
+```
+
+You can see what "hunks" you've stashed so far using `git stash list`.
+Since the "hunks" are stored in a Last-In-First-Out stack, our most recent change will be at top.
+
+```bash
+$ git stash list
+stash@{0}: WIP on master: 049d078 added the index file
+stash@{1}: WIP on master: c264051 Revert "added file_size"
+stash@{2}: WIP on master: 21d80a5 added number to log
+```
+
+Now let's apply our dirty changes back by popping them off the stack.
+
+```bash
+$ git stash pop
+# On branch master
+# Changes not staged for commit:
+# (use "git add <file>..." to update what will be committed)
+#
+# modified: index.html
+# modified: lib/simplegit.rb
+#
+```
+
+`git stash apply` does the same thing
+
+Now you're ready to get back to work on your stuff!
+
+[Additional Reading.](http://git-scm.com/book/en/v1/Git-Tools-Stashing)
+
### rebase (caution)
Take all changes that were committed on one branch, and replay them onto another branch.
@@ -396,4 +458,4 @@ $ git rm /pather/to/the/file/HelloWorld.c
* [GitGuys](http://www.gitguys.com/)
-* [Git - the simple guide](http://rogerdudler.github.io/git-guide/index.html) \ No newline at end of file
+* [Git - the simple guide](http://rogerdudler.github.io/git-guide/index.html)
diff --git a/haskell.html.markdown b/haskell.html.markdown
index 2785405c..748a29da 100644
--- a/haskell.html.markdown
+++ b/haskell.html.markdown
@@ -110,7 +110,7 @@ last [1..5] -- 5
-- A tuple:
("haskell", 1)
--- accessing elements of a tuple
+-- accessing elements of a pair (i.e. a tuple of length 2)
fst ("haskell", 1) -- "haskell"
snd ("haskell", 1) -- 1
@@ -195,8 +195,8 @@ foo 5 -- 75
-- fixing precedence
-- Haskell has another function called `$`. This changes the precedence
-- so that everything to the left of it gets computed first and then applied
--- to everything on the right. You can use `.` and `$` to get rid of a lot
--- of parentheses:
+-- to everything on the right. You can use `$` (often in combination with `.`)
+-- to get rid of a lot of parentheses:
-- before
(even (fib 7)) -- true
@@ -204,6 +204,9 @@ foo 5 -- 75
-- after
even . fib $ 7 -- true
+-- equivalently
+even $ fib 7 -- true
+
----------------------------------------------------
-- 5. Type signatures
----------------------------------------------------
@@ -227,24 +230,24 @@ double :: Integer -> Integer
double x = x * 2
----------------------------------------------------
--- 6. Control Flow and If Statements
+-- 6. Control Flow and If Expressions
----------------------------------------------------
--- if statements
+-- if expressions
haskell = if 1 == 1 then "awesome" else "awful" -- haskell = "awesome"
--- if statements can be on multiple lines too, indentation is important
+-- if expressions can be on multiple lines too, indentation is important
haskell = if 1 == 1
then "awesome"
else "awful"
--- case statements: Here's how you could parse command line arguments
+-- case expressions: Here's how you could parse command line arguments
case args of
"help" -> printHelp
"start" -> startProgram
_ -> putStrLn "bad args"
--- Haskell doesn't have loops because it uses recursion instead.
+-- Haskell doesn't have loops; it uses recursion instead.
-- map applies a function over every element in an array
map (*2) [1..5] -- [2, 4, 6, 8, 10]
diff --git a/pt-br/ruby-pt.html.markdown b/pt-br/ruby-pt.html.markdown
index 4a8a1b5c..89a051d4 100644
--- a/pt-br/ruby-pt.html.markdown
+++ b/pt-br/ruby-pt.html.markdown
@@ -33,7 +33,7 @@ Você não deve usar também
10 * 2 #=> 20
35 / 5 #=> 7
-# Aritimética é apenas açúcar sintático
+# Aritmética é apenas açúcar sintático
# para chamar um método de um objeto
1.+(3) #=> 4
10.* 5 #=> 50
@@ -129,7 +129,7 @@ array = [1, "Oi", false] #=> => [1, "Oi", false]
array[0] #=> 1
array[12] #=> nil
-# Como aritimética, o acesso via [var]
+# Como aritmética, o acesso via [var]
# é apenas açúcar sintático
# para chamar o método [] de um objeto
array.[] 0 #=> 1
@@ -171,7 +171,7 @@ end
# Desde o Ruby 1.9, temos uma sintaxe especial quando usamos símbolos como chaves (keys)
-novo_hash = { defcon: 3, acao: true}
+novo_hash = {defcon: 3, acao: true}
novo_hash.keys #=> [:defcon, :acao]
@@ -183,9 +183,9 @@ novo_hash.keys #=> [:defcon, :acao]
if true
"Se verdadeiro"
elsif false
- "else if, opicional"
+ "else if, opcional"
else
- "else, também é opicional"
+ "else, também é opcional"
end
for contador in 1..5
@@ -259,7 +259,7 @@ end
# Argumentos de métodos são separados por uma vírgula
somar 3, 4 #=> 7
-somar somar(3,4), 5 #=> 12
+somar(3,4), 5 #=> 12
# yield
# Todos os métodos possuem implicitamente um paramêntro opcional que é um bloco