Skip to content

Instantly share code, notes, and snippets.

View brusic's full-sized avatar

Ivan Brusic brusic

View GitHub Profile
@brusic
brusic / split_config.rb
Created February 12, 2019 18:32 — forked from YurySolovyov/split_config.rb
Split Reentrant A/B Ext.
rails_env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
Split.redis = YAML.load_file(Rails.root.join('config/split.yml')).fetch(rails_env)
Split.configure do |config|
adapter = Split::Persistence::RedisAdapter.with_config(
lookup_by: :params_user_id,
namespace: 'abtesting_participant_id',
expire_seconds: 2_592_000, # 30 days
)
@brusic
brusic / 1 mapping
Created November 10, 2014 19:48
Nested aggregation issue
curl -XPUT localhost:9200/test -d '{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0
}
},
"mappings": {
"test" : {
"properties" : {
@brusic
brusic / sed with \n support
Created September 30, 2014 21:12
Convert Elasticsearch search results to Elasticsearch bulk index format
sed -e 's/{"took":[0-9]*,"timed_out":false,"_shards":{"total":[0-9]*,"successful":[0-9]*,"failed":0},"hits":{"total":[0-9]*,"max_score":[0-9\.]*,"hits":\[\(.*\)\]}}$/\1/' -e 's/}},/}}\n/g' -e 's/{"_index"/{ "index":{"_index"/' -e 's/,"_score":[0-9\.]*, "_source" : /}}\n/g'
@brusic
brusic / Option 1
Created April 3, 2014 16:50
Log4j socket appender -> Logstash
appender:
socketA:
type: org.apache.log4j.net.SocketAppender
port: 9500
remoteHost: logstash-server
socketB:
type: org.apache.log4j.net.SocketAppender
port: 9501
remoteHost: logstash-server
@brusic
brusic / NormRemovalSimilarity.java
Last active August 29, 2015 13:57
Norm Removal Machine
package org.elasticsearch.index.similarity;
import org.apache.lucene.search.similarities.DefaultSimilarity;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
public class NormRemovalSimilarity extends DefaultSimilarity {
private ESLogger logger;
@brusic
brusic / Mapping with no explicit boost field
Created February 16, 2014 00:38
Document boosting with Elasticsearch
curl -XPOST localhost:9200/boosts -d '
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"doc": {
"properties": {
"text": {
@brusic
brusic / gist:8185134
Created December 30, 2013 17:32
facet filter example
{
"query": {
"match_all": {}
},
"filter": {
"term": {
"model": "vw"
}
},
"facets": {
// TEST DATA
curl -XPUT http://localhost:9200/twitter/user/kimchy -d '{
"name" : "Shay Banon"
}'
curl -XPUT http://localhost:9200/twitter/tweet/1 -d '{
"user": "kimchy",
"post_date": "2009-11-15T13:12:00",
"message": "Trying out elasticsearch, so far so good?"
@brusic
brusic / benchmark.m
Created September 7, 2011 20:07
Benchmark code
// define inside file timetest.m
function blank = timetest(x, y, MAX_ITR)
m = length(y);
x = [ones(m, 1) x];
theta = zeros(size(x(1,:)))'; % initialize fitting parameters
alpha = 0.07;
for num_iterations = 1:MAX_ITR
grad = (1/m).* x' * ((x * theta) - y);
theta = theta - alpha .* grad;