Skip to content

Instantly share code, notes, and snippets.

@karmi
karmi / prices.sh
Last active December 15, 2015 16:09 — forked from imotov/prices.sh
curl -XDELETE "localhost:9200/test"
curl -XPUT "localhost:9200/test" -d '{
"mappings": {
"doc": {
"properties": {
"price": {
"type": "long"
},
"colour": {
"type": "string",
@karmi
karmi / d3.js
Last active April 18, 2016 06:13
A D3.js Tutorial: Bar Chart
!function() {
var d3 = {
version: "3.4.11"
};
if (!Date.now) Date.now = function() {
return +new Date();
};
var d3_arraySlice = [].slice, d3_array = function(list) {
return d3_arraySlice.call(list);
};
@karmi
karmi / Rakefile
Last active December 15, 2015 08:29
Národnosti a věkové skupiny (Panel Chart)
task :default => :run
# Serving files via Rack
desc "Serve the files via Rack and Thin"
task :run => [:dependencies] do
port = ENV['PORT'] || 8000
puts "Launching local webserver at <http://localhost:#{port}> ...", "-"*80
begin
@karmi
karmi / Rakefile
Last active December 15, 2015 07:39
Národnosti v regionech České Republiky (Bubble Chart)
task :default => :run
# Serving files via Rack
desc "Serve the files via Rack and Thin"
task :run => [:dependencies] do
port = ENV['PORT'] || 8000
puts "Launching local webserver at <http://localhost:#{port}> ...", "-"*80
begin
@karmi
karmi / example.sh
Last active October 3, 2019 03:31
A simple Elasticsearch example
# Let's delete the index first
curl -X DELETE localhost:9200/people
# Create an index with specific settings
curl -X POST localhost:9200/people -d '{
"settings" : {
"index" : { "number_of_shards" : 1, "number_of_replicas" : 0 }
}
}'
@karmi
karmi / generate.rb
Last active December 14, 2015 19:19
Simple CSV import to Elasticsearch with Tire
# Usage:
#
# $ ruby generate.rb > people.csv
require 'time'
require 'faker'
require 'oj'
COUNT = (ENV['COUNT'] || 1000).to_i
@karmi
karmi / data
Last active July 19, 2017 08:34
An example of request definitions in external files.
{ "index" : { "_index" : "myindex", "_type" : "document", "_id" : "1" } }
{ "title" : "Jumping High" }
{ "index" : { "_index" : "myindex", "_type" : "document", "_id" : "2" } }
{ "title" : "Diving Deeper" }
@karmi
karmi / .gitignore
Last active December 14, 2015 08:29
A demo of Dangle chart components for Angular.js and Elasticsearch
.DS_Store
@karmi
karmi / Gemfile
Last active August 4, 2021 13:53 — forked from rkh/Gemfile
Sinatra + EventSource JavaScript Streaming
source "http://rubygems.org/"
gem "sinatra", "~> 1.3.0"
gem "thin"
@karmi
karmi / README.markdown
Last active February 13, 2017 12:27
Script fields in Elasticsearch

This example demostrates how to manipulate search results with the script_fields support in Elasticsearch.