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
class Module | |
# Return all constants presently defined | |
def all_constants | |
# I <3 you ActiveSupport, really I do! | |
if defined?(ActiveSupport::Deprecation) | |
ActiveSupport::Deprecation.silence { __all_constants } | |
else | |
__all_constants | |
end | |
end |
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 simplejson as json | |
import lxml | |
class objectJSONEncoder(json.JSONEncoder): | |
"""A specialized JSON encoder that can handle simple lxml objectify types | |
>>> from lxml import objectify | |
>>> obj = objectify.fromstring("<Book><price>1.50</price><author>W. Shakespeare</author></Book>") | |
>>> objectJSONEncoder().encode(obj) | |
'{"price": 1.5, "author": "W. Shakespeare"}' | |
""" |
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/dbparent/metadata/1' -d '{ "user" : "senthil", "Title" : "trying out Elastic Search"}' | |
curl -XPUT 'http://localhost:9200/dbparent/metadata/2' -d '{ "user" : "kumar", "Title" : "Elastic Search"}' | |
curl -XPUT 'http://localhost:9200/dbparent/child/_mapping' -d '{ "child" : { "_parent" : { "type" : "metadata" } }}' | |
curl -XPUT 'http://localhost:9200/dbparent/child/1?parent=1' -d '{ "tag" : "something"}' | |
curl -XGET 'http://localhost:9200/dbparent/_search' -d '{ |
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 sys | |
from gevent import server | |
from multiprocessing import Process, current_process, cpu_count | |
def note(format, *args): | |
sys.stderr.write('[%s]\t%s\n' % (current_process().name, format%args)) | |
def echo(socket, address): | |
print 'New connection from %s:%s' % address |
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 sys | |
import gevent | |
from gevent.monkey import patch_all; patch_all() | |
from gevent import server, event, socket | |
from multiprocessing import Process, current_process, cpu_count | |
""" | |
Simple multiprocess StreamServer that proxies messages between clients. | |
Avoids using a multiprocessing.Event since it blocks on a semaphore. |
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
# Encoding: utf-8 | |
# The following code is under BSD 2-clause license | |
# -> http://en.wikipedia.org/wiki/BSD_licenses#2-clause_license_.28.22Simplified_BSD_License.22_or_.22FreeBSD_License.22.29 | |
# | |
# Author: Stefan Rusterholz <[email protected]> - https://github.com/apeiros/ | |
# | |
# A module to help with transliteration issues. | |
# Provides methods for: | |
# * Changing the case of characters/strings, mapping most latin characters |
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
var BaseObject = { | |
create: function create() { | |
var instance = Object.create(this); | |
instance._construct.apply(instance, arguments); | |
return instance; | |
}, | |
extend: function extend(properties, propertyDescriptors) { | |
propertyDescriptors = propertyDescriptors || {}; |
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
# All of this testing was done on an AWS m1.large with a single Python | |
# process. I ran the commands multiple times and the numbers below are | |
# typical of the behavior, though they are the results of two particular | |
# cases | |
# Brubeck with Gevent | |
$ siege -c500 -t10s localhost:6767/brubeck | |
Lifting the server siege... done. |
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
license: gpl-3.0 |
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
# ======================================== | |
# Testing n-gram analysis in ElasticSearch | |
# ======================================== | |
curl -X DELETE localhost:9200/ngram_test | |
curl -X PUT localhost:9200/ngram_test -d ' | |
{ | |
"settings" : { | |
"index" : { | |
"analysis" : { |
OlderNewer