Skip to content

Instantly share code, notes, and snippets.

View gaving's full-sized avatar
🎯
Focusing

Gavin Gilmour gaving

🎯
Focusing
View GitHub Profile
reduce( lambda x, y: x + y, [ reduce( lambda x, y: x + y, [ ( j + 1 ) * ( ord( i ) - 64 ) for i in x[ j ] ] ) for j in xrange( len( x ) ) ] )
#!/bin/sh
cp_p()
{
strace -q -ewrite cp -- "${1}" "${2}" 2>&1 \
| awk '{
count += $NF
if (count % 10 == 0) {
percent = count / total_size * 100
printf "%3d%% [", percent
for (i=0;i<=percent;i++)
a.tag {
display: block;
float: left;
height: 19px;
padding: 0 2px 0 0;
background: url(http://cdn.last.fm/flatness/icons/tag/1/globaltag_right.png) no-repeat right top;
color: #fff;
font-size: 11px;
text-decoration: none;
vertical-align: middle;
if which pbpaste > /dev/null; then
# build git clone command from clipboard
git-clone-clipboard() {
REPO_URL="$(pbpaste)"
REPO_BASE_NAME=${$(basename $REPO_URL)%.git}
LBUFFER="nocorrect git clone $REPO_URL $REPO_BASE_NAME"
}
zle -N git-clone-clipboard
bindkey "^Xg" git-clone-clipboard
fi
var string = (<r><![CDATA[
The text string goes here. Since this is a XML CDATA section,
stuff like <> work fine too, even if definitely invalid XML.
]]></r>).toString();
#!/bin/bash
# clear the screen
tput clear
# Move cursor to screen location X,Y (top left is 0,0)
tput cup 3 15
# Set a foreground colour using ANSI escape
tput setaf 3
Function.prototype.delay = function(s){ setTimeout(this, s*1000); };
Date.prototype.addDays = function(days){ return new Date(this.getTime() + (days*1000*60*60*24)); }
http://www.zsh.org/mla/users/2003/msg00167.html
zcalc () { print $(( ans = ${@:-ans} )) }
set wildignore+=*.o,*.r,*.class,*.pyc,*.so,*.sl,*.tar,*.tgz,*.gz,*.dmg,*.zip,*.pdf,CVS,.svn,.git,CVS/,.svn/,.git/
require 'rake/clean'
require 'rake/testtask'
require 'fileutils'
require 'date'
def stop_error(message)
puts "ERROR: #{message}"
exit(1)
end