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
# inboxcheck.rb monitors a Gmail account for new mails and returns | |
# info (as JSON) about the first new mail from a specified address | |
# | |
# This is used to see if our newsletter testing mails arrive at | |
# Gmail and then if they go into spam, promotions or the normal inbox. | |
# | |
# To use or work on this script for yourself, follow steps 1 and 2 at | |
# https://developers.google.com/gmail/api/quickstart/ruby to get set | |
# up with the Google API stuff. Make sure client_secret.json ends up | |
# in the same directory as this script, then you're good to go. |
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
#!/usr/bin/env python | |
try: | |
# For Python 3.0 and later | |
from urllib.request import urlopen | |
except ImportError: | |
# Fall back to Python 2's urllib2 | |
from urllib2 import urlopen | |
import json |
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 elasticsearch | |
from math import log | |
def tfidf_matrix(es, index, doc_type, fields, size=10, bulk=500, query=dict(match_all=[])): | |
"""Generate tfidf for `size` documents of `index`/`doc_type`. | |
All `fields` need to have the mapping "term_vector": "yes". | |
This is the consuming version (i.e. get everything at once). | |
:param es: elasticsearch client |
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
# No flash messages are set with this controller. | |
# | |
# This is a fairly basic / bare controller which does only the basic CRUD. | |
class BooksController < ApplicationController | |
respond_to :html, :xml, :json | |
before_action :set_book, only: [:show, :edit, :update, :destroy] | |
def index | |
respond_with @books = Book.all |