When working with Internet protocols, we have to read RFCs a lot. They
can be found on the Web, but it’s better to have them directly in the terminal.
Ubuntu provide some packages to have them offline, but if you aren’t a
sudoer, you can’t install them with apt-get. So I needed a little script to
fetch RFCs from IETF’s website and read them locally.
Here comes rfc
rfc was initially a small Bash script (~5 lines) that cURL-ed RFCs and
displayed them with less. I used it for the Networking class at Paris Diderot.
A few weeks ago, I enhanced it with a local cache (it now download an RFC the
first time only), and an offline search feature. Thanks to ecksun, it
can also be used to read drafts. The script works pretty much everywhere, and is
really simple to use:
$ rfc <number>
For example, get the RFC 6749 (OAuth 2.0) with:
$ rfc 6749
That’s all! Since it’s just plain text, you can pipe it or redirect its output
to anything:
If you don’t have ~/bin in your PATH, add this line in your ~/.bashrc:
export PATH="$HOME/bin:$PATH"
The only requirements are a pager (less is the default, but it’ll use $PAGER
if it’s set) and curl (it’ll use $CURL if it’s set, and fallback on wget
if curl can’t be found).
Spotify’s Web app is great, but you may prefer to
use the desktop client. The problem is that the links default to the Web app.
Here is a quick tip to make what you want.
First, install Switcheroo. It’s a Chrome extension (Firefox users,
go here) that allows you
to setup custom redirect rules for any http request, using a string
replacement. Then, add a rule to replace http://open.spotify.com/ with
spotify://.
That’s it! Now, all open.spotify.com/something links will open in the desktop
client instead of the Web one.
Note: I found the original tip here, but it was not working because the
author suggested to replace with spotify instead of spotify://.
The Urban Dictionary website is pretty useful when one wants to
know the meaning of any familiar or slang word. Users can write definitions for
any words, and upvote or downvote them. Unfortunately, the website doesn’t have
a public API, and I couldn’t find a command-line tool for it. So I wrote one.
Introducing ud
ud is a command-line tool which prints definitions from the Urban Dictionary
website. It’s written in Ruby, and allows you to quickly search for a
definition of any word.
$ ud wth
* WTH (567/126):
1) Abbreviation for "What the Hell"
2) Shortened alternative to "With"
Example:
1) WTH was that?!
2) I ate some crackers wth chicken
(…)
For common abbreviations like “wtf” or “omg”, there are dozens of definitions,
with minor differences. That’s why the script scraps only the first page of
results, and supports a few options: -n allows you to limit the number of
definitions (e.g. -n 1 → only one). -r allows you to select only the
definitions which have an upvotes/downvotes ratio higher than what you want,
e.g. -r 2 will select only the definitions which have twice more upvotes than
downvotes. For your convenience, it also support the shortcut -u which is an
alias for -r 2. Type ud -h for more info.
Install
That’s easy:
gem install ud
Please note that if you’re using Windows, you’ll need to install the Win32
Console ANSI gem for the colored output. Install it with:
gem install win32console
Using the UD module
The gem also provide a UD module, which you can use to query the website in
your own Ruby code: