Handy One-Liners

Thursday, March 18th, 2010 | code, development, nerdery, python, tips

It’s been a while since I’ve posted, so I figured I’d just go with something that I found to have been pretty useful as of late. Peteris Krumins recently posted a great article about one-liners, so I figured I’d add a few of my own to that list:

  1. Python SMTP Server

    python -m smtpd -n -c DebuggingServer localhost:1025

    This just starts an email consumer on your localhost on port 1025. When emails are sent to it, they are echoed to STDOUT instead of being routed. Handy when developing features that require email.

  2. Git Graph ‘Pretty Print’

    git log --graph --abbrev-commit --pretty=oneline --decorate

    This really just serves as a replacement to gitk or GitX in a (command-line) pinch.

  3. Remove .pyc

    find . -name '*.pyc' -exec rm {} \;

    Does just what you’d think it does: removes all .pyc files from the current directory you are in.

These are all pretty much just great candidates for bash aliases, but I figured I’d share since I was inspired. Thanks Peteris, and if you haven’t checked out his article, do so IMMEDIATELY:

Top Ten One-Liners from CommandLineFu Explained

Share The Wealth:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Reddit
  • Slashdot
  • StumbleUpon

Tags: , ,

3 Comments to Handy One-Liners

Peteris Krumins
March 19, 2010

I love the first one-liner! Didn’t know there was a module for running SMTP server so easily via Python.

I will definitely include it in some future one-liners article.

Thanks!

Peteris

Peteris Krumins
April 21, 2010

I have now written about this one-liner. Included it as a “bonus one-liner” in my latest post:

Another 10 One-Liners From CommandLineFu Explained.

Peteris

evan
April 21, 2010

Awesome! I actually saw it when it hit hacker news. Good stuff man. Keep it up.

Leave a comment