I'm writing a small Ruby library:
class FizzBuzzEndpoint
def call(env)
// data density example | |
// shows how storing/sorting data by key can reduce I/O drastically in MongoDB | |
// diskloc gives file # and offset of a given document, divide by 512 for block # | |
// 2011 kcg | |
// start clean | |
db.disktest_noorg.drop(); | |
db.disktest_org.drop(); | |
// create some random data in non userid dense form |
import pymongo | |
import random | |
from collections import defaultdict | |
import time | |
import sys | |
from pymongo import Connection | |
connection = Connection() | |
connection.drop_database('test_db') | |
collection = connection['test_db']['testing'] |
module Export | |
module V1 | |
class GroupSerializer < ActiveModel::Serializers | |
attributes :items | |
def items | |
docs = object.items.order_by(:position.asc) | |
ItemsSerializer.new(docs, special_options).serializable_hash | |
end |
def self.fully_approved_query_value | |
MultiTenancy.current_version.locales.inject({}) do |result, locale| | |
result.merge(locale.to_s => true) | |
end | |
end |
module Models | |
module GroupByCaching | |
extend ActiveSupport::Concern | |
included do | |
CACHE_KEY_PREFIX = "#{self.name.collectionize}_grouped_by" | |
end | |
module ClassMethods |
/** | |
* Select2 | |
* | |
* Renders Select2 - jQuery based replacement for select boxes | |
* | |
* Simply pass a 'config' object on your schema, with any options to pass into Select2. | |
* See http://ivaynberg.github.com/select2/#documentation | |
*/ | |
Backbone.Form.editors.Select2 = Backbone.Form.editors.Base.extend({ |
class Group | |
include Mongoid::Document | |
recursively_embeds_many | |
end | |
# remove from old parent | |
@group.parent_group.child_groups.delete @group | |
# set new state |
# multilingual analysis for title search taken from : | |
# http://jprante.github.com/lessons/2012/05/16/multilingual-analysis-for-title-search.html | |
# or alternatively here (where the used plugin comes from, is less descriptive but has more technical details) | |
# https://github.com/yakaz/elasticsearch-analysis-combo | |
analysis: | |
filter: | |
germansnow: | |
type: snowball | |
language: German2 | |
ngram_filter: |
curl -XDELETE 'localhost:9200/test' | |
echo | |
curl -XPUT 'localhost:9200/test?pretty' -d '{ | |
"mappings" : { | |
"test" : { | |
"properties" : { | |
"text_de" : { | |
"type" : "string" | |
} |