Skip to content

Instantly share code, notes, and snippets.

Avatar

Adi Wabisabi timeartist

  • Redis
  • 8500 ft
View GitHub Profile
@timeartist
timeartist / README.md
Last active Nov 9, 2021
One File Product Catalog Service
View README.md

Prerequisites:

  • Python 3.9+
  • Redis & RedisJSON 2.0

To run:

## if you want to run the container locally
docker run -d -p 6379:6379 redislabs/rejson:preview
pip3 install poetry
poetry install
@timeartist
timeartist / shard_key_creator.py
Created Feb 28, 2018
Creating Deterministic Shard Sentinel Value keys
View shard_key_creator.py
from subprocess import check_output
from uuid import uuid4
from redis import Redis
PORT = 19475
SHARD_IDS = [1,2,3,4]
R = Redis(port=PORT)
## keys is unsafe for production as it can block for a long time - use scan instead if testing there
_shard_keys_command = lambda shard_id, pattern: ['/opt/redislabs/bin/shard-cli', str(shard_id), 'keys', str(pattern)]
View redis-no-save.conf
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
View audio-delay-fixer.py
#pip installed
from appscript import app
QUICKTIME = '/Applications/Quicktime Player 7.app'
def offset_audio(file, offset_amount):
##Open the video
vid = app(QUICKTIME).open(file)
##Find the audio track
View s3_uploader.py
import math, os, signal, hashlib
from glob import glob
from filechunkio import FileChunkIO
from boto import connect_s3
from boto.s3.key import Key
from gevent import sleep
from gevent.pool import Pool
from gevent.event import Event
View gist:3b9dec6720c595c694b8
import signal
from os import getpid
from time import sleep
def never_die(signal, frame):
while True:
print "Can't stop won't stop"
signal.signal(signal.SIGTERM, never_die)
View gist:288d916d5d26cef4569c
class Tree(object):
def __init__(self, root=None):
self.root = root
@classmethod
def from_string(cls, tree_string):
raise NotImplementedError
def __contains__(self, item):
if isinstance(item, Node):