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
# Recursively diff two hashes, showing only the differing values. | |
# By Henrik Nyh <http://henrik.nyh.se> 2009-07-14 under the MIT license. | |
# | |
# Example: | |
# | |
# a = { | |
# "same" => "same", | |
# "diff" => "a", | |
# "only a" => "a", | |
# "nest" => { |
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
This is an example how to perform multi-select faceting in ElasticSearch. | |
Selecting multiple values from the same facet will result in an OR filter between each of the values: | |
(facet1.value1 OR facet1.value2) | |
Faceting on more than one facet will result in an AND filter between each facet: | |
(facet1.value1 OR facet1.value2) AND (facet2.value1) | |
I have chosen to update the counts for each facet the selected value DOES NOT belong to since we are performing an AND between each facet. I have included an example that shows how to keep the counts if you don't want to do this (filter0.sh). |
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 CommentsController < ApplicationController | |
# GET /comments | |
# GET /comments.json | |
def index | |
@comments = Comment.all | |
respond_to do |format| | |
format.html # index.html.erb | |
format.json { render json: @comments } | |
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
$.ajax({ | |
url: url, | |
data: data, | |
success: function (data) { | |
var blob = new Blob([data]); | |
var link = document.createElement('a'); | |
link.href = window.URL.createObjectURL(blob); | |
link.download = "Dossier.pdf"; | |
link.click(); | |
} |
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
headers['X-Accel-Buffering'] = 'no' | |
headers['Cache-Control'] = 'no-cache' | |
headers['Content-Type'] = 'text/csv; charset=utf-8' | |
headers['Content-Disposition'] = 'inline; filename="data.csv"' | |
headers['Content-Encoding'] = 'gzip' | |
sql = "select * from something;" | |
self.response_body = SqlToCsvStreamer.new(sql) |