Skip to content

Instantly share code, notes, and snippets.

@iref
iref / repo_stats.py
Created May 21, 2018 16:28
Get GH user's most popular repos
from collections import namedtuple
Repo = namedtuple('Repo', 'name stars forks')
def get_repo_stats(user, n=5):
"""Takes a Github user object and returns the top n most popular repos by star count,
skips forks."""
repos = []
@iref
iref / bot.py
Last active April 18, 2018 19:34
from discord.ext import commands
from bb8.embed import CardImage
from bb8.search import Search
from bb8.swdestinydb import SWDestinyDBClient
import logging
import os
DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN")
import scala.language.higherKinds
import cats.data._
import cats.effect.Sync
import cats.implicits._
import org.http4s.HttpService
import org.http4s.dsl.Http4sDsl
import org.http4s.implicits._
class Example[F[_] : Sync] extends Http4sDsl[F] {
Traceback (most recent call last):
File "./env/lib/python3.5/site-packages/peewee.py", line 3688, in _create_connection
return self._connect(self.database, **self.connect_kwargs)
File "./env/lib/python3.5/site-packages/peewee.py", line 3939, in _connect
conn = sqlite3.connect(database, **kwargs)
sqlite3.OperationalError: unable to open database file
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
final class Reporter(scheduler: Scheduler) extends Observable[Payload] {
implicit val s = scheduler
// TODO define overflow strategy.
private val subject = ConcurrentSubject.publish[Payload]()
def unsafeSubscribeFn(subscriber: Subscriber[Payload]): Cancelable = {
subject.unsafeSubscribeFn(subscriber)
}
final case class UserId(id: Long) extends AnyVal
final case class User(email: String, name: String, passwordDigest: String, createdAt: Instant, updatedAt: Instant)
final case class UserAndId(user: User, id: UserId)
sealed abstract class SignupError extends Product with Serializable
case object EmailAlreadyUsed
final case class Authenticated(email: String, token: Token)
final case class Token(get: UUID = UUID.randomUUID())
@iref
iref / error.log
Last active December 2, 2016 15:12
Logback ElasticSearch 5 setup
java.lang.ClassCastException: org.apache.logging.slf4j.SLF4JLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext
at org.apache.logging.log4j.core.LoggerContext.getContext(LoggerContext.java:178)
at org.apache.logging.log4j.core.config.Configurator.setLevel(Configurator.java:290)
at org.elasticsearch.common.logging.Loggers.setLevel(Loggers.java:149)
at org.elasticsearch.common.logging.Loggers.setLevel(Loggers.java:144)
at org.elasticsearch.index.SearchSlowLog.setLevel(SearchSlowLog.java:114)
at org.elasticsearch.index.SearchSlowLog.<init>(SearchSlowLog.java:109)
at org.elasticsearch.index.IndexModule.<init>(IndexModule.java:114)
at org.elasticsearch.indices.IndicesService.createIndexService(IndicesService.java:406)
at org.elasticsearch.indices.IndicesService.createIndex(IndicesService.java:378)
@iref
iref / evolutions-di.scala
Last active September 4, 2015 11:19
Running evolutions with Compile-time DI
trait ApplicationComponent extends BuiltInComponents with SlickComponents
with I18nComponents with EvolutionsComponents with SlickEvolutionsComponents {
lazy val dbConfigProvider: DatabaseConfigProvider = new DatabaseConfigProvider {
override def get[P <: BasicProfile]: DatabaseConfig[P] = api.dbConfig(DbName("default"))
}
lazy val router: Router = wire[Routes] withPrefix "/"
lazy val assets: Assets = wire[Assets]
@iref
iref / gist:2b6586b5bb9d5400471b
Last active August 29, 2015 14:09
Implicits session is not found in passed anonymous function
package models
import org.specs2.mutable.Specification
import play.api.Play.current
import play.api.db.slick.{DB, Session}
import play.api.db.slick.Config.driver.simple._
import play.api.test.FakeApplication
import play.api.test.Helpers._
class UserSpec extends Specification {
<module xmlns="urn:jboss:module:1.1" name="company.handler">
<resources>
<resource-root path="company-handler.jar" />
</resources>
<dependencies>
<module name="javax.api"/>
<module name="org.jboss.logging"/>
<module name="org.javassist" />
<module name="org.jboss.as.logging" export="true">