This command will start a simple SMTP server listening on port 1025 of localhost. This server simply prints to standard output all email headers and the email body.
In Python version 3, the module was merged into http.server. Gentlemen, change your aliases. Show Sample Output
You can use a site like http://www.jsonlint.com/ or use the command line to validate your long and complex json data. This is part of the simplejson package for python http://undefined.org/python/#simplejson.
Wrong json expression example:
echo '{ 1.2:3.4}' | python -m simplejson.tool
Expecting property name: line 1 column 2 (char 2)
Show Sample Output
Validates and pretty-prints the content fetched from the URL. Show Sample Output
They are using json now Show Sample Output
essentially the ruby one, but perhaps has a larger installed base
Convert JSON to YAML. Note that you'll need to have PyYaml installed.
A common programming question for interviewers to ask potential job candidates is to code "FizzBuzz". That is, if a number is divisible by 3, then it should display "Fizz". If a number is divisible by 5, it should display "Buzz". If it is divisible by both, then it should display "FizzBuzz". Otherwise, display the current number between 1 and 100. Show Sample Output
Converts YAML file to JSON. Note that you'll need to install PyYAML. Also some YAML data types (like dates) are not supported by JSON).
Replace 'csv_file.csv' with your filename.
This works on all versions of python 2.X. Tested on Linux and bundled python versions on Mac OSX and Solaris / UNIX Note: Serves globally on port 8000. Ctrl+c to stop. Don't start the server and leave it on a internet connected machine. :) Show Sample Output
on multihomed hosts, connected to several networks, could be usefull to know the source address (local ip address) used to reach the target host, this command does not require root priviledges. The command use a TCP socket, if there is any error the command return an empty string, elsewhere return a valid ip address. Show Sample Output
You have a python script that slowly prints output, you want to pipe the output to grep or tee, and you are impatient and want to watch the results right away. Rather than modify your script (making it slightly less efficient), use the -u option to have the output unbuffered.
You can use "decode()" in a similar manner:
python -c 'print "68656c6c6f".decode("hex")'
Show Sample Output
useful if you are using lots of data URI's in your css files
(1) required: python-googl ( install by: pip install python-googl ) (2) get from google API console https://code.google.com/apis/console/ Show Sample Output
I tried a few curses based mp3 players for playing back choir practice songs for my wife. Unfortunately none of the ones I tried were capable of scrubbing a track. Firefox saves the day.
This utilizes the Requests and BeautifulSoup libraries in Python to retrieve a user page on commandlinefu, parse it (error-tolerant) and extract all the lines of the following format: gzip * To print them, a list comprehension is used to iterate over the values, and join() is called on a newline character. Show Sample Output
You can specify various output formats, theme styles, etc.
python -m pygments -o source.png source.py
python -m pygments -o source.rtf source.py
Check available output formats, styles, etc.:
python -m pygments -L
Find pygments module here: http://pygments.org/
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: