Skip to content

Instantly share code, notes, and snippets.

View valerybriz's full-sized avatar
🐍
Writing poetry in Python

Valery Briz valerybriz

🐍
Writing poetry in Python
View GitHub Profile
@doobeh
doobeh / eg.py
Created February 11, 2016 21:15
FormField/FieldList Example
from flask_wtf import Form
from wtforms import FormField, FieldList, DecimalField
from flask import Flask, render_template
app = Flask(__name__)
app.secret_key = 'SHG'
class PairForm(Form):
first = DecimalField('First')
second = DecimalField('Second')
@yarosla
yarosla / rxweb.py
Last active April 19, 2018 17:40
RxPy + Twisted example - simplistic web server.
# coding=utf-8
from StringIO import StringIO
from datetime import timedelta
from rx import Observer
from rx.concurrency import TwistedScheduler
from rx.disposables import Disposable
from rx.subjects import Subject
from twisted.internet.protocol import Factory, Protocol, connectionDone
from twisted.internet.endpoints import TCP4ServerEndpoint
@djamelz
djamelz / aliasSwitching.py
Created October 12, 2015 21:09
Elasticsearch Alias switching in python => restore the new one, close the latest and delete the olders (based on name versioning index_name_xxx, index_name_xxy for index name and index_name for alias)
from elasticsearch import Elasticsearch
es = Elasticsearch(hosts=['es-host:9200'], timeout=600) #long timeout for the restore operation
snapshotName='index_name_20151012140502'
alias = es.indices.get_alias('index_name').keys()[0] if es.indices.exists_alias(name='index_name') else ''
indices = filter(lambda x: x.startswith('index_name'), es.indices.get_aliases())
indices.sort()
print 'restore repository'
es.snapshot.restore(repository='repository_name', snapshot=snapshotName, body ='{ "ignore_unavailable": "true", "include_global_state": false}', wait_for_completion=True)
if (len(alias) > 1):