Skip to content

Instantly share code, notes, and snippets.

Dino Fancellu fancellu

View GitHub Profile
@zhenwenc
zhenwenc / DoobieSyntax.scala
Last active Mar 30, 2020
Doobie ConnectionIO helpers for use with Quill integration
View DoobieSyntax.scala
import doobie._
import doobie.implicits._
import cats.data.NonEmptyList
import cats.implicits._
sealed abstract class UnexpectedResultSetSize(msg: String) extends Exception(msg)
final case object UnexpectedOptionalContinuation
extends UnexpectedResultSetSize(s"Expected ResultSet with zero or one row, but more rows were available.")
@fancellu
fancellu / .block
Last active Apr 12, 2020
Force directed graph for D3.js v4 with labelled edges and arrows
View .block
license: gpl-3.0
height: 600
@lihaoyi
lihaoyi / trace.scala
Last active Dec 27, 2015
Downloading JSON and splatting it into some files in 4 lines of Scala with Ammonite http://lihaoyi.github.io/Ammonite/
View trace.scala
haoyi-mbp:Ammonite haoyi$ ~/amm
Loading...
Welcome to the Ammonite Repl 0.5.2
(Scala 2.11.7 Java 1.8.0_25)
haoyi-Ammonite@ load.ivy("org.scalaj" %% "scalaj-http" % "2.2.0")
haoyi-Ammonite@ import ammonite.ops._, scalaj.http._
import ammonite.ops._, scalaj.http._
haoyi-Ammonite@ Http("https://api.github.com/repos/scala/scala").asString
res2: HttpResponse[String] = HttpResponse(
View output.txt
myfine.domain.user.actor.handlers.BetterAnonymousClassApp$$anon$1(mutingStuff = let's see, otherStuff = List(works, too), stuff = works, moreLazyStuff = myfine.domain.user.actor.handlers.BetterAnonymousClassApp$$anon$1$$anon$2(extensionData = This is just some extension data))
Disconnected from the target VM, address: '127.0.0.1:55780', transport: 'socket'
{
"mutingStuff" : "let's see",
"otherStuff" : [ "works, too" ],
"stuff" : "works",
"moreLazyStuff" : {
"extensionData" : "This is just some extension data"
}
}
@CliffordAnderson
CliffordAnderson / collect.cypher
Last active Jul 10, 2018
A Cypher examples to unwind and collect
View collect.cypher
match (a {name:"Daniel"}), (b {name:"Jerry"})
with a,b
match s = shortestPath(a-[]-b)
unwind nodes(s) as n
with collect(n) as m
return head(m)
@ScalaWilliam
ScalaWilliam / WSWithoutPlayApp.scala
Last active Jun 1, 2017
Running Play WS standalone, without a Play App. Works with Maven builds nicely. The top way to make REST calls in Scala, in my opinion.
View WSWithoutPlayApp.scala
package com.scalawilliam.example.play
import play.api.libs.ws._
/**
* Play's Scala WS library is very very cool. Provides you with plenty niceties.
* See more: https://www.playframework.com/documentation/2.3.x/ScalaWS
*
* Unfortunately it by default requires a Play application context.
* But you do not necessarily always want that.
@ScalaWilliam
ScalaWilliam / initialise.scala
Last active Aug 29, 2015
Embedded Jetty + Scalatra with Webjars loading (loads META-INF/resources data from the classpath jars). Works without any configuration in Jetty, jetty-maven-plugin, but not so easily in embedded form. Make sure to create websresources/index.html in your src/main/resources/ directory. Examples provided in Scalatra documentation are strange - set…
View initialise.scala
def initialiseApp[T<:LifeCycle](port: Int) = {
val server = new Server(port)
val context = new WebAppContext()
context.setContextPath("/")
context.setResourceBase(new File(getClass.getResource("/webresources/index.html").getFile).getCanonicalFile.getParentFile.getCanonicalPath)
context.addEventListener(new ScalatraListener)
context.addServlet(classOf[DefaultServlet], "/")
context.setInitParameter(ScalatraListener.LifeCycleKey, classOf[ConfiguredBootstrap].getCanonicalName)
context.setAttribute(WebInfConfiguration.WEBINF_JAR_PATTERN, ".*\\.jar$")
@fancellu
fancellu / TimestampMacro.scala
Created Jul 22, 2014
Simple Macro example, allows you to have a string which shows when last compiled. Remember that your main has to be in a different project to the macro (for the moment)
View TimestampMacro.scala
package com.felstar.macros.timestamp
import scala.reflect.macros.blackbox.Context
import scala.language.experimental.macros
object TimestampMacro {
def timestampString: String = macro timestampMacro
def timestampMacro(c: Context): c.Tree = {
import c.universe._
@kevinwright
kevinwright / scaladays2014.md
Last active Mar 8, 2018
Scaladays 2014 slides
View scaladays2014.md

As compiled by Kevin Wright a.k.a @thecoda

(executive producer of the movie, and I didn't even know it... clever huh?)

please, please, please - If you know of any slides/code/whatever not on here, then ping me on twitter or comment this Gist!

This gist will be updated as and when I find new information. So it's probably best not to fork it, or you'll miss the updates!

Monday June 16th

@milessabin
milessabin / gist:c51b6851548dae403abf
Created May 9, 2014
Type safe selectDynamic without macros
View gist:c51b6851548dae403abf
miles@frege:~$ scala
Welcome to Scala version 2.11.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_55).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import scala.language.dynamics
import scala.language.dynamics
scala> case class Assoc[K, V](value: V)
defined class Assoc
You can’t perform that action at this time.