This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
import redis | |
from django.db import DEFAULT_DB_ALIAS | |
from django.db.models import Q, signals as db_signals | |
from piston.models import Consumer, Token | |
from piston.store import DataStore as PistonDataStore | |
from mirrio.api._redis import redis | |
redis = redis.Redis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// adding to a potentially non-existent counter column | |
Mutator<String> m2 = HFactory.createMutator(ServiceDescriptor.keyspace(), StringSerializer.get()); | |
m2.addCounter(indexRowKey, "streamidx", HFactory.createCounterColumn(indexColKey, 1, StringSerializer.get())); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mutator<String> m1 = HFactory.createMutator(ServiceDescriptor.keyspace(), StringSerializer.get()); | |
m1.addInsertion(seriesRowKey, "StreamTS", HFactory.createColumn(id, item.getType().getName(), | |
UUIDSerializer.get(), StringSerializer.get())); | |
m1.execute(); // incompatible class change error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The author disclaims copyright to this source code. In place of a legal | |
# notice, here is a blessing: | |
# | |
# May you do good and not evil. | |
# May you find forgiveness for yourself and forgive others. | |
# May you share freely, never taking more than you give. | |
import hashlib, cPickle as pickle, logging | |
from django.db.models import signals as db_signals | |
from django.core.cache import cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db.models import Q | |
from django.contrib.auth.models import User | |
from django.contrib.auth.backends import ModelBackend | |
from piston.authentication import (OAuthAuthentication as | |
PistonOAuthAuthentication, send_oauth_error) | |
from piston import oauth | |
from model_cache import ModelCache | |
user_cache = ModelCache(User) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The author disclaims copyright to this source code. In place of a legal | |
# notice, here is a blessing: | |
# | |
# May you do good and not evil. | |
# May you find forgiveness for yourself and forgive others. | |
# May you share freely, never taking more than you give. | |
# | |
# It is based on a snipped found in this project: | |
# https://github.com/martinblech/mimerender |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lenny.handler import BaseHandler | |
from lightt.api.db.series import Series | |
class SeriesHandler(BaseHandler): | |
""" | |
Documentation that will be generated for /series | |
""" | |
name = 'series' # urls can be automatically generated | |
version = 1.2 # version is selected via Accept header |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""Counts all the lines from a directory inward.""" | |
import os | |
import os.path | |
import sys | |
lines = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import newrelic.api.function_trace | |
def instrument_pycassa_connection(module): | |
newrelic.api.function_trace.wrap_function_trace( | |
module, 'Connection.__init__') | |
_cf_methods = ['xget', 'get', 'get_indexed_slices', 'multiget', 'get_count', | |
'multiget_count', 'get_range', 'insert', 'batch_insert', | |
'add', 'remove', 'remove_counter', 'truncate'] |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def random_words(num, separator='-'): | |
""" | |
Return `num`-random concatinated to each other. | |
They will be joined by `separator` | |
""" | |
words = [] |