Skip to content

Instantly share code, notes, and snippets.

View itsadok's full-sized avatar

Israel Tsadok itsadok

  • Tel Aviv, Israel
View GitHub Profile
@itsadok
itsadok / reindex.py
Last active January 1, 2016 07:09 — forked from bracki/reindex.py
Simple reindex for elasticsearch using pyes >= 0.19.1
>>> import pyes
>>> conn = pyes.es.ES("localhost:9200")
>>> search = pyes.query.MatchAllQuery().search(bulk_read=1000)
>>> hits = conn.search(search, 'index', 'type', scan=True, scroll="30m", model=lambda _,hit: hit)
>>> for hit in hits
... conn.index(hit['_source'], 'new_index', 'type', hit['_id'], bulk=True)
...
>>> conn.flush()
@itsadok
itsadok / behaviors.js
Created July 12, 2011 07:37 — forked from yuvaltobias/behaviors.js
Behavior-registration for UJS with jQuery
// An Unobtrusive Javascript (UJS) driver based on explicit behavior definitions. Just
// put a "data-behaviors" attribute on your view elements, and then assign callbacks
// for those named behaviors via Behaviors.add.
$.behaviors = {
add: function(trigger, behavior, handler) {
$('[data-behaviors~=' + behavior + ']').each(function() {
$(this).bind(trigger, handler);
});
}