Skip to content

Instantly share code, notes, and snippets.

Working from home

Pavel Katsev p7k

Working from home
View GitHub Profile
View gist:838884
def parse_event(self, response):
# self.log('Hi, this is an event page! %s' % response.url)
hxs = HtmlXPathSelector(response)
event_view_div ='//div[@class="event_view"]')
event = Event()
event_loader = XPathItemLoader(event, event_view_div)
View gist:945012
elif isinstance(value, (int, long)):
model = self.fk_resource._meta.object_class
obj = model.objects.get(pk=value)
except (model.DoesNotExist, model.MultipleObjectsReturned):
raise ApiFieldError("Could not find the provided object via PK '%s'." % value)
return self.fk_resource.full_dehydrate(obj)
p7k /
Created Aug 4, 2011 — forked from juniorz/
Installing PostGIS on Mac OS X and Ubuntu
# Some good references are:
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
p7k / gist:1246408
Created Sep 27, 2011
rrule converter
View gist:1246408
from dateutil import parser, rrule
class BaseArgConverter(object):
def convert_value(self, value):
"""convert either a single value or sequence"""
sequence = value.split(',')
if len(sequence) > 1:
return map(self._convert_value, sequence)
return self._convert_value(value)
p7k /
Created Dec 14, 2011 — forked from klipstein/
Base64 file handling for django-tastypie
import base64
import os
from tastypie.fields import FileField
from django.core.files.uploadedfile import SimpleUploadedFile
class Base64FileField(FileField):
A django-tastypie field for handling file-uploads through raw post data.
It uses base64 for en-/decoding the contents of the file.
p7k /
Created Mar 31, 2012 — forked from erikh/
OSX For Hackers
#!/usr/bin/env sh
# This is script with usefull tips taken from:
# install it:
# curl -sL | sh
p7k / gist:4238388
Created Dec 8, 2012
greenlet throttling decorator | rate limiting gevent | with semaphores
View gist:4238388
from functools import wraps
from timeit import default_timer
import gevent
from gevent.queue import Queue
def gevent_throttle(calls_per_sec=0):
"""Decorates a Greenlet function for throttling."""
interval = 1. / calls_per_sec if calls_per_sec else 0
def decorate(func):
blocked = [False] # has to be a list to not get localised inside the while loop
p7k /
Last active Dec 27, 2015
a random dictator for ivan's experimental performance
#!/usr/bin/env python
# adjust these params
KNOBS = ['phase', 'flange', 'delay']
ACTIONS = [('up', 45), ('down', 45), (' decide..', 10)]
DELAY_MIN = 1 # seconds
DELAY_MAX = 3 # seconds
p7k /
Created Feb 10, 2017 — forked from burke/
This sets up keybindings in tmux that allow you to copy/paste to/from your OS X clipboard from tmux running inside an SSH connection to a remote host. Partially borrowed from

Local (OS X) Side


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">
p7k / tmux.conf
Created Feb 10, 2017 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
View tmux.conf
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000