Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / Top City Names Word Cloud.md
Last active December 19, 2015 06:49
Word cloud from words in top 100 city names.
@yaph
yaph / download-jpg.sh
Last active November 1, 2022 11:20
Extract all URLs to jpg files from text file with grep and download images with wget
grep -shoP 'https?.*?\.jpg' rss.xml | xargs wget
@yaph
yaph / search-gh-user-commits.bq
Created May 22, 2013 15:24
Sample query to search for SEARCH in the public commit timeline of GITHUB_LOGIN using the GitHub Archive dataset on Google's Big Query service.
SELECT actor, payload_commit_msg, repository_language FROM [publicdata:samples.github_timeline]
WHERE actor == 'GITHUB_LOGIN' AND payload_commit_msg != ''
AND REGEXP_MATCH(payload_commit_msg, r'(?i)SEARCH')
@yaph
yaph / checkboxes.js
Last active October 27, 2023 19:14
Check or uncheck all check boxes using browser JavaScript console
# JS snippet for email notification settings, e. g. Twitter
cb=document.querySelectorAll('input[type="checkbox"]');for(i in cb){cb[i].checked=false}
# for Drupal 4.x comment approval form
cbx=document.getElementsByClassName('form-checkbox');for(i in cbx){cbx[i].checked=true}
@yaph
yaph / forbes-most-powerful-people-names.js
Created March 13, 2013 21:28
Get a list of names of the worlds most powerful people according to Forbes Magazine http://www.forbes.com/powerful-people/list/
var names = [];
$('.company h3').each(function(idx, item){names.push(item.innerHTML.replace(' & family', ''))});
var routes = [];
var route = {};
$('.datenhellgrau td').each(function(idx, item){
if ('sp1_1' == $(item).attr('headers')) {
route = {};
route['name'] = $(item).text();
}
else if ('sp1_2' == $(item).attr('headers')) {
route['gpx'] = $($(item).find('.download a')[0]).attr('href')
.replace('../../download/gps_tracks/', '/gpx/');
@yaph
yaph / xfce4-terminal-laptop.sh
Created February 21, 2013 12:49
Launch xfce4-terminal on laptop with given width and height.
xfce4-terminal --geometry=170x22
@yaph
yaph / archive_dirs.sh
Created February 15, 2013 20:06
Create a tar archive for all directories in current director.
ls -d * | xargs -i tar czf "{}.tgz" {}