Skip to content

Instantly share code, notes, and snippets.

Avatar
🚲

Vlad Derzhavin avevlad

🚲
View GitHub Profile
@avevlad
avevlad / gist:dc8ba65c8e5b5367f879
Created Oct 19, 2015 — forked from ctcarrier/gist:9918087
Joda DateTime Serializer for ReactiveMongo
View gist:dc8ba65c8e5b5367f879
import reactivemongo.bson.{BSONHandler, BSONDateTime, Macros}
import org.joda.time.format.ISODateTimeFormat
import org.joda.time.{DateTime, DateTimeZone}
package object myApp {
DateTimeZone.setDefault(DateTimeZone.UTC)
implicit object BSONDateTimeHandler extends BSONHandler[BSONDateTime, DateTime] {
val fmt = ISODateTimeFormat.dateTime()
def read(time: BSONDateTime) = new DateTime(time.value)
@avevlad
avevlad / YearOrderIncomeReport.scala
Created Oct 8, 2015 — forked from yujikiriki/YearOrderIncomeReport.scala
ReactiveMongo aggregation pipeline example
View YearOrderIncomeReport.scala
private def query( ): Future[ List[ JsObject ] ] = {
val group: Group = Group( BSONString( "$order.year" ) )( ("total", SumField( "value" )) )
val pipeline: Seq[ PipelineOperator ] = Seq( group )
val command: Future[ Stream[ BSONDocument ] ] = db.command( Aggregate( "opportunities", pipeline ) )
command map {
c =>
c.toList map {
d =>
toJSON( d ).asInstanceOf[ JsObject ]
}
View parse.py
import requests
from bs4 import BeautifulSoup
class Parser:
def __init__(self):
self.fl()
def fl(self):
payload = {