Tag Archives: tips
Exclude a Directory when Grepping
node-modules
folder, try this:
grep -R --exclude-dir node_modules [what to search for] *
If you’re using a different tech stack you may want to exclude a different directory (for PHP, the directory would be called vendor
), but this is a very handy tip and a bit nicer than the older approach I was using which did the whole search and then used a second grep to eliminate things by using the -v
switch.
Using OS X From The Keyboard
I collected all my tools, my own notes and scribbled cheatsheets and put them into this gist so that I could refer to them later; I also intend to keep updating this as a reference. Continue reading
Handling Composer “lock file out of date” Warning
composer.json
where you specify your dependenciescomposer.lock
where composer itself records exactly which precise version of every library and every dependency of every library it picked, so all installs will be identical
Crucially, the composer.lock
also includes a hash of the current composer.json
when it updates, so you can always tell if you’ve added a requirement to the composer.json
file and forgotten to install it. Continue reading
Git Won’t Check Out A Path It Autocompleted
Git Pull Causes a Merge
git pull
and expect a fast-forward update, but get a merge instead, don’t panic! This usually happens when we’re collaborating on a branch with other people, and we’ve made changes on our local version of a branch, and someone else (or the other you, if you use git to sync between multiple dev platforms) has made changes to the remote version of a branch in the meantime. It also happens really frequently in teams where all commits are to the master
branch … yet another reason to have a decent branching strategy.
All that’s happened is something like this:
$ git log --oneline --all --graph --decorate * 054f163 (HEAD, branch1) Installation instructions for the application | * 0ce808c (origin/branch1) Fixing template layout |/ * 927aad9 A random change of 731 to ideas2.txt
Since the last common commit, there are commits on your local branch, and the remote one. You could just let the merge go ahead but there are other options. You could also check out a new branch at this point, reset your tracking branch to the right place and then reapply your changes using cherry-pick or by rebasing and then fast-forward merging your branch. Continue reading
Debugging rst2pdf and pygments
Code Reviews: Before You Even Run The Code
Over time I’ve developed some particular processes that I find helpful when reviewing code. In particular, I often surprise people at how much review I do before I run the code. Sometimes I grab the branch so that I can use my local diff tools, but I don’t actually execute code until I’ve established some basic facts. This post is a little insight into what’s happening in this not-running-the-code-yet zone. Continue reading
Count Changed Lines in Git
git log --numstat
will show you how many lines were added (first column) and removed (next column) per file, kind of a more scientific version of the --stat
switch. And if you’re thinking of scripting this to gather stats, try it with --oneline
as well, it’s easier to parse.
Scaling and Sizing with PDFJam
pdfjam --suffix converted --papersize '{1920px,1080px}' --scale 0.4 --trim "-6cm -1cm 13cm 8cm" slides.pdf
The --suffix
is instead of giving an output filename, whatever you feed in ends up with the suffix in its filename. This is very handy because I use this command in a script and only need to pass in one variable. The --papersize
isn’t a switch I have used before either but you can set exact sizes for the final output which is nice. The --trim
switch can also be used to set --clip=true
to remove the trimmed space from the document if desired.
I find PDFJam a very handy tool but with not nearly enough blog posts and code snippets around, so I’m dropping my command for future reference (yours as well as mine!).