Skip to content

Instantly share code, notes, and snippets.

View almeidap's full-sized avatar

Pedro De almeida almeidap

View GitHub Profile
$.each(document.styleSheets, function(index) {
var id = this.href || '[inline]',
rules = this.cssRules ? this.cssRules.length : 0,
selectors = 0;
$.each(this.cssRules, function() {
if (this.selectorText) {
try {
selectors += this.selectorText.split(',').length;
} catch (err) {
@almeidap
almeidap / ImageApiController.scala
Last active September 14, 2020 13:32
DAO & Controller example for image manipulation & serving with ReactiveMongo (http://reactivemongo.org/) and Scrimage (https://github.com/sksamuel/scrimage). This code uses the DAO design for ReactiveMongo available here: https://gist.github.com/almeidap/5685801
import scala.concurrent.Future
import play.api.mvc._
import reactivemongo.api.gridfs.{ReadFile, GridFS}
import reactivemongo.bson.BSONValue
import core.dao.ImageDao
import enums.ImageSize
@almeidap
almeidap / BaseDAO.scala
Last active March 25, 2023 12:26
DAO design for ReactiveMongo using JSONCollection and Play2 Scala JSON API (work in progress).
package core.dao
import scala.concurrent.Future
import play.api.Logger
import reactivemongo.core.commands.LastError
import reactivemongo.core.errors.DatabaseException
import core.db.MongoHelper