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
# Search usernames that begins with given phrase | |
# | |
# usernames: (username1, username2, ..) | |
# userscore:<username>: float | |
# user:obj: { id: int, username: string } | |
usernames_zset = "usernames" | |
def my_ord(c): | |
return "%03d" % ord(c) |
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 os | |
from behaving import environment as benv | |
from splinter import Browser | |
default_browser = Browser() | |
PERSONAS = {} | |
def _mkdir(path): | |
return os.makedirs(path) if not os.path.exists(path) else None |
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 json | |
import requests | |
API_KEY = '' | |
PROJECT_ID = '' | |
COLLECTION_NAME = '' | |
filters = [{'property_name': 'keen.timestamp', 'operator': 'eq', 'property_value': '2015-02-02T10:20:00.000'}] | |
resp = requests.delete('https://api.keen.io/3.0/projects/' + PROJECT_ID + '/events/' + COLLECTION_NAME +'?api_key=' + API_KEY + '&filters=' + json.dumps(filters)) |
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 os | |
import hashlib | |
import sys | |
from pathlib import Path # python < 3.4 : pip install pathlib | |
def md5(path): | |
content = path.open('br').read() | |
return hashlib.md5(content).hexdigest() |
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 json | |
import pickle | |
import msgpack | |
TEST_REDIS = False | |
if TEST_REDIS: | |
import redis | |
rconn = redis.StrictRedis() | |
dataset = [(('key:%d' % i), {'a': 1, 'b': list(range(100)), 'c': ('z' * 25)}) for i in range(1000000)] |
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 fastapi import FastAPI | |
from pydantic import BaseModel | |
class Item(BaseModel): | |
name: str | |
class CreateSignature(BaseModel): | |
id: int |
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
# - hug version: 2.4.7 | |
# - marshmallow: 3.0.0rc4 | |
# - Python: 3.6.7 on Ubuntu 18.10 | |
import hug | |
from marshmallow import Schema, fields | |
class ItemSchema(Schema): | |
name = fields.Str() | |
id = fields.Int() |
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 | |
from dataclasses import dataclass | |
NO_OF_DOORS = 3 | |
@dataclass | |
class Door: |
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 datetime | |
import os | |
import string | |
from random import randrange | |
from peewee import Model, DatabaseProxy, PostgresqlDatabase | |
from peewee import ForeignKeyField, BooleanField, TextField, IntegerField, CharField | |
NO_OF_DBS = 800 | |
NO_OF_POSTS = 50 |
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 datetime | |
import os | |
import string | |
from random import randrange | |
from peewee import Model, PostgresqlDatabase | |
from peewee import BooleanField, TextField, CharField | |
from playhouse.postgres_ext import ArrayField, BinaryJSONField | |
NO_OF_DBS = 500 |
OlderNewer