View gist:1323387
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
function cartesianProductOf(){ | |
return _.reduce(arguments, function(mtrx, vals){ | |
return _.reduce(vals, function(array, val){ | |
return array.concat( | |
_.map(mtrx, function(row){ return row.concat(val); }) | |
); | |
}, []); | |
}, [[]]); | |
} |
View gist:7913652
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
require 'json' | |
require 'tempfile' | |
OLD_CLUSTER_ENDPOINT = '' # root endpoint | |
NEW_CLUSTER_ENDPOINT = '' # root endpoint | |
PER_PAGE = 3_000 | |
def get_json(url) | |
JSON.parse(`curl -s '#{url}'`) |
View TransportTest.java
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
import org.elasticsearch.action.bulk.BulkItemResponse; | |
import org.elasticsearch.action.bulk.BulkRequestBuilder; | |
import org.elasticsearch.action.bulk.BulkResponse; | |
import org.elasticsearch.action.search.SearchResponse; | |
import org.elasticsearch.client.Client; | |
import org.elasticsearch.client.transport.TransportClient; | |
import org.elasticsearch.common.settings.ImmutableSettings; | |
import org.elasticsearch.common.settings.Settings; | |
import org.elasticsearch.common.transport.InetSocketTransportAddress; | |
import org.elasticsearch.index.query.QueryBuilders; |
View gist:6689477
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
Tire.configure do | |
url QBOX_ENDPOINT | |
end | |
Tire.index(INDEX_NAME) do | |
delete_if_exists | |
create | |
end | |
json_filepaths.each do |filepath| |
View gist:5623373
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
require 'tire' | |
Tire.configure do | |
url "http://api.qbox.io/xxxxxxxx" | |
end | |
CONFIGURATION = { | |
mappings: { | |
product: { | |
properties: { |
View gist:2898588
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
# requires ImageMagick. very simple to install | |
# quick and simple image montaging | |
collage() { | |
# convert all images to png | |
# squash them into one grid-based .png | |
# cleanup | |
convert ./* MON%02d.png && montage ./MON*.png -geometry +0+0 __montage.png && rm ./MON* | |
} |
View gist:1387748
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
# Facets are little bits of info about visitors | |
# Each facet has it's own Mongo collection; however, | |
# Essential attributes of the facet are imbedded in an Impression. | |
# This greatly improves performance by avoiding extraneous lookups, | |
# but also links Facets to their respectful impressions, much like | |
# facet :has_many => :impressions | |
# The containing module serves to provide "facet definitions" -- |
View gist:1378576
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
module Arbiter | |
class Identity | |
@@data = Arbiter.db.collection('data') | |
@@coll = Arbiter.db.collection('page_ids') | |
def initialize | |
@length = identity_matrix['length'] | |
@last = identity_matrix['last'] | |
@idx = identity_matrix['idx'] |
View gist:1345428
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
require 'acceptance/admin/admin_spec' | |
feature 'Channel management', :js => true, :admin => true do | |
let!(:channel) { Fabricate(:channel) } | |
# TODO: make helper for doing something like | |
# on_page admin_channels_path do | |
# scenario... | |
View gist:1319903
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
(function($){ | |
// | |
//-------------------------------------- Model : Image | |
// | |
Image = Backbone.Model.extend({ | |
defaults: { | |
'delete' : false | |
} | |
}); | |
NewerOlder