Archive for the ‘how-to’ Category
Back in August of last year, for one of the first posts on my brand-new blog, I put up the slides from a lunch-time presentation that I gave on find, grep, sed, and awk. I put it up so that it would be available as reference to those that attended the talk, even though the slides weren’t designed for stand-alone use, and slides make a poor Internet reference.
Given the surprising popularity of that post, it seemed reasonable to repackage the information in a format that is more fitting for a blog post.
grep are incredibly powerful. But many never learn a fraction of what they can do. Did you know that
grep can print the surrounding lines? Or that you can search for files based on permissions? Here’s a collection of examples that might expand your notion of what can be done with
I love the command line, and it is my primary interface for version control. When using Subversion, I appreciate the advantages of TortoiseSVN and Subclipse, and I use them on particular occasions. But the speed and precision offered at the CLI are too much of an advantage for any SVN user to ignore.
Some of you are snickering already. “Subversion? It’s almost 2012, past time to move to Git or Mercurial.” Sure, and we’ve all left Java behind, and spend our days coding in Clojure or Scala. The fact is that if you don’t work at a startup, you are unlikely to actually use a DVCS at work, so Subversion is still relevant to more developers than any other version control system, and will be for the next five years, regardless of how you feel about that.
If you are one of those that uses Subversion, read on, and I’ll detail the commands that you should know and use regularly. Read the rest of this entry »
I love keyboard shortcuts, and I do my best to incorporate them with every GUI application that I use regularly. I’ve been comparatively negligent in learning keyboard shortcut for the command-line applications, as it seems less advantages. After all, there’s no need to reach for the mouse, what are we hoping to save?
Nevertheless, there are real efficiencies out there, and here are my favorite Bash shortcuts. Read the rest of this entry »
When you want to see the contents of a text file in unix, the first two things to come to mind are
less. I choose
cat when the files are small, but the pagination and navigation in
less makes it the better choice most of the time.
Suppose you find a directory with five files that are unknown to you. Printing the contents of all five is easy enough with
cat and a pipe:
$ ls | xargs cat
But if you have five files, chances are you don’t just want everything scrolling past you. So we try:
$ ls | xargs less
Hmm … when you get to the bottom of
file1.txt we find the message
(END) - Next: file2.txt. What to do?
As always, the answer is in the
:n for next file,
:p for previous file.
Of course, this isn’t only useful when piping input into
less, it also works when specifying multiple arguments:
$ less file1.txt file2.txt file3.txt
If the question involves mathematical typesetting, then you can be sure that the answer is LaTeX. But if you are off the beaten path, LaTeX can be both the solution and a new problem.
I was interested in typesetting some elementary-school style vertical arithmetic problems. You know, like:
28 + 15 ----
Except with better readability.
Every programmer should read The Little Schemer (pdf) at some point. It doesn’t take long to read, and I hope to provide a review of it soon. For now, I hope to explain how to get started practically with Scheme, as used in this book, since these details are hard to find.
Suppose you want to send tweets from Python code from your own Twitter account. How hard could that be? It’s Python, so the batteries are included right?
It turns out that the Python side is pretty slick, but there are some issues about interacting with Twitter that aren’t as easy as you could imagine.
Do I need to use a library?
The mature Python Twitter libraries, (Python Twitter Tools, and Python Twitter) will allow you to do anything that you could want with the Twitter API. But you’re just trying to send tweets, you don’t need to look at your friends’ timelines’. Maybe this approach is more what you are looking for?
Well not exactly like that. That approach uses Basic Authentication, which is no longer supported. Whatever you do will require OAuth, so it’s definitely going to take less time to use a library for novice twitter devs.