
Command line tools every web dev needs to know - countessa
http://www.coderholic.com/invaluable-command-line-tools-for-web-developers/
======
zalew
quite relevant: <http://www.commandlinefu.com> a great collection of cli uses
and abuses

one of my favorites is querying dns to get wiki excerpts

    
    
        dig +short txt bmw.wp.dg.cx
        "(BMW), is an independent German automobile manufacturing company founded in 1916. It also produces motorcycles, is the owner of the MINI brand and is the parent company of Rolls-Royce Motor Cars. http://en.wikipedia.org/wiki/BMW"
    

[http://www.commandlinefu.com/commands/view/2829/query-
wikipe...](http://www.commandlinefu.com/commands/view/2829/query-wikipedia-
via-console-over-dns#comment)

~~~
morsch
I've got something like this in my .bashrc so I can access commandlinefu from
within the shell:

    
    
      cmdfu(){ wget -qO - "http://www.commandlinefu.com/commands/matching/$@/$(echo -n "$@" | openssl base64)/plaintext"; }
    

It's like _man_ but for one-liners.

~~~
hntester123
Interesting. Can you explain how the command works? I did look at the
commandlinefu API page but didn't get it. I know UNIX and also specifically
what "$@" means in UNIX but didn't get the meaning of the two uses of it in
the commandlinefu URL you show, nor what the openssl part does.

~~~
shabble
It seems that the API bizarrely expects:

    
    
        [URL]/matching/ssh/c3No - Search results for the query
        'ssh' (note that the final segment is a base64-encoding
        of the search query)
    

So it's passing the command args through 'openssl base64' to encode them as
required by the api.

    
    
         $ echo -n ssh | openssl base64
         c3No
    

It's not immediately clear to me why they require both - base64 encoding might
be useful to allow non-printable/special-purpose chars in the URL, but we
already have a perfectly good URL-encoding scheme for that.

And requiring both (it doesn't seem to work with only one) is just silly.

~~~
codeinthehole
commandlinefu.com author here. Agreed, the API is odd and needs rewriting - I
was trying to work around the idiosyncrasies of CodeIgniter which didn't
support query parameters (hilarious) at the time of writing. The first segment
(eg 'ssh' in /matching/ssh/c3No') isn't actually used - it's just there for
SEO. You can insert junk there if you want - both aren't required. I'll update
the docs to make this clearer.

There is a Django-rewrite of commandlinefu on the way including a saner API.

------
benjaminwootton
We are interviewing for experienced developers at the moment and the lack of
general unix knowledge is really surprising.

A little bit of shell scripting goes a long way in automating away dev work.

~~~
Derbasti
Also, typing.

I am frequently amazed to see professional software developers with years of
experience in the field, who only type using their two index fingers. You
probably do not need to type 120 WPM to be an amazing programmer, but typing
without looking at the keyboard is absolutely essential.

~~~
prostoalex
Why? What projects have slipped due to programmer's inability to type in all
the necessary code on time?

~~~
jimm
I don't know, but typing that slowly means that there is a barrier between the
thought and the deed. It like if you wrote a poem, then started speaking the
letters one by one in Morse code --- and you refuse to learn Morse code so you
have to look up each letter's code as you go.

~~~
coroxout
My former coworker would use the mouse to copy and paste even 3-letter
variable names rather than typing them in again. He'd also scroll his terminal
window up and copy and paste old commands (again, all with the mouse) rather
than using the up arrow, even after I told him about command line history and
tab completion in case he didn't know, and would frequently mis-copy and miss
the first letter off or have a stray $ at the front, causing him to start his
mousing over from scratch rather than using the keyboard to correct it.

I am not the most patient of people and had to bite my tongue a few times when
instructing him. I can understand being more comfortable with the mouse than
keyboard shortcuts but programming is not the best profession for anyone
keyboard-averse to that level.

Of course some people genuinely find the keyboard physically uncomfortable and
there's no reason they couldn't still be excellent programmers - but it seems
like it would impede the "flow".

~~~
to3m
I'm not sure it makes a big difference. You're going to have to waste a HUGE
amount of time doing things the inefficient way (whichever it is for the task
at hand) before it will be the equal of arriving late for even just one day,
or taking an extra 5 minutes at lunch.

Things I suspect you'd be better off getting good at than keyboard shortcuts:

* Regular expression search and replace

* The command line (default Windows command prompt is fine), and the POSIX-style command line tools (default Windows command line tools are NOT fine)

* Some kind of popular scripting-type language (perl/python/ruby/whatever/etc.), if you don't know one already

I like my keyboard shortcuts, but the above have saved me much, much more time
over the years.

------
lordlarm
Another useful one; Fire up a instant web-server from local folder on
<http://localhost:8080>:

> python -m SimpleHTTPServer

~~~
dudus
Note that it has changed in python3

    
    
      > python3 -m http.server
      Serving HTTP on 0.0.0.0 port 8000 ...
    
      > python3 -m http.server 8080
      Serving HTTP on 0.0.0.0 port 8080 ...

------
simfoo
> With the following command we test google with 20 concurrent connections for
> 30 seconds

Even though this is Google and they probably don't have a problem with this, I
don't think you should benchmark servers that don't belong to you. It's not
nice and could be mistaken for a DOS attack.

~~~
ihsw
Google may actually give you a short-term IP ban (a day or so), so spamming
their servers with spurious connections may not be in your best interest --
doubly so if you're at a workplace.

~~~
evilduck
However, if I dislike the IT guys, this sounds like an awesome practical joke.

~~~
bdunbar
Ted, is that you?

------
jameswyse
Also check out HTTPie: <https://github.com/jkbr/httpie/> I much prefer it over
curl.

$ http GET <http://yourmom.ca/>

~~~
secoif
see also burl: <https://github.com/visionmedia/burl> been good for testing
requests against json apis

~~~
dtf
see also Curlish: <http://packages.python.org/curlish/>

------
lovskogen
Yesterday I used the ipfw command to run our product in "slow motion" to spot
loading order and if animations started at the right places. Discovered alot
of stuff that needs fixing. The ipfw command is for trottling bandwidth, and
great for product designers like myself :) I'm sure it has other uses as well.

~~~
rada
OS X has a useful Network Link Conditioner utility. It has built-in profiles
such as lossy 3G connection, average wifi connection, good wifi connection
etc.

~~~
lovskogen
Cool, where is it?

~~~
rada
You have to have Developer Tools installed. I am at work right now, not on a
mac, but I will try from memory. I believe you get it from Xcode > Developer
tools > Get more tools. I don't recall the exact menu tree but I am sure you
can google it.

After that, it's integrated into the System Preferences panel. You simply pick
which network conditions you want to simulate.

I think it's also possible to launch it from the xcode Utilities folder w/o
installation. Sorry I can't be more coherent w/o my machine in front of me.

------
sirn

        $ curl -I news.ycombinator.com
        HTTP/1.1 200 OK
        Content-Type: text/html; charset=utf-8
        Cache-Control: private
        Connection: close
    

Keep in mind that this will fire a HEAD request to the server which, depending
on web server you use in development, may not return the exact header you'd
get with GET (IIRC, Jetty used to do this).

I like to use something like this in such situation:

    
    
        $ curl -s -D /dev/stderr news.ycombinator.com >/dev/null

~~~
k33l0r
You can also use the -i option which prints out the headers _and_ the response
body (which is perhaps a bit too noisy).

    
    
        curl -i http://news.ycombinator.com

~~~
JonnieCache
or

    
    
        curl -v https://github.com
    

which dumps _everything._ Including, handily, the HTTPS handshake.

------
jasomill
Among (too) many other things, the OpenSSL "openssl" command does Base64
en/decoding, calculates MD5 and SHA* hashes, creates, displays, converts, and
verifies certificates, certificate chains, and CRLs, and even works as a
convenient "micro-CA" for testing purposes.

------
coderholic
I'm honoured that this post has made it to the front page a second time! Here
are the comments from the first time around:
<http://news.ycombinator.com/item?id=2880800>

------
bazzargh
That ngrep tool is pretty nifty. Has anyone done something like that with
dtrace? (I know about tcpsnoop - something at a higher level)

------
jessicard
If you're getting started with the command line, you might find helpful an
entire series on Quick Left's blog for beginners and experienced devs alike:
<http://quickleft.com/blog/tag/command-line>

------
ibotty
swaks is another very nice tool for email-testing (isn't email also part of
the web nowadays)

~~~
moreati
Cheers for that, will come in handy very soon. For those wondering

Deliver a standard test email, requiring CRAM-MD5 authentication as user
me@example.com. An "X-Test" header will be added to the email body. The
authentication password will be prompted for.

    
    
      swaks --to user@example.com --from me@example.com --auth CRAM-MD5 --auth-user me@example.com --header-X-Test "test email"

<http://linux.die.net/man/1/swaks>

------
justincormack
Being able to use DNS tools is a requirement too.

------
patrickod
Another alternative to ifconfig.me is icanhazip.com The main difference being
that icanhazip.com supports ipv6.

------
kooshball
if you use json a lot, this is super useful for prettifying stuff in command
line.

echo '{"foo": "lorem", "bar": "ipsum"}' | python -mjson.tool

------
easternmonk
ant ?

~~~
fsaintjacques
why?

