Mac Osx pbcopy and pbpaste, provide copying and pasting to the pasteboard (the Clipboard) from command line, it does accept data from the standard input, so, you can find amazing uses for it
find . -name *txt | pbcopy
Mac Osx pbcopy and pbpaste, provide copying and pasting to the pasteboard (the Clipboard) from command line, it does accept data from the standard input, so, you can find amazing uses for it
find . -name *txt | pbcopy
mtimeit module provides a simple way to time small bits of Python code. It has both command line as well as callable interfaces. It avoids a number of common traps for measuring execution times. See also Tim Peters’ introduction to the “Algorithms” chapter in the Python Cookbook, published by O’Reilly.
the command line example:
python -mtimeit -s"from math import sqrt; x = 123" "x**.5"
the module example:
>>> import timeit >>> s = """\ ... try: ... str.__nonzero__ ... except AttributeError: ... pass ... """ >>> t = timeit.Timer(stmt=s) >>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000) 17.09 usec/pass >>> s = """\ ... if hasattr(str, '__nonzero__'): pass ... """ >>> t = timeit.Timer(stmt=s) >>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000) 4.85 usec/pass
Home made circuit boards
That’s amazing and easy =)
Decoding as dictionary an ajax form uri with magic and lambda
# Don't thouch this shit
def urldecode(url):
x = {}
map(lambda dt: x.update(dt), map(lambda word: {word[0] : \
word[1]}, map(lambda param: param.split('='),re.compile( \
'%([0-9a-hA-H][0-9a-hA-H])',re.M).sub(lambda m: chr(int( \
m.group(1),16)),url.replace('+', ' ')).decode("utf-8").split('&'))))
return x
as you can see, my comment denotes it as a badsmellstuff
Previously accessed ssh servers bash completion put it under .bashrc or .bash_profile [mac]
SSH_COMPLETE=( $(cat ~/.ssh/known_hosts | \
cut -f 1 -d ' ' | \
sed -e s/,.*//g | \
uniq ) )
complete -o default -W '${SSH_COMPLETE[*]}' ssh
Enabling grep coloring, put it under .bashrc or .bash_profile on mac
alias grep='GREP_COLOR="1;33;40" LANG=C grep --color=auto'
Sums a column of numbers starting at point
(defun sum-column()
"Sums a column of numbers starting at point"
(interactive)
(save-excursion
(if (and (not (= (current-column) 0))
(re-search-backward "[ \t]" 0 t ))
(forward-char))
(let ((retn 0)
(old-column (current-column))
(old-next-line-add-newlines))
(setq next-line-add-newlines nil)
(while (not
(looking-at "^[ \t]*$"))
(move-to-column old-column t)
(if (and (looking-at "-?[0123456789]+")
(eq (current-column) old-column))
(setq retn (+ retn (string-to-number (current-word)))))
(next-line)
(beginning-of-line))
(next-line)
(next-line)
(move-end-of-line 0)
(insert (make-string (- old-column (current-column)) 32))
(insert (number-to-string retn))
(setq next-line-add-newlines old-next-line-add-newlines)
retn)))
Simple and fast gpg crypt
fmeyer@fnandomac ~/projects/canivete $ gpg -c gpg.txt
Just happened on my team:
Developer : I have installed the full adobe software package on my Macbook, so I’m a better designer than you.
Designer: I have mysql and python on my laptop, so I’m a developer as you.
I always forget the amazing rsync between a remote and my local disk
rsync -avz -e ssh remoteuser@remotehost:/remote/dir /this/dir/