Skip to content

Instantly share code, notes, and snippets.

View rikva's full-sized avatar

Rik rikva

  • Self-Employed
  • The Netherlands
View GitHub Profile
export PS1="[\t] \[$(tput sgr0)\]\[\033[38;5;11m\]\u\[$(tput sgr0)\]\[\033[38;5;15m\]@\h:\[$(tput sgr0)\]\[\033[38;5;6m\][\w]:\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]"
# Virtualenv
export WORKON_HOME=~/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
## Use a long listing format ##
alias ll='ls -la'
@rikva
rikva / gist:8935098
Created February 11, 2014 13:46
Python multiprocessing example
import multiprocessing
import logging
import subprocess
from django.core.management.base import BaseCommand
import time
from products.models import ProductFeed
log = logging.getLogger('xxx.fetcher')
log.info('Starting feed parser')
@rikva
rikva / gist:4585800
Created January 21, 2013 12:47
Date generator for simple backup rotation
from datetime import date, timedelta
KEEP_DAYS = 7
KEEP_WEEKS = 4
KEEP_MONTHS = 6
today = date.today()
def calculate_daily_days():
return [today - timedelta(days=day) for day in range(0, KEEP_DAYS)]
@rikva
rikva / kamertje_spider.py
Created May 21, 2012 09:08
Don't Judge This Code
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.selector import HtmlXPathSelector
from kamertje.items import KamertjeItem
import sqlite3 as sqlite
from scrapy import log
class KamertjeSpider(CrawlSpider):
name = "kamertje"
allowed_domains = ["www.kamertje.nl", "kamertje.nl"]
@rikva
rikva / nrcnextfetch.py
Created April 24, 2012 09:50
Simpel Python script om de huidige NRC Next PDF te downloaden en te openen (voor NRC Next abonnees)
#!/usr/bin/env python
from sys import argv, exc_info
from mechanize import Browser
from datetime import datetime
from subprocess import call
pdfreader = '/usr/bin/okular'
if len(argv) == 3: