232 points · by countessa · 14y ago · 68 comments
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... cmdfu(){ wget -qO - "http://www.commandlinefu.com/commands/matching/$@/$(echo -n "$@" | openssl base64)/plaintext"; }
It's like man but for one-liners.$(<command>) gets replaced by the output of <command>, in our case that means the output of the openssl base64 call, which takes stdin, applies the base64 encoding and prints it out on stdout. echo -n $@ just serves to translate our parameters into something the openssl base64 call can work with (-n means it won't introduce a superfluous newline). I'm not sure why the script uses openssl base64 instead of just base64 (a GNU coreutils utility).
I agree with the sibling that the API requirement to include both verbatim and base64-encoded search terms are fairly bizarre.
[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.
$ echo 'test' | openssl base64
dGVzdAo=
Which is the same as: $ echo 'test' | base64
dGVzdAo=
The URL is the same as: args="$@"
b64=$(echo -n "$@" | openssl base64)
url="http://www.commandlinefu.com/commands/matching/$args/$b64/plaintext"
For these purposes though, "$@" could probably be replaced with "$*". Technically the URL is invalid since "$@" could introduce non-escaped spaces into the URL.A little bit of shell scripting goes a long way in automating away dev work.
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.
Folks who did not grow up touch typing, though, simply learned to construct a longer-lasting mental model, which they can then write out however slowly. Think of it as a bigger buffer. In rare cases it can become enormous, and people write entire novels in their head before ever putting ink on paper (famous example: "The Diving Bell and the Butterfly", which was written at a rate of about one word every 2 minutes).
Or, they learned to create and capture design decisions in higher-density media (like diagrams or pseudocode), which, again, can then be typed in more slowly.
It's probably much better to judge developers by the quality of their output than how fast they type--especially since most software spends way longer in production and maintenance than it does being developed.
If someone watched me on Visual Studio without letting me install Viemu first, I'd look like an idiot.
Rare are the ones who know how to use these basic commandline tools.
The last time I've shown ngrep to a sysadmin he was like "omagad amazing" - always feels nice :)
But, that's not really an obscure tool. I initially thought everyone knew that, like most know nmap.
Turns out most know nmap and ssh because they're really that well known (generally they don't know most options)
Makes me sad! Command's line easy and fun!
> python -m SimpleHTTPServer
> 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 ...> php -S localhost:8080
> python -m SimpleHTTPServer 5000
$ sudo python -m smtpd -n -c DebuggingServer localhost:25Even 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.
$ http GET http://yourmom.ca/
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.
$ 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 curl -i http://news.ycombinator.com curl -v https://github.com
which dumps everything. Including, handily, the HTTPS handshake. $ curl -s does.not.exist; echo $?
6
$ curl -sS does.not.exist; echo $?
curl: (6) Couldn't resolve host 'does.not.exist'
6
$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/swaksecho '{"foo": "lorem", "bar": "ipsum"}' | python -mjson.tool