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 / 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);
});
}
@itsadok
itsadok / jquery.selectbox-1.2.js
Created August 11, 2011 12:48
jQuery selectbox plugin
/*
* jQuery selectbox plugin
*
* Copyright (c) 2007 Sadri Sahraoui (brainfault.com)
* Licensed under the GPL license and MIT:
* http://www.opensource.org/licenses/GPL-license.php
* http://www.opensource.org/licenses/mit-license.php
*
* The code is inspired from Autocomplete plugin (http://www.dyve.net/jquery/?autocomplete)
*
@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()