Skip to content

Instantly share code, notes, and snippets.

@martijnvg
martijnvg / 1.sh
Created January 28, 2013 16:35
Nested type and nested facets
curl -s -XPUT 'localhost:9200/test1' -d '{
"mappings" : {
"records" : {
"properties" : {
"coords" : {
"type" : "nested",
"properties" : {
}
}
}
@jbgo
jbgo / debug_system_stack_error.md
Created January 9, 2013 15:08
debug SystemStackError in ruby 1.9

This is how I debug SystemStackError when there is no stack trace.

My first attempt was:

begin
  a_method_that_causes_infinite_recursion_in_a_not_obvious_way
rescue SystemStackError
  puts caller
end
Capybara.add_selector :record do
xpath { |record| XPath.css("#" + ActionController::RecordIdentifier.dom_id(record)) }
match { |record| record.is_a?(ActiveRecord::Base) }
end
@steveklabnik
steveklabnik / pair
Created November 9, 2012 13:09
A ruby script to change pairs
#!/usr/bin/env ruby
def usage
puts "./pair [name]: pair two people"
puts "./pair : switch to just steve"
exit
end
def set_config(name, email)
`git config user.name "#{name}"`
@clintongormley
clintongormley / gist:3888120
Created October 14, 2012 09:44
Upgrading a running elasticsearch cluster

Yesterday I upgraded our running elasticsearch cluster on a site which serves a few million search requests a day, with zero downtime. I've been asked to describe the process, hence this blogpost.

To make it more complicated, the cluster was running elasticsearch version 0.17.8 (released 6 Oct 2011) and I upgraded it to the latest 0.19.10. There have been 21 releases between those two versions, with a lot of functional changes, so I needed to be ready to roll back if necessary.

Our setup:

  • elasticsearch

We run elasticsearch on two biggish boxes: 16 cores plus 32GB of RAM. All indices have 1 replica, so all data is stored on both boxes (about 45GB of data). The primary data for our main indices is also stored in our database. We have a few other indices whose data is stored only in elasticsearch, but are updated once daily only. Finally, we store our sessions in elasticsearch, but active sessions are cached in memcached.

@joho
joho / gist:3735740
Created September 17, 2012 05:40 — forked from rafaelss/gist:3700977
PostgreSQL 9.2 upgrade steps
Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. brew update
4. brew upgrade postgresql
5. initdb /usr/local/var/postgres -E utf8
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
7. cp /usr/local/Cellar/postgresql/9.2.0/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
@karmi
karmi / .gitignore
Created August 17, 2012 19:13
World's Smallest Application Hosted in elasticsearch
.DS_Store
tmp/
@ferblape
ferblape / gist:3314376
Created August 10, 2012 13:57
La mejor hamburguesa de Madrid™
  1. Alfredos
  2. Madcafé
  3. New York Burger
  4. Homeburger
  5. San Wich
  6. La vaca picada
 _____ 
@greypants
greypants / README.markdown
Last active October 17, 2023 05:49 — forked from reagent/nav_link.rb
RAILS 3: nav_link helper for adding 'selected' class to navigation elements
@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.
#