Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Pavel Katsev p7k

🏠
Working from home
View GitHub Profile
View trf2bed.py
"""Translate a Tandem Repeat Finder file into a bed file containing
annotated repeat intervals.
> This file is a text file which contains the same information, in the same
order, as the summary table file, plus consensus pattern and repeat sequences
http://tandem.bu.edu/trf/trf.definitions.html#table
"""
from __future__ import division
@p7k
p7k / voluptuous.xor.py
Created May 23, 2018
xor gate in voluptuous
View voluptuous.xor.py
def xor(fields, group_name):
"""Creates an Exclusive OR (XOR) logical gate voluptuous schema.
see https://github.com/alecthomas/voluptuous/issues/126
:param fields: fields comprising the exclusive group.
:type fields: Dict[str, Schema]
:param group_name: exclusive group identifier.
:type group_name: str
:returns: XOR gated voluptuous schema.
@p7k
p7k / __init__.py
Last active Feb 12, 2017
recipe as script simple sketch
View __init__.py
import argparse
import functools
import inspect
import json
import sys
def recipe_inputs(schema, kw='inputs'):
def decorator(recipe_func):
@functools.wraps(recipe_func)
@p7k
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
@p7k
p7k / remotepaste.md
Created Feb 10, 2017 — forked from burke/remotepaste.md
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 http://seancoates.com/blogs/remote-pbcopy
View remotepaste.md

Local (OS X) Side

~/Library/LaunchAgents/pbcopy.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
     <key>Label</key>
     <string>localhost.pbcopy</string>
@p7k
p7k / ivanescence.py
Last active Dec 27, 2015
a random dictator for ivan's experimental performance
View ivanescence.py
#!/usr/bin/env python
# adjust these params
KNOBS = ['phase', 'flange', 'delay']
ACTIONS = [('up', 45), ('down', 45), ('..you decide..', 10)]
DELAY_MIN = 1 # seconds
DELAY_MAX = 3 # seconds
@p7k
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
p7k / hack.sh
Created Mar 31, 2012 — forked from erikh/hack.sh
OSX For Hackers
View hack.sh
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@p7k
p7k / b64field.py
Created Dec 14, 2011 — forked from klipstein/b64field.py
Base64 file handling for django-tastypie
View b64field.py
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.
Usage:
@p7k
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)