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
package main | |
import ( | |
"fmt" | |
"gopkg.in/olivere/elastic.v2" | |
"strconv" | |
) | |
type Tweet struct { | |
User string `json:"user"` |
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
package main | |
// https://github.com/dps/go-xml-parse/blob/master/go-xml-parse.go | |
import ( | |
"fmt" | |
"os" | |
"encoding/xml" | |
) |
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 __future__ import print_function | |
import socket, sys | |
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | |
addr,path = sys.argv[1].split(":") | |
sock.connect(addr) | |
sock.send("""GET {} HTTP/1.1 | |
host: test.ru |
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
requests.put('http://localhost:9200/site/', data=json.dumps({ | |
'settings': { | |
'analysis': { | |
'analyzer': { | |
'ru': { | |
'type': 'custom', | |
'tokenizer': 'standard', | |
"filter": ['lowercase', 'russian_morphology', 'english_morphology', 'ru_stopwords'], | |
}, | |
}, |
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 string | |
# http://interactivepython.org/runestone/static/pythonds/Recursion/pythondsConvertinganIntegertoaStringinAnyBase.html | |
class AbcNumCoverter: | |
chars = string.digits + string.ascii_lowercase | |
base = len(chars) | |
@classmethod | |
def to_str(cls, n): |
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
cluster.name: mycluster | |
node.name: node-1 | |
node.master: true | |
node.data: true | |
network.host: 0.0.0.0 | |
transport.tcp.port: 9300 | |
http.port: 9200 |
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
LOGGING = { | |
'version': 1, | |
'disable_existing_loggers': True, | |
'formatters': { | |
'verbose': { | |
'format': '%(levelname)s %(asctime)s %(process)d %(module)s %(message)s' | |
}, | |
'simple': { | |
'format': '%(levelname)s %(message)s' | |
}, |
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 gc | |
from more_itertools import chunked | |
from collections import defaultdict | |
def fetch_fk(fk_field, fields, objects): | |
assert 'id' in fields | |
if not objects: | |
return |
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 django import forms | |
from django.db import models | |
class BitFieldWrapper: | |
def __init__(self, instance, field, value): | |
self.instance = instance | |
self.field = field | |
self.value = value |
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 'http://localhost:9200/_bulk?pretty' -d ' | |
{ "index" : { "_index" : "test", "_type" : "publication", "_id" : "1" } } | |
{ "title" : "The NoSQL database glut", "journal" : "2", "author": "1" } | |
{ "index" : { "_index" : "test", "_type" : "publication", "_id" : "2" } } | |
{ "title" : "Graph Databases Seen Connecting the Dots", "journal" : "1", "author": "2"} | |
{ "index" : { "_index" : "test", "_type" : "publication", "_id" : "3" } } | |
{ "title" : "How to determine which NoSQL DBMS best fits your needs", "journal" : "2", "author": "3" } | |
{ "index" : { "_index" : "test", "_type" : "publication", "_id" : "4" } } | |
{ "title" : "MapR ships Apache Drill", "journal" : "4", "author": "4" } | |