class ElasticSearchCartDaily(object):
def __init__(self, es_index_name, host=None, version=_CONFIG.ELASTICSEARCH_VERSION):
hosts = (host, ) if host else _CONFIG.ELASTICSEARCH_HOSTS
self.es = Elasticsearch(hosts)
self.version = version
# Need two indices, one to alias to when we update the index, and one to hold historical stats.
# They will both be alternating as a search or update index per build
self.es_index_name_a = u'{}_a'.format(es_index_name)
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
SELECT DATE_TRUNC('day', checkout.created) AS checkout_date, | |
DATE_TRUNC('day', interaction.created) AS interaction_date, | |
CASE WHEN DATEDIFF('days', interaction.created, checkout.created) <= 15 THEN checkout.value | |
ELSE NULL END AS value, | |
interaction.owner_pub_id AS pub_id, | |
interaction.interaction_type AS interaction_type, | |
checkout.auction_id | |
FROM ( | |
SELECT interaction.interaction_type AS checkout_type, | |
interaction.owner_merch_id AS merch_id, |
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 'time' | |
class SubscriptionInitiationWorker < Boxxspring::Worker::TaskBase | |
def process_payload(payload) | |
if payload['create_subscription_tasks'] | |
properties_and_sources.each do |property_id, sources| | |
sources.each_with_index do |source, index| | |
if source.last_polled_at.nil? || Time.now.utc >= Time.parse(source.last_polled_at) + source.time_to_live | |
self.logger.info("Source (id: #{source.id}) was last polled more than (or exactly) #{source.time_to_live} seconds ago.") |
- If the service doesn’t already exist (Google, Facebook, Dailymotion), add the service & its oauth options:
# bedrocket-api/app/models/[service name]_service.rb
class DailymotionChannelService < SocialService
oauth 2, :dailymotion, client_options: :client_options, authorize_params: :authorize_params
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
2015-07-13T22:07:47.482910+00:00 heroku[vimeo_metadata.1]: Starting process with command `bundle exec rake worker:vimeo_metadata --trace` | |
2015-07-13T22:07:47.909739+00:00 heroku[vimeo_metadata.1]: Stopping all processes with SIGTERM | |
2015-07-13T22:07:48.063182+00:00 heroku[vimeo_metadata.1]: State changed from starting to up | |
2015-07-13T22:07:48.376967+00:00 app[vimeo_metadata.1]: rake aborted! | |
2015-07-13T22:07:48.377053+00:00 app[vimeo_metadata.1]: SignalException: SIGTERM | |
2015-07-13T22:07:48.377122+00:00 app[vimeo_metadata.1]: /app/vendor/ruby-2.1.6/lib/ruby/2.1.0/net/protocol.rb:155:in `select' | |
2015-07-13T22:07:48.377127+00:00 app[vimeo_metadata.1]: /app/vendor/ruby-2.1.6/lib/ruby/2.1.0/net/protocol.rb:155:in `rescue in rbuf_fill' | |
2015-07-13T22:07:48.377128+00:00 app[vimeo_metadata.1]: /app/vendor/ruby-2.1.6/lib/ruby/2.1.0/net/protocol.rb:152:in `rbuf_fill' | |
2015-07-13T22:07:48.377129+00:00 app[vimeo_metadata.1]: /app/vendor/ruby-2.1.6/lib/ruby/2.1.0/net/protocol.rb:134:in `readuntil' | |
2015-07-13T22:07:48.3771 |
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 the scripts in <head> | |
// (The carousel is dependent on jQuery and jQuery UI) | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js"></script> | |
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script> | |
<script src="/path/to/fullCarousel.js"></script> | |
// IN YOUR SCRIPT FILE: | |
// Input customized slideConfig. The format for begin and end date is [yyyy, mm, dd]: | |
var slideConfig = [ | |
{ src: 'http://waywire.com/media/site/YH5PLD0V56XPX2RS/uploads/AdamLevine_HomePageSlider_1aa.png', |
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
var naturals = new NaturalGen(); | |
var evens = new EvenGen(); | |
var odds = new OddGen(); | |
var fibbs = new FibbGen(); | |
var matches = new Match(evens, fibbs); | |
for (var i = 0; i < 10; i++) { | |
console.log(naturals.next()); | |
console.log(evens.next()); | |
console.log(odds.next()); |
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
// REFACTOR 1 | |
function loadFeed(url) { | |
var feed = new google.feeds.Feed(url); | |
feed.setNumEntries(1); | |
feed.load(function(result) { | |
for (var i = 0; i < result.feed.entries.length; i++) { | |
var $article = $('<div>').addClass('article'); | |
var $date = $('<div>').addClass('date').append(result.feed.entries[i].publishedDate); | |
var $link = $('<a>').attr('href', result.feed.entries[i].link); | |
var $title = $('<h3>').append(result.feed.entries[i].title); |
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
$ rspec | |
F | |
Failures: | |
1) Fashionista has a username | |
Failure/Error: fashionista = Fashionista.new(username: 'myfashionhub') | |
ActiveRecord::StatementInvalid: | |
PG::UndefinedTable: ERROR: relation "fashionistas" does not exist | |
LINE 5: WHERE a.attrelid = '"fashionistas"'::regclass |