Skip to content

Instantly share code, notes, and snippets.

@yaph
yaph / Top City Names Word Cloud.md
Last active December 19, 2015 06:49
Word cloud from words in top 100 city names.
@yaph
yaph / monitor-server-connections.sh
Last active December 21, 2015 08:59
monitor server connections
# count port 80 connections
netstat -alpen | grep -c :80
# watch connections, refresh every 5 seconds
sudo watch -n5 -d 'netstat -alpen | grep -c :'
@yaph
yaph / grep-through-python.sh
Created August 27, 2013 13:12
More effective grepping through Python projects code
grep --exclude=*.{pyo,pyc,txt} -r STRING
@yaph
yaph / ula2json.js
Created October 24, 2013 20:14
Convert an HTML ul list of links to a JSON list of objects with href and text content.
var list = [];
$('ul a').each(function(idx, item){
list.push({
href: $(item).attr('href'),
text: item.textContent
});
});
JSON.stringify(list, null, " ");
@yaph
yaph / wikicsv.sh
Last active December 30, 2015 15:49
DBpedia/Wikipedia CSV manipulation
# DBpedia table
csvcut -c 2 Film.csv | sed -e 's/(.*)$//' > film-titles.txt
# wikitables CSV
csvcut -c 1 List_of_Academy_Award-winning_films.csv | sed -e 's/(.*)//' | sed -e 's/\"//g' > film-titles.txt
# fix names
sed -e 's/|.*}//g' -e 's/{//' -i datasets/populated-places-locations.csv
@yaph
yaph / arachni-basic-usage.sh
Created January 22, 2014 11:59
Basic arachni usage commands
# scan up to 1000 URLs
arachni --link-count=1000 --report=afr:outfile=domain.tld.html http://domain.tld
# convert existing afr report to html
arachni --repload=domain.tld.afr --report=html:outfile=domain.tld.html
@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 {} \;