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 | |
from mongokit import CustomType, Document, Connection | |
class CustomDate(CustomType): | |
mongo_type = unicode | |
python_type = datetime.datetime # optional, just for more validation | |
init_type = None # optional, fill the first empty value | |
def to_bson(self, value): | |
"""convert type to a mongodb type""" |
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 dingus import Dingus | |
class DeterministicDingus(Dingus): | |
"""This dingus returns a different Dingus depending on the arguments it's called with. | |
It has the property of being purely deterministic (i.e. the same | |
arguments always return the same object). Unfortunately this | |
means that the behaviour of returning an identical `Dingus` when | |
called without arguments is lost. |
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
# -*- coding: utf-8 -*- | |
# Author: Douglas Creager <dcreager@dcreager.net>, Allan Caffee <allan.caffee@gmail.com> | |
# This file is placed into the public domain. | |
# Calculates the current version number. If possible, this is the | |
# output of “git describe”, modified to conform to the versioning | |
# scheme that setuptools uses. If “git describe” returns an error | |
# (most likely because we're in an unpacked copy of a release tarball, | |
# rather than in a git working copy), then we fall back on reading the | |
# contents of the RELEASE-VERSION file. |
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
curl -XPUT localhost:9200/test_a/type1/1 -d '{ | |
"url" : "http://example.com/blog" | |
}' | |
# {"ok":true,"_index":"test_a","_type":"type1","_id":"1","_version":1} | |
curl localhost:9200/test_a/type1/_search?pretty=true -d '{ | |
"query": { | |
"term": { | |
"url": "http://example.com/blog" | |
} |
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
curl -X PUT 'http://localhost:9200/articles/article/1?pretty=true' -d '{ | |
"title": "One", | |
"some_date": "2000-01-01T00:00:00" | |
}' | |
# { | |
# "ok" : true, | |
# "_index" : "articles", | |
# "_type" : "article", | |
# "_id" : "1", |
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
domains = """ | |
am.example.com | |
ap.example.com | |
eu.example.com | |
itd.sel.example.com | |
jp.example.com | |
ncope.account.example.com | |
bizbat.example.com | |
scesh.example.com | |
smss.example.com |
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
#!/usr/bin/env python3 | |
import itertools | |
import re | |
import sys | |
from base64 import b64encode | |
from hashlib import sha256 | |
import phonenumbers | |
import pytz | |
from csvkit import DictReader, DictWriter |