Skip to content

Instantly share code, notes, and snippets.

View ishikawa's full-sized avatar
🏠
Working from home

Takanori Ishikawa ishikawa

🏠
Working from home
View GitHub Profile
@ishikawa
ishikawa / runtests.py
Created August 31, 2010 16:36
runtests.py: (unit|doc)test discovery
#!/usr/bin/env python
"""
The **runtests.py** script supports simple test discovery (both `doctest`_ and `unittest`_)
and running discovered tests.
* ``-s DIRECTORY`` Directory to start discovery ('.' default)
* ``-t DIRECTORY`` Top level directory of project (default to start directory)
How to use::
@ishikawa
ishikawa / iterate_recursively.py
Created August 28, 2010 03:19
iterate_recursively: flatten a list easily
def iterate_recursively(*objects):
"""
Makes an iterator that returns elements from the `objects` argument.
If an element is a list or tuple, the element will be iterated
recursively, and the iterator returns each items.
>>> list(iterate_recursively(1, 2, 3))
[1, 2, 3]
>>> list(iterate_recursively([1, 2, 3]))
[1, 2, 3]
@ishikawa
ishikawa / colorize.py
Created August 18, 2010 14:48
"colorize" - The tiny module which provides ANSI color formatting
"""
This tiny module provides ANSI color formatting.
ANSI escape code - Wikipedia, the free encyclopedia
http://en.wikipedia.org/wiki/ANSI_escape_code
>>> colorize("")
''
>>> colorize("black and white")
'black and white'
@ishikawa
ishikawa / itunes.sh
Created April 4, 2010 09:04
itunes.sh - control your iTunes from shell
#/bin/bash
#
# itunes.sh - Control Your iTunes from shell
#
TRACK_PROGRAM=`cat <<EOS
tell current track
name & " - " & artist
end tell
EOS`
@ishikawa
ishikawa / objcfmt.py
Created March 13, 2010 11:28
The code formatter for Objective-C source programs.
#!/usr/bin/env python
# vim: set filetype=python :
"""
Synopsis
================================
*objcfmt* is the code formatter for Objective-C source programs.