Skip to content

Instantly share code, notes, and snippets.

View randidwiputra's full-sized avatar
💭
Open for new opportunity. Remote or Onsite

Randi Dwi Putra randidwiputra

💭
Open for new opportunity. Remote or Onsite
  • Freelancer
  • Jakarta - Indonesia
View GitHub Profile
@randidwiputra
randidwiputra / word-service.py
Created February 19, 2018 10:56 — forked from joegle/word-service.py
Flask + gensim word2vec
from gensim.models import word2vec
import logging
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
model1 = word2vec.Word2Vec.load_word2vec_format('models/glove_model.txt', binary=False)
model1.init_sims(replace=True)
from flask import Flask, jsonify, request
app = Flask(__name__)
@randidwiputra
randidwiputra / TokenAuthenticator.scala
Created August 24, 2016 08:01 — forked from chrisgibson/TokenAuthenticator.scala
Spray Token Authentication
import scala.concurrent.{ExecutionContext, Future}
import spray.routing.{AuthenticationFailedRejection, RequestContext}
import spray.routing.authentication.{Authentication, ContextAuthenticator}
/** Token based authentication for Spray Routing.
*
* Extracts an API key from the header or querystring and authenticates requests.
*
* TokenAuthenticator[T] takes arguments for the named header/query string containing the API key and
* an authenticator that returns an Option[T]. If None is returned from the authenticator, the request