Skip to content

Instantly share code, notes, and snippets.

View imankulov's full-sized avatar

Roman Imankulov imankulov

View GitHub Profile
@imankulov
imankulov / bitmapist_workaround.py
Created February 23, 2017 19:13
Workaround for broken "foo AND NOT bar" logic in bitmapist
>>> bitmapist.mark_unique('foo', 1)
>>> bitmapist.mark_unique('foo', 1000)
>>> bitmapist.mark_unique('bar', 1)
>>> list(bitmapist.UniqueEvents('foo') & ~bitmapist.UniqueEvents('bar'))
[]
>>> list(bitmapist.UniqueEvents('foo') ^ bitmapist.UniqueEvents('bar') & bitmapist.UniqueEvents('foo'))
[1000]
@imankulov
imankulov / .tmux
Created December 27, 2016 13:56
mx sample config
session=wahoo
[first]
cmd='echo Wahoo!' C-m
[second]
cmd='echo Heya.' C-m
@imankulov
imankulov / jump_hash.py
Created May 30, 2016 16:23
Jump hash with linear probing
"""
Jump hash with linear probing
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
JumpHash(N) maps consistently integer values onto the range [0, N), which can
be used to map users (by their user ids) to servers (by their indexes in
a configuration file, for example).
There is one important limitation of the hash, which affects its
use: buckets (servers) must be numbered sequentially, and it's important
@imankulov
imankulov / recursive.py
Created March 9, 2016 14:32
recursive.py
def change_type(root, old_type, new_type):
"""
Helper function to recursively walk through the datastructure and change old_type to new_type
"""
def _match(obj, **kwargs):
return isinstance(obj, old_type)
def _replace(obj, **kwargs):
return new_type(obj)
{
"af": {
"name": "Afrikaans",
"formula": "n != 1",
"plurals": 2,
"cases": [
"one",
"other"
],
"examples": {
@imankulov
imankulov / cldr_test.sh
Created December 8, 2015 21:53
CLDR test
#!/bin/bash
function create_venv() {
test -d env || virtualenv env
source ./env/bin/activate
pip install -q -U pip
}
function babel_from_pip() {
echo "=================================================="
echo "Running tests with Babel 2.1.1, installed with pip"
@imankulov
imankulov / detached_screen.sh
Created November 27, 2015 09:50
Detached screen
screen -d -m -S screen_with_cat /bin/cat
@imankulov
imankulov / text.md
Last active December 14, 2020 15:38

Overview of localization tools.

I have collected a large number of proposals from Artyom, Roman, Nuno, Goncalo, selected 8 of them in my opinion the most successful platforms and checked how well they fit us.

I checked which of service fit us on the basis of features reviews from Goncalo, Nuno, and Roman, and tested following features:

  • Format support - localization formats which we can upload / download to / from service
  • Integrate with - Parameter indicates that the service is integrated with the app store. Since Nuno reported problems that changing in the localization files have to wait long for a confirmation.
  • Quality checks - checks on the correctness of the translation
  • Prulals - supports multiple forms and checks their spelling
@imankulov
imankulov / text.md
Last active December 14, 2020 15:38

Overview of localization tools.

I have collected a large number of proposals from Artyom, Roman, Nuno, Goncalo, selected 8 of them in my opinion the most successful platforms and checked how well they fit us.

I checked which of service fit us on the basis of features reviews from Goncalo, Nuno, and Roman, and tested following features:

  • Format support - localization formats which we can upload / download to / from service
  • Quality checks - checks on the correctness of the translation
  • Prulals - supports multiple forms and checks their spelling
  • Glossary - helps to standardize the way terms in your project are translated
@imankulov
imankulov / dictify.py
Created February 18, 2015 18:01
dictify.py -- extract "__dict__" contents from all objects recursively, and build a tree of them.
import json
def dictify(obj):
"""
Recursively find all dicts in a stricture, and convert them to attr dict
"""
if isinstance(obj, (list, tuple, set)):
return obj.__class__([dictify(item) for item in obj])
if isinstance(obj, dict):