Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / bootstrap-custom-modal-site.css
Created February 6, 2013 11:38
Custom sized Twitter bootstrap modal windows, based on http://stackoverflow.com/a/10513686/291931
.modal {
width:38%; /* desired relative width */
left:31%; /* (100%-width)/2 */
height:56%; /* desired relative height */
top:22%; /* (100%-height)/2 */
margin:auto; /* place center */
}
@yaph
yaph / bootstrap-highlight-active-links.js
Created February 1, 2013 22:04
Highlight active links in navigation menus of Twitter bootstrap based pages.
@yaph
yaph / feedparser_django_datetime.py
Last active August 1, 2019 13:24
A snippet that shows how to convert a feedparser time.struct_time object to a Django datetime with timezone support.
from django.utils import timezone
import time
# feed = object from DB
# doc = parsed feedparser object
feed.updated_at = doc.feed.get('updated_parsed', timezone.now())
if isinstance(feed.updated_at, time.struct_time):
feed.updated_at = timezone.make_aware(
timezone.datetime(*feed.updated_at[:-3]),
@yaph
yaph / pgsql_commands.sh
Last active December 11, 2015 20:49
Frequently used commands when working with postgresql databases on Ubuntu, like creating and deleting databases and users. https://help.ubuntu.com/community/PostgreSQL
# create user and database with user as admin
sudo -u postgres createuser -D -A -P uname
sudo -u postgres createdb -O uname dbname
# delete database and user
sudo -u postgres dropdb dbname
sudo -u postgres dropuser uname
# dump and import data
pg_dump --clean -U uname dbname > dump.sql
@yaph
yaph / uncheck.js
Created January 21, 2013 12:28
Uncheck all checkboxes on a page using jQuery.
$('input').each(function(){$(this).attr('checked', false)})
@yaph
yaph / citysearch.py
Created December 6, 2012 18:46 — forked from vlandham/citysearch.py
Search where people are moving in Germany
# coding: utf-8
# requires: pattern http://www.clips.ua.ac.be/pages/pattern
from pattern.web import *
import csv
import itertools
# engine = Google(license='XXX', throttle=2.0)
#engine = Twitter(license=None)
engine = Bing()
@yaph
yaph / tunnel.sh
Created December 4, 2012 23:12
aliases for creating and killing an ssh tunnel using sshuttle
# http://coding.smashingmagazine.com/2012/10/29/powerful-command-line-tools-developers/
alias tunnel='sshuttle -D --pidfile=/tmp/sshuttle.pid -r <server> --dns 0/0'
alias stoptunnel='[[ -f /tmp/sshuttle.pid ]] && kill `cat /tmp/sshuttle.pid`'