Terminal Piping, Wget, Git, cURL
git log | subl allows you to view the Git log in Sublime Text (assuming your symlink has been established). Or you can write into a file with
git log > gitlog.txt! More about these strange symbols (like
-q makes wget run in quiet mode (so as to not output anythign to the terminal).
The input after
-O indicates where we want to download the file to. In this case, by entering
- as the filename, we're telling wget to just output the results into the standard output (which is likely your terminal). More about that here.
Finally, this output gets piped into the
sh terminal command, which is the Bourne shell.
TLDR: You run Heroku’s
install.sh file immediately in your terminal.
git add -p (or
--patch) allows you to interactively and independently select which changes to stage for committing. But what do all the crazy options
[y,n,q,a,d,/,e,?] mean when Git asks, "Stage this hunk?" Here, alas, is the answer:
y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk or any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk or any of the later hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
e - manually edit the current hunk
? - print help
I’ve found the
s option extremely helpful when I hadn't committed as frequently as I should have (oops) and ended up working on more than one feature. It allowed me to be very specific with which changes I wanted to stage for commit (and the
e option allowed me to be especially detailed). This helped me make very clean commits that didn't have any non-related changes. (The manual edit option pulled up Sublime Text with some amazingly colored code. 10/10, would recommend.)
git add here.
I’d seen curl commands before, but never quite understood what was going on.
Curl is a tool that lets us transfer data to a server.
curl http://localhost:8000/ allows us to make a GET request to our local server.
curl http://localhost:8000/ -d "hello world" makes a POST request to our local server with "hello world" as the data sent.
We can make multiple requests to different URLs by using brackets. For example:
curl http://localhost:8000/\[1-3\] makes GET requests to:
..one at a time, in that order. I can see this being especially useful when trying to hit several different endpoints of a RESTful API.