I often want to look at all of the changes a file has gone through. Sometimes
git blameis enough because I’m interested in the most recent change. But when the most recent change to a line isn’t relevant—a formatting change, for example—I need something more powerful. Enter
git log --follow -p -- myfilename, I can view the entire commit history for a file with a diff of the changes introduced by each commit.
Julia Evans posted earlier about a neat Vim feature I had forgotten about—vim sessions.
When closing Vim, you can save the view you have open by creating a session:
When you need to come back to that work, just reopen the session:
To see a list of your environment variables in a UNIX-like system, you can simply use
envwithout any additional arguments.
man envwill show you other uses of the
There are also some common gotchas to watch out for when using event listeners on scroll and touch events. Setting local or passive event listeners may help, but these implementations depend on what browsers you use.
Laurens Van Houten’s PyCon 2013 talk Crypto 101 is a great introduction to TLS, some of the basics of symmetric and asymmetric cryptography, and some of the most common hashing algorithms.
Let’s say you’re looking for more information about a command like
ansible. You can use
man ansibleto print the
manpage for the
ansiblecommand. But maybe you want to see a list of
manpages that mention the string “ansible”. You can simply write:
> man -k ansible ansible(1) - run a task on a target host(s) ansible-doc(1) - show documentation on Ansible modules ansible-galaxy(1) - manage roles using galaxy.ansible.com ansible-playbook(1) - run an ansible playbook ansible-pull(1) - pull playbooks from VCS server and run them using this machine as the target ansible-vault(1) - manage encrypted ansible vars files (YAML)
The number next to each
manentry represents its section number. Thanks Justin Weissig for helping me learn this useful tip.
I learned a handful of
consoletricks from this article.
When logging to the console, you can use
console.group()to name a group and collect console ouptput. Calling
console.groupEnd()will end the named group. You can even create nested named groups.
The following code will organize the console output under a group named “Starting up”. Nested under that group will be “First task” and “Second task” groups. These groups can also be auto-collapsed if you don’t want them cluttering up your console output.
console.group('Starting up'); console.group('First task'); console.log('First task starting'); console.log('First task complete'); console.groupEnd('First task'); console.group('Second task'); console.log('Second task starting'); console.log('Second task complete'); console.groupEnd('Second task'); console.groupEnd('Starting up');
console.assert()function will print an error string to the console if the assertion used as the first parameter is
console.assert(article.tagCount > 0, "There are no tags for this article.");
Check out the full article for more tips.
git cherryis a useful part of the
gitsuite that allows you to find commits that have yet to be applied to an upstream branch. Let’s say you have an upstream branch
To see how your
HEADcompares with the upstream branch, you can run
git cherry origin/my-cool-feature. You will then see a list of commits yet to be applied to
- abcdefg123456... + jiw8134dadzfw... + zyxwvut123987...
Those commits marked with a
-can be dropped from
HEADwhen rebased on top of
origin/my-cool-feature. The commits with a
+will need to be kept so that they can be applied to the upstream branch.
git cherryto be useful today when I wanted to compare a local branch to a branch we were testing for an upcoming release. I wanted to see whether some commits in
masterhad been cherry-picked into our release, and
git cherry -v our-release-candidateprovided a nice list of the differences between the two branches (the useful
-vflag outputs the commit subjects next to the SHA1s).
Developers often through around the term “RESTful API”, but we aren’t always on the same page about what “RESTful” means. I enjoyed this Martin Fowler article on the Richardson Maturity Model because of its helpful explanation of the steps toward REST.
As a developer consuming APIs, I can get frustrated with APIs that are on lower rungs of this model. Their resources are not easily identified, and interacting with them can be a headache. When I work with APIs like this, I find myself referring to the API documentation way more than I would like to. Unfortunately, it’s hard to avoid doing so because the API is not necessarily consistent across resources.
My favorite APIs to work with have clearly identified resources and use HTTP verbs as you might expect. Recently, I’ve had the pleasure of working with some APIs that implement hypermedia controls. Fetching a resource, requesting more information about its associated resources, and manipulating resources are easy because the API itself provides clues about where to go next.
If you find yourself designing and writing APIs I sometimes do, please check out Fowler’s article.
If you use
binding.prywhen debugging like I do, you may find Pry’s
show-sourcemethod useful. Use it to see the source code of a method (complete with syntax highlighting).
show-sourcehas the useful alias
$, so you can even write something like
$ some_methodto quickly see a method’s source code while debugging.
For more on how
show-sourceworks, check out the Pry wiki.
Sometimes you want to encrypt a file that contains sensitive information like API keys. One way to encrypt such a file is to use a symmetric cipher:
After entering and confirming a passphrase, you will now have an encrypted file that you can decrypt at any time. This technique might be useful if you want to check in the encrypted file into your version control system, for example.
To learn more about encrypting and decrypting files, including how to use public-key cryptography to share encrypted files, check out The GNU Privacy Handbook.
Mitchell Anicas at Digital Ocean wrote an excellent post about HAProxy which really helped make clear to me how load balancing with HAProxy works. The diagrams in the article are very clear and useful, and it’s worth checking out if you’re new to load balancing concepts.
subscribe via RSS