Skip to content

Instantly share code, notes, and snippets.

View alekseyev's full-sized avatar

Oleksii Aleksieiev alekseyev

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
</head>
<body>
<div class="container">
@alekseyev
alekseyev / fabfile.py
Created October 3, 2013 14:23
Fabric script to transfer DB dump from remote server
import os
import json
import time
from fabric.api import local, run, cd, env, task
from fabric.operations import get
from fabric.context_managers import cd, prefix
from settings import DATABASES, MEDIA_ROOT
@alekseyev
alekseyev / odm.py
Last active December 24, 2015 04:38
Simple Mongo ODM
from somewhere import get_mongo_db
# assuming get_mongo_db returns db instance
class MongoException(Exception):
pass
class MongoField(object):
pass
@alekseyev
alekseyev / futures.py
Last active December 21, 2015 05:28
Concurrency in Python 3
# Source: http://firepear.net/docs/python3-futures-2.html
from concurrent.futures import ThreadPoolExecutor
import random
import time
def sleep_until_the_future(**kwargs):
kwargs['launchtime'] = time.time()
time.sleep(kwargs['sleeptime'])
return kwargs