Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
from django.contrib.auth.decorators import login_required
from django.utils.cache import patch_response_headers
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page, never_cache
from django.views.decorators.csrf import csrf_exempt
class NeverCacheMixin(object):
@method_decorator(never_cache)
import datetime
import simplejson as json
import subprocess
def setClipboardData(data):
p = subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE)
p.stdin.write(data.encode('utf-8'))
p.stdin.close()
retcode = p.wait()
is_crackle_worthy = lambda n: n % 3 == 0
is_pop_worthy = lambda n: n % 5 == 0
for i in range(1, 100 + 1):
should_crackle = is_crackle_worthy(i)
should_pop = is_pop_worthy(i)
if should_crackle & should_pop:
print('{:03d}.....CracklePop'.format(i))
@SimplyAhmazing
SimplyAhmazing / gist:3eb2089ff1c04e58e789
Last active August 29, 2015 14:10
Solution for Code Kata # 18
import collections
from pprint import pformat
{
'A': ['B', 'C'],
'B': ['C', 'E'],
}
class Dependencies(object):
import asyncio
import multiprocessing
import os
from concurrent.futures import ThreadPoolExecutor
@asyncio.coroutine
def coro_get(q):
loop = asyncio.get_event_loop()
from opentrons_sdk.labware import containers, instruments
# Deck declarations
"""
Deck is a singleton behind the scenes that registers containers
and validates errors such as impromper allocation and inferences
loading of yaml/json files based on attribute names.
"""
protocol = Protocol()

Below is a class decorator did_you_mean that will, when applied to a class, catch undefined methods on that class and return y ou a recommendation of methods to call instead.

from fuzzywuzzy.process import extractOne


def get_class_methods(cls_instance):
    return [name for name in dir(cls_instance) if not name.startswith('__')]
import copy
from pprint import pprint as pp
def Memento(obj, deep=False):
state = (copy.copy, copy.deepcopy)[bool(deep)](obj.__dict__)
def Restore():
obj.__dict__.clear()
obj.__dict__.update(state)
@SimplyAhmazing
SimplyAhmazing / list-ot-builds.py
Created November 10, 2016 16:05
get latest n builds from ot-app-builds
import os
import boto
import boto.s3.connection
access_key = os.environ.get('AWS_ACCESS_KEY_ID')
secret_key = os.environ.get('AWS_SECRET_ACCESS_KEY')
------------------------------ MAC BUILDS ------------------------------
Build #1
https://s3.amazonaws.com/ot-app-builds/mac/OpenTrons-v1.99.99-Darwin64_2016-11-07_19.09_20161104-170000-fix-windows-integration-test_e9e2bca5fd.zip
--------------------------------------------------------------------------------
Build #2
https://s3.amazonaws.com/ot-app-builds/mac/OpenTrons-v1.99.99-Darwin64_2016-11-07_18.42_20161106-adding-linux-support_9eeddd6b03.zip
--------------------------------------------------------------------------------
Build #3
https://s3.amazonaws.com/ot-app-builds/mac/OpenTrons-v1.99.99-Darwin64_2016-11-07_18.33_20161104-170000-fix-windows-integration-test_e56124f857.zip
--------------------------------------------------------------------------------