Skip to content

Instantly share code, notes, and snippets.

@yaph
yaph / README.md
Last active August 29, 2015 13:57 — forked from mbostock/.block
Fork of mbostock's coastal counties map

This map shows the graph distance of each county from the Pacific or Atlantic coast; it is a recreation of a map posted to /r/dataisbeautiful using TopoJSON. Coastal counties are dark blue, while counties nine or more counties away from the coast are light yellow. (I opted not to reuse the original’s cycling color scale.)

See also the underlying graph.

@yaph
yaph / ubuntu-printer-pains.sh
Created April 9, 2014 12:48
Trying to get a Brother DCP-135C to work on Ubuntu 13.10
sudo apt-get purge brother-lpr-drivers-extra
sudo apt-get autoremove
sudo dpkg -i dcp135clpr-1.0.1-1.i386.deb
sudo mkdir ls /var/spool/lpd
sudo dpkg -i dcp135ccupswrapper-1.0.1-1.i386.deb
@yaph
yaph / vat-reverse
Created April 10, 2014 11:18
Calculate initial amount from final amount for VAT calculation
no_vat = final_amount * 100 / 119
@yaph
yaph / update-python-envs.sh
Last active August 29, 2015 14:00
Update distribute and all Python virtualenvs in current directory
sudo easy_install -U distribute
find . -type d -maxdepth 1 -exec virtualenv {} \;
@yaph
yaph / gist:134894
Created June 23, 2009 22:33
create a query string from a dictionary (pquery) as returned from cgi.parse_qs / urlparse.parse_qs when urllib.urlencode is not appropriate
# create a query string from a dictionary (pquery) as returned from
# cgi.parse_qs / urlparse.parse_qs when urllib.urlencode is not appropriate
query_string = '&'.join(
'='.join([key, pquery[key][0]]) for key in pquery
)
@yaph
yaph / Generic .htaccess redirect from www to non-www
Created August 6, 2010 09:08
Generic .htaccess redirect from www to non-www
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
</IfModule>
@yaph
yaph / alexa keyword url
Created December 18, 2010 16:36
get a list of full URLs from Alexa Top 1M pages that match given keyword
grep -r keyword alexa_top-1m.csv | perl -pe 's/^d+,/http:\/\//'
@yaph
yaph / gist:825091
Created February 13, 2011 20:34
Generic .htaccess redirect from non-www to www
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
@yaph
yaph / bundle install call
Created May 23, 2011 15:53
install ruby packages using bundler
sudo /var/lib/gems/1.8/bin/bundle install
@yaph
yaph / git_copy_changed.sh
Created July 7, 2011 20:31
copy changed files in git repo to target directory, paths are not retained
git diff --name-only | xargs -I {} cp {} /target_dir