Skip to content

Instantly share code, notes, and snippets.

.DS_Store
tmp/*
@karmi
karmi / .gitignore
Last active December 11, 2015 08:18
.DS_Store
@karmi
karmi / movie-titles.rb
Created January 13, 2013 20:42
Multiple analyzers and query fields in Elasticsearch for auto-completion
require 'tire'
# Tire.configure { logger STDERR, level: 'debug' }
Tire.index('movie-titles') do
delete
create \
settings: {
index: {
analysis: {
@karmi
karmi / austen.rb
Created December 15, 2012 10:56
IRB Snippets for the #railsgirls Prague workshop
require 'open-uri'
# Otevreme soubor z Project Gutenberg, Jane Austen, "Pride and Prejudice"
#
file = open('http://www.gutenberg.org/cache/epub/1342/pg1342.txt')
# Nacteme soubor jako text
#
text = file.read
@karmi
karmi / .gitignore
Last active December 24, 2015 14:53
Build a virtual machine with Elasticsearch from scratch with Vagrant
.vagrant
Gemfile.lock
Berksfile.lock
tmp/
@karmi
karmi / run_selection_as_command.py
Created October 1, 2012 12:48
Run selection as command in Sublime Text
import os, sublime, sublime_plugin
# Select some text and execute it through bash
#
class RunSelectionAsCommandCommand(sublime_plugin.TextCommand):
def run(self, edit):
for region in self.view.sel():
if not region.empty():
# Get the selected text
command = self.view.substr(region)
@karmi
karmi / AsciiDoc.sublime-build
Created September 29, 2012 17:02
A simple Sublime Text build system for AsciiDoc
// A simple Sublime Text build system for AsciiDoc
//
// Install with:
//
// $ curl -# -k \
// -o "$HOME/Library/Application Support/Sublime Text 2/Packages/AsciiDoc/AsciiDoc.sublime-build" \
// https://raw.github.com/gist/3804588/AsciiDoc.sublime-build
//
{
"cmd": ["/usr/local/bin/asciidoc", "$file"],
@karmi
karmi / .gitignore
Created August 17, 2012 19:13
World's Smallest Application Hosted in elasticsearch
.DS_Store
tmp/
@karmi
karmi / .gitignore
Created August 16, 2012 12:00
Ember.js application with elasticsearch persistence and Goliath based proxy [http://www.elasticsearch.org/tutorials/2012/08/22/javascript-web-applications-and-elasticsearch.html]
.DS_Store
tmp/
@karmi
karmi / active_record_associations.rb
Created July 29, 2012 16:57
An example of elasticsearch & Tire setup for ActiveRecord associations
# An example of elasticsearch & Tire setup for ActiveRecord associations.
#
# A `Book has_many :chapters` scenario, with mapping and JSON serialization
# for indexing associated models.
#
# Demonstrates three important caveats as of now:
#
# 1. You you have to use `touch: true` in the `belongs_to` declaration,
# to automatically notify the parent model about the update.
#