Skip to content

Instantly share code, notes, and snippets.

View msukmanowsky's full-sized avatar
🥳
Building the future of how companies work with elvex!

Mike Sukmanowsky msukmanowsky

🥳
Building the future of how companies work with elvex!
View GitHub Profile
@msukmanowsky
msukmanowsky / storm_transactional_mongodb.md
Last active August 29, 2015 13:56
Thoughts on how to achieve strict and opaque transactional Trident topologies with a hypothetical Mongo Trident state.

Storm Transactional Topologies with Mongo DB State

Strict Transactional State

  1. Batches for a given txid are always the same. Replays of batches for a txid will exact same set of tuples as the first time that batch was emitted for that txid.
  2. There's no overlap between batches of tuples (tuples are in one batch or another, never multiple).
  3. Every tuple is in a batch (no tuples are skipped)

Current DB document State

@msukmanowsky
msukmanowsky / image_file_validator.py
Last active November 13, 2017 19:51
An ImageFieldRequired validator for a Flask WTForm.
from flask.ext.wtf import Form
from flask.ext.wtf.file import FileField
import imghdr
class ImageFileRequired(object):
"""
Validates that an uploaded file from a flask_wtf FileField is, in fact an
image. Better than checking the file extension, examines the header of
@msukmanowsky
msukmanowsky / AspectRatio.java
Last active May 11, 2018 12:38
A little Python script and a Java Pig UDF showing how to produce aspect ratios for any arbitrary screen resolution.
package com.parsely.pig.screens;
import java.io.IOException;
import org.apache.pig.EvalFunc;
import org.apache.pig.data.Tuple;
/**
* This UDF takes a tuple with two positive ints specified 0 -> width
* and 1 -> height and returns the aspect ratio for the resolution.
from collections import defaultdict
try:
import cStringIO as StringIO
except ImportError:
import StringIO
class EscapedLineReader(object):
"""Custom reader for files where we could have escaped new lines.