Skip to content

Instantly share code, notes, and snippets.

@yaph
yaph / migrate_disqus.py
Created February 6, 2013 21:26
Python script to map old to new URLs for migrating Disqus threads.
# coding: utf-8
import pandas as pd
def fix(url):
# remove www subdomain
url = url.replace('://www.', '://')
# add slash if URL doesn't end with .html
if not url.endswith('html'):
url = url.rstrip('/') + '/'
return url
@yaph
yaph / favicon.sh
Created February 7, 2013 21:08
Create a favicon from a PNG file using the command line tool icotool, see http://www.nongnu.org/icoutils/ for documentation.
icotool -o favicon.ico -c favicon.png
@yaph
yaph / Ubuntu_post_install.sh
Last active February 15, 2021 22:49
Ubuntu post install scripts
sudo apt-get install abiword chromium-browser gimp gftp icoutils keepassx python-gpgme ssh xclip
# drivers
sudo apt-get install brother-lpr-drivers-extra
# dev
sudo apt-get install curl git gitk htop phantomjs python-pip mysql-server r-base vim
# Apache
sudo apt-get install apache2 libapache2-mod-fcgid
@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" {}
@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
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 / 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', ''))});
@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 / 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 / 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