Skip to content

Instantly share code, notes, and snippets.

View timeartist's full-sized avatar

Adi Wabisabi timeartist

  • Confluent
  • 8500 ft
View GitHub Profile
@timeartist
timeartist / README.md
Last active August 15, 2023 11:12
One File Product Catalog Service

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 February 28, 2018 22:33
Creating Deterministic Shard Sentinel Value keys
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)]
@timeartist
timeartist / redis-no-save.conf
Created November 23, 2015 21:04
Redis No Save
# 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
#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
@timeartist
timeartist / s3_uploader.py
Last active September 10, 2015 06:37
s3uploader
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
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)
@timeartist
timeartist / gist:288d916d5d26cef4569c
Created October 9, 2014 18:57
Pythonic Linked List
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):