Skip to content

Instantly share code, notes, and snippets.

View iloveluce's full-sized avatar

Luciano Arango iloveluce

View GitHub Profile
@peterc
peterc / inboxcheck.rb
Last active April 30, 2020 22:12
A Ruby script that checks a Gmail inbox for new mail and shares info about how it was classified
# 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.
@kgn
kgn / AppReviews
Created June 9, 2015 23:02
App Reviews - Python script to retrieve App Store reviews and save them to a CSV file
#!/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
@konradkonrad
konradkonrad / es_features.py
Last active January 25, 2022 23:52
tfidf from elasticsearch
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
@cupakromer
cupakromer / books_controller.rb
Last active May 19, 2020 10:20
Rails 4 Standard CRUD Controller
# 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